-
Notifications
You must be signed in to change notification settings - Fork 0
/
word_data.py
32 lines (26 loc) · 1.12 KB
/
word_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from word_count import build_word_count_from_corpus
from word_count import word_list_to_fragment_lookup
from params import parameters
from fileio import read_ciphered_text
from word_count import process_word
def get_word_data():
"""
:return: dictionary that has word_count and fragment lookup
"""
word_count = build_word_count_from_corpus()
frequency_min = parameters['min_frequency_word_to_fragment']
word_count_smaller = {word: count for word, count in word_count.iteritems()
if count >= frequency_min}
fragment_lookup = word_list_to_fragment_lookup(word_count_smaller.keys())
word_data = {'word_count': word_count, 'fragment_lookup': fragment_lookup}
return word_data
def get_input_data():
"""
:return: dictionary that has the cypher text and some items calculated from it
that are needed various places
"""
ciphered_text = read_ciphered_text()
ciphered_words = [process_word(word) for word in ciphered_text.split()]
input_data = {'ciphered_text': ciphered_text,
'ciphered_words': ciphered_words}
return input_data