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