-
Notifications
You must be signed in to change notification settings - Fork 1
/
lexicon.py
48 lines (38 loc) · 934 Bytes
/
lexicon.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Code for loading in the lexicon.
"""
import os.path
import yaml
from verbs import Verb
LEXICA_DIR = "lexica"
LEXICON = {}
LEXICON_FILES = [
"lexicon.yaml",
"lexicon0a.yaml",
"lexicon0b.yaml",
"lexicon0w.yaml",
"lexicon0x.yaml",
"lexicon1a.yaml",
"lexicon1b.yaml",
"lexicon1c.yaml",
"lexicon1x.yaml",
"lexicon2a.yaml",
"lexicon2b.yaml",
"lexicon2c.yaml",
"lexicon2x.yaml",
"lexicon3a.yaml",
"lexicon3x.yaml",
"lexicon4w.yaml",
"lexicon5w.yaml",
"lexicon6w.yaml",
"lexicon7w.yaml",
]
for lexicon_filename in LEXICON_FILES:
with open(os.path.join(LEXICA_DIR, lexicon_filename)) as f:
for lemma, lexeme in yaml.load(f).items():
LEXICON[lemma] = Verb(lexeme)
for lemma, verb in LEXICON.items():
if "inherit" in verb.lexeme:
verb.inherit = LEXICON.get(verb.lexeme["inherit"])
else:
verb.inherit = None