7 english_counts
= collections
.defaultdict(int)
8 with
open('count_1l.txt', 'r') as f
:
10 (letter
, count
) = line
.split("\t")
11 english_counts
[letter
] = int(count
)
12 normalised_english_counts
= norms
.normalise(english_counts
)
14 english_bigram_counts
= collections
.defaultdict(int)
15 with
open('count_2l.txt', 'r') as f
:
17 (bigram
, count
) = line
.split("\t")
18 english_bigram_counts
[bigram
] = int(count
)
19 normalised_english_bigram_counts
= norms
.normalise(english_bigram_counts
)
21 english_trigram_counts
= collections
.defaultdict(int)
22 with
open('count_3l.txt', 'r') as f
:
24 (trigram
, count
) = line
.split("\t")
25 english_trigram_counts
[trigram
] = int(count
)
26 normalised_english_trigram_counts
= norms
.normalise(english_trigram_counts
)
29 # choices, weights = zip(*weighted_choices)
30 # cumdist = list(itertools.accumulate(weights))
31 # x = random.random() * cumdist[-1]
32 # choices[bisect.bisect(cumdist, x)]