Updated letter frequencies, updated test values to reflect them
[cipher-training.git] / lettercount.py
index 18f75c48db4d8f141f19a645267a86f58b704d5e..956eca1a5b2ba469d66c80612446726cdf8307d4 100644 (file)
@@ -8,8 +8,6 @@ for corpus in corpora:
     text = sanitise(open(corpus).read())
     counts.update(text)
 
-sorted_letters = sorted(counts, key=counts.get, reverse=True)
-
 with open('count_1l.txt', 'w') as f:
-    for l in sorted_letters:
-        f.write("{}\t{}\n".format(l, counts[l]))
+    for l, c in counts.most_common():
+        f.write("{}\t{}\n".format(l, c))