3 from utilities
import sanitise
6 # return [l.lower() for l in text if l in string.ascii_letters]
8 corpora
= ['shakespeare.txt', 'sherlock-holmes.txt', 'war-and-peace.txt']
9 counts
= collections
.defaultdict(int)
11 for corpus
in corpora
:
12 text
= sanitise(open(corpus
, 'r').read())
16 sorted_letters
= sorted(counts
, key
=counts
.get
, reverse
=True)
18 with
open('count_1l.txt', 'w') as f
:
19 for l
in sorted_letters
:
20 f
.write("{0}\t{1}\n".format(l
, counts
[l
]))