-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacorn-utils.hpp
194 lines (177 loc) · 7.73 KB
/
acorn-utils.hpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#ifndef ACORN_UTILS_H_
#define ACORN_UTILS_H_
#include <string>
#include <map>
#include "synset-pointers.hpp"
// parse lexicographer file index and return equivalent file name
auto parseLexFilename = [] (int *lexFilenum) -> std::string {
switch (*lexFilenum) {
case 0: return "adj.all"; case 1: return "adj.pert"; case 2: return "adv.all"; case 3: return "noun.Tops";
case 4: return "noun.act"; case 5: return "noun.animal"; case 6: return "noun.artifact"; case 7: return "noun.attribute";
case 8: return "noun.body"; case 9: return "noun.cognition"; case 10: return "noun.communication"; case 11: return "noun.event";
case 12: return "noun.feeling"; case 13: return "noun.food"; case 14: return "noun.group"; case 15: return "noun.location";
case 16: return "noun.motive"; case 17: return "noun.object"; case 18: return "noun.person"; case 19: return "noun.phenomenon";
case 20: return "noun.plant"; case 21: return "noun.possession"; case 22: return "noun.process"; case 23: return "noun.quantity";
case 24: return "noun.relation"; case 25: return "noun.shape"; case 26: return "noun.state"; case 27: return "noun.substance";
case 28: return "noun.time"; case 29: return "verb.body"; case 30: return "verb.change"; case 31: return "verb.cognition";
case 32: return "verb.communication"; case 33: return "verb.competition"; case 34: return "verb.consumption"; case 35: return "verb.contact";
case 36: return "verb.creation"; case 37: return "verb.emotion"; case 38: return "verb.motion"; case 39: return "verb.perception";
case 40: return "verb.possession"; case 41: return "verb.social"; case 42: return "verb.stative"; case 43: return "verb.weather";
case 44: return "adj.ppl";
}
};
// parse synset type character and return complete string equivalent
auto parseSynsetTypeExpanded = [] (char *synsetType) {
switch (*synsetType) {
case 'n': return "noun";
case 'v': return "verb";
case 'a': return "adjective";
case 'r': return "adverb";
case 's': return "adjective satellite";
}
};
// index file character and complete file name equivalent
std::map<char, std::string> indexPosFileNameFromChar = {
{'n', "index.noun"},
{'v', "index.verb"},
{'a', "index.adj"},
{'r', "index.adv"}
};
// exception file character and complete file name equivalent
std::map<char, std::string> excPosFileNameFromChar = {
{'n', "noun.exc"},
{'v', "noun.exc"},
{'a', "adj.exc"},
{'r', "adv.exc"}
};
// pointer pos and data.pos file name map
std::map<char, std::string> dataPosFileNameFromChar = {
{'n', "data.noun"},
{'v', "data.verb"},
{'a', "data.adj"},
{'r', "data.adv"},
{'s', "data.adj"}
};
// noun pointer disambiguation map
std::map<std::string, std::string> nounPointerDisambiguation = {
{"!", "Antonym"},
{"@", "Hypernym"},
{"@i", "Instance Hypernym"},
{"~", "Hyponym"},
{"~i", "Instance Hyponym"},
{"#m", "Member holonym"},
{"#s", "Substance holonym"},
{"#p", "Part holonym"},
{"%m", "Member meronym"},
{"%s", "Substance meronym"},
{"%p", "Part meronym"},
{"=", "Attribute"},
{"+", "Derivationally related form"},
{";c", "Domain of synset - TOPIC"},
{"-c", "Member of this domain - TOPIC"},
{";r", "Domain of synset - REGION"},
{"-r", "Member of this domain - REGION"},
{";u", "Domain of synset - USAGE"},
{"-u", "Member of this domain - USAGE"}
};
// noun pointer element index map
std::map<int, std::string> nounPointerElemDisambiguationIndex = {
{ 0, "Antonym"},
{ 1, "Hypernym"},
{ 2, "Instance Hypernym"},
{ 3, "Hyponym"},
{ 4, "Instance Hyponym"},
{ 5, "Member holonym"},
{ 6, "Substance holonym"},
{ 7, "Part holonym"},
{ 8, "Member meronym"},
{ 9, "Substance meronym"},
{10, "Part meronym"},
{11, "Attribute"},
{12, "Derivationally related form"},
{13, "Domain of synset - TOPIC"},
{14, "Member of this domain - TOPIC"},
{15, "Domain of synset - REGION"},
{16, "Member of this domain - REGION"},
{17, "Domain of synset - USAGE"},
{18, "Member of this domain - USAGE"}
};
// verb pointer disambiguation map
std::map<std::string, std::string> verbPointerDisambiguation = {
{"!", "Antonym"},
{"@", "Hypernym"},
{"~", "Hyponym"},
{"*", "Entailment"},
{">", "Cause"},
{"^", "Also see"},
{"$", "Verb Group"},
{"+", "Derivationally related form"},
{";c", "Domain of synset - TOPIC"},
{";r", "Domain of synset - REGION"},
{";u", "Domain of synset - USAGE"}
};
// verb pointer element index map
std::map<int, std::string> verbPointerElemDisambiguationIndex = {
{ 0, "Antonym"},
{ 1, "Hypernym"},
{ 2, "Hyponym"},
{ 3, "Entailment"},
{ 4, "Cause"},
{ 5, "Also see"},
{ 6, "Verb Group"},
{ 7, "Derivationally related form"},
{ 8, "Domain of synset - TOPIC"},
{ 9, "Domain of synset - REGION"},
{10, "Domain of synset - USAGE"}
};
// adjective pointer disambiguation map
std::map<std::string, std::string> adjectivePointerDisambiguation = {
{"!", "Antonym"},
{"&", "Similar to"},
{"<", "Participle of verb"},
{"\\", "Pertainym (pertains to noun)"},
{"=", "Attribute"},
{"^", "Also see"},
{";c", "Domain of synset - TOPIC"},
{";r", "Domain of synset - REGION"},
{";u", "Domain of synset - USAGE"}
};
// adjective pointer element index map
std::map<int, std::string> adjectivePointerElemDisambiguationIndex = {
{0, "Antonym"},
{1, "Similar to"},
{2, "Participle of verb"},
{3, "Pertainym (pertains to noun)"},
{4, "Attribute"},
{5, "Also see"},
{6, "Domain of synset - TOPIC"},
{7, "Domain of synset - REGION"},
{8, "Domain of synset - USAGE"}
};
// adverb pointer disambiguation map
std::map<std::string, std::string> adverbPointerDisambiguation = {
{"!", "Antonym"},
{"\\", "Derived from adjective"},
{";c", "Domain of synset - TOPIC"},
{";r", "Domain of synset - REGION"},
{";u", "Domain of synset - USAGE"},
};
// adverb pointer element index map
std::map<int, std::string> adverbPointerElemDisambiguationIndex = {
{0, "Antonym"},
{1, "Derived from adjective"},
{2, "Domain of synset - TOPIC"},
{3, "Domain of synset - REGION"},
{4, "Domain of synset - USAGE"},
};
// parse pointer_symbols and return disambiguated pointer type
auto parsePointerSymbol = [] (std::string pointerSymbol, std::string pos) {
switch (pos[0]) {
case 'n': return nounPointerDisambiguation[pointerSymbol];
case 'v': return verbPointerDisambiguation[pointerSymbol];
case 'a': return adjectivePointerDisambiguation[pointerSymbol];
case 'r': return adverbPointerDisambiguation[pointerSymbol];
case 's': return adjectivePointerDisambiguation[pointerSymbol];
}
};
#endif /* ACORN_UTILS_H_ */