-
Notifications
You must be signed in to change notification settings - Fork 0
/
vocabulary.py
33 lines (26 loc) · 953 Bytes
/
vocabulary.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
33
import grammar
import rules
class Vocabulary:
'''
Class that centralizes the known words of different lexical
categories.
'''
def __init__(self, pwd):
'''
Attribute:
- self.data: dict of dicts; for each lexical category, maps
each word's index to the instance of the word.
'''
self.rules = {}
rules.init(self.rules)
self.data = {}
for category in grammar.EXTRA_LIST:
self.data[category] = {}
grammar.init(category, self.data[category], self.rules, pwd)
# Associates contractions to corresponding prepositions
for contraction in self.data['contraction'].values():
preposition = self.data['preposition'][contraction.preposition]
preposition.set_contraction(
(contraction.next, contraction.category),
self.data['contraction'][contraction.index]
)