-
Notifications
You must be signed in to change notification settings - Fork 1
/
loadconfig.py
66 lines (55 loc) · 1.5 KB
/
loadconfig.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import yaml
path = './comet-commonsense/config/config.yaml'
def loadConfigForROV():
with open(path) as f:
docs = yaml.load_all(f, Loader=yaml.FullLoader)
for doc in docs:
for k, v in doc.items():
if k=="exception_vadarneg_words":
exception_vadarneg_words=v
elif k=="missing_vadarneg_words":
missing_vadarneg_words=v
return exception_vadarneg_words,missing_vadarneg_words
def loadConfigForRank():
with open(path) as f:
docs = yaml.load_all(f, Loader=yaml.FullLoader)
for doc in docs:
for k, v in doc.items():
if k=="swap":
swap_words=v
return swap_words
def loadConfigForSentences():
with open(path) as f:
docs = yaml.load_all(f, Loader=yaml.FullLoader)
for doc in docs:
for k, v in doc.items():
if k=="nonoverlap":
nonoverlap_words=v
return nonoverlap_words
def loadConfigForRetrieval():
with open(path) as f:
docs = yaml.load_all(f, Loader=yaml.FullLoader)
for doc in docs:
for k, v in doc.items():
if k=="stop_words":
stop_words = v[0].split(',')
if k=="missing":
missing = v
if k=="quantifier":
quantifier = v
if k=="replacement":
replacements = v
if k=="start":
start = v
if k=="wrongNE":
wrongNE = v
return stop_words,missing,quantifier,replacements,start,wrongNE
def loadConfig(step):
if step == 'ROV':
return loadConfigForROV()
elif step == 'Retrieve':
return loadConfigForRetrieval()
elif step == 'Sentences':
return loadConfigForSentences()
else:
return loadConfigForRank()