Natural Language Processing  0.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
config.h
1 #pragma once
2 
3 #include <map>
4 #include <QtSql>
5 
6 using namespace std;
7 
8 namespace NLP
9 {
10 
13  const QString DB_PATH = "../../en_db.sqlite";
14  const QString ONT_PATH= "../../Granular-Extractor/ont_db.sqlite";
15 
16  // word tag? there are more, see .dat for list of them
17  enum WordType {
18  others = 0,
19  adjective , adverb , conjunction , dative ,
20  noun , interjections , imperfect ,
21  particple , preposition , pronoun , plural , singular ,
22  verb , transitive , intransitive , interrogative , object ,
23  determiner , question , auxiliary , negation ,
24 
25  IGNORETHIS
26  };
27 
28  static map<string, WordType> WordTypeMap = {
29  {"a." , adjective } ,
30  {"adv." , adverb } ,
31  {"conj." , conjunction } ,
32  {"n." , noun } ,
33  {"interj." , interjections } ,
34  {"imp." , imperfect } ,
35  {"p." , particple } ,
36  {"prep." , preposition } ,
37  {"dat." , dative } ,
38  {"interrog." , interrogative } , //Need to change the Wh words into interoggs
39 
40  {"pr." , pronoun } ,
41  {"pron." , pronoun } ,
42  {"obj." , pronoun } ,
43 
44 
45  {"pl." , plural } ,
46  {"sing." , singular } ,
47  {"v." , verb } ,
48  {"aux." , auxiliary } ,
49  {"neg." , negation } ,
50 
51 
52  {"object." , pronoun } , //previously mapped to object
53  {"t." , transitive } ,
54  {"i." , intransitive } ,
55 
56  {"det." , determiner } ,
57  {"q." , question } ,
58 
59  {"?" , others } ,
60 
62  {"&" , IGNORETHIS } ,
63  {"/" , IGNORETHIS }
64  };
65 
66  static map<WordType, string> WordStringMap = {
67  {others , "?." } ,
68  {adjective , "a." } ,
69  {adverb , "adv." } ,
70  {conjunction , "conj." } ,
71  {noun , "n." } ,
72  {interjections , "interj." } ,
73  {imperfect , "imp." } ,
74  {particple , "p." } ,
75  {preposition , "prep." } ,
76  {plural , "pl." } ,
77  {singular , "sing." } ,
78  {pronoun , "pron." } ,
79  {verb , "v." } ,
80  {object , "object." } ,
81  {transitive , "t." } ,
82  {intransitive , "i." } ,
83  {dative , "dat." } ,
84  {interrogative , "interrog." } ,
85  {determiner , "det." } ,
86  {question , "q." } ,
87  {auxiliary , "aux." } ,
88  {negation , "neg." } ,
89 
90  {IGNORETHIS , "IGNORE" }
91  };
92 
93 //thereexists eWalks(e)^xWalker(e,He)^yWalkTo(e,car)
94 //From here on is from JOSEPH:
95  //GrammarPhrase:
100  G_INVALID = 0,
101  ALL = 1,
102  SENTENCE = 2,
103  NOUNPHRASE = 3,
104  VERBPHRASE = 4,
105  PREPPHRASE = 5,
106  NOMINAL = 6,
107  NOUN = 7,
108  VERB = 8,
109  PREP = 9,
110  DETERMINER = 10,
111 
112  INTPHRASE,
113  WHPHRASE,
114  WHWORD,
115  AUXILARY,
116  ADJECTIVE,
117  NEGATION,
118  ADJPHRASE
119  };
123  static const GrammarPhrase gpList[] ={
124  G_INVALID ,
125  ALL ,
126  SENTENCE ,
127  NOUNPHRASE ,
128  VERBPHRASE ,
129  PREPPHRASE ,
130  NOMINAL ,
131  NOUN ,
132  VERB ,
133  PREP ,
134  DETERMINER ,
135  INTPHRASE ,
136  WHPHRASE ,
137  WHWORD ,
138  AUXILARY,
139  ADJPHRASE
140  };
141 
145  static std::map<GrammarPhrase,std::string> phraseLookUp = {
146  { G_INVALID, "Invalid" },
147  { ALL, "All" },
148  { SENTENCE, "Sentence" },
149  { NOUNPHRASE, "Noun Phrase" },
150  { VERBPHRASE, "Verb Phrase" },
151  { PREPPHRASE, "Prep. Phrase" },
152  { NOMINAL, "Nominal" },
153  { NOUN, "Noun" },
154  { VERB, "Verb" },
155  { PREP, "Preposition" },
156  { DETERMINER, "Determiner" },
157  { INTPHRASE , "Inter. Phrase" },
158  { WHPHRASE, "Wh. Phrase" },
159  { WHWORD, "Wh. Word" },
160  { AUXILARY, "Auxilary" },
161  { ADJECTIVE, "Adjective" },
162  { NEGATION, "Negation" },
163  {ADJPHRASE,"Adj. Phrase"}
164 
165  };
166 
168  S_INVALID ,
169  S_NONE ,
170  SUBJECT ,
171  MAINVERB ,
172  DIRECTOBJ ,
174  AUX ,
175  QWORD ,
177  };
178 
179  static std::map<SyntaxObject, std::string> syntaxStrEncoding = {
180  { S_INVALID, "i" },
181  { S_NONE, "n" },
182  { SUBJECT, "s" },
183  { MAINVERB, "v" },
184  { DIRECTOBJ, "o" },
185  { INDIRECTOBJ, "io" },
186  { AUX, "aux" },
187  { ATTRIBUTE, "att" },
188  { QWORD, "q" }
189  };
190 
191  static std::map<SyntaxObject,std::string> syntaxLookUp = {
192  { S_INVALID, "Invalid" },
193  { S_NONE, "None" },
194  { SUBJECT, "Subject" },
195  { MAINVERB, "Main Verb" },
196  { DIRECTOBJ, "Direct Object" },
197  { INDIRECTOBJ, "Indirect Object" },
198  { AUX, "Auxilary Verb" },
199  { QWORD, "Question Word" },
200  { ATTRIBUTE, "Atrribute" }
201  };
202 
206  static std::map<SyntaxObject,std::string> syntaxDBLookUp = {
207  { S_INVALID, "invalid" },
208  { S_NONE, "none" },
209  { SUBJECT, "sub" },
210  { MAINVERB, "pred" },
211  { DIRECTOBJ, "obj" },
212  { INDIRECTOBJ, "indirect" },
213  { AUX, "*" }, // * why star? yes no question
214  { ATTRIBUTE , "attribute" },
215  { QWORD, "question" }
216  };
217  static const SyntaxObject soList[] = {
218  S_INVALID ,
219  S_NONE ,
220  SUBJECT ,
221  MAINVERB ,
222  DIRECTOBJ ,
223  INDIRECTOBJ ,
224  AUX ,
225  QWORD ,
226  ATTRIBUTE
227  };
228 
229  static const GrammarPhrase posList[] = {
230  NOUN ,
231  VERB ,
232  DETERMINER ,
233  PREP ,
234  WHWORD ,
235  AUXILARY
236  };
237 
238  enum SentenceType{
239  ST_INVALID,
240  DECLARATIVE,
241  IMPERATIVE,
242  INTERROGATIVE
243 // QUESTION
244  };
245 
246  static const SentenceType sentenceList[] = {
247  ST_INVALID ,
248  DECLARATIVE ,
249  IMPERATIVE ,
250  INTERROGATIVE
251  };
252 
253  static std::map<SentenceType,std::string> sentenceLookUp = {
254  {ST_INVALID, "Invalid" },
255  {DECLARATIVE, "Declarative"},
256  {IMPERATIVE, "Imperative" },
257  {INTERROGATIVE, "Interrogative"}
258  };
259 
260 // std::string
261  //Typedefs:
265  typedef std::vector<GrammarPhrase> GPlist;
269  typedef std::multimap<GrammarPhrase,GPlist> mmap;
273  typedef std::pair<GrammarPhrase,GPlist> GPpair;
274 
275 
276 
277 
278  //Initializer List for Reduced Context Free Grammar of Order Zero
282  static const GPpair cfgzInit[] = {
283  GPpair(SENTENCE,{NOUNPHRASE,VERBPHRASE}),
284  GPpair(NOUNPHRASE,{NOUN}),
285  GPpair(NOUNPHRASE,{DETERMINER,NOUN}),
286  GPpair(VERBPHRASE,{VERB}),
287  GPpair(VERBPHRASE,{VERB,NOUNPHRASE}),
288  GPpair(VERBPHRASE,{VERB,NOUNPHRASE,PREPPHRASE}),
289  GPpair(VERBPHRASE,{VERB,PREPPHRASE}),
290  GPpair(PREPPHRASE,{PREP,NOUNPHRASE})
291  };
292 
293  static const GPpair cfgqInit[] = {
294  GPpair(SENTENCE,{INTPHRASE,NOUNPHRASE,VERBPHRASE}),
295 // GPpair(SENTENCE,{INTPHRASE,NOUNPHRASE,PREPPHRASE}),
296 // GPpair(SENTENCE,{INTPHRASE,NOUNPHRASE,ADJPHRASE}),
297  GPpair(SENTENCE,{INTPHRASE,VERBPHRASE}),
298  GPpair(SENTENCE,{INTPHRASE,NOUNPHRASE}),
299  GPpair(SENTENCE,{NOUNPHRASE,VERBPHRASE}),
300 // GPpair(SENTENCE,{NOUNPHRASE,AUXILARY,ADJECTIVE}),
301 // GPpair(SENTENCE,{NOUNPHRASE,AUXILARY,NEGATION,ADJECTIVE}),
302  GPpair(NOUNPHRASE,{DETERMINER,NOUN}),
303  GPpair(NOUNPHRASE,{NOUN}),
304  GPpair(VERBPHRASE,{VERB,NOUNPHRASE,PREPPHRASE}),
305  GPpair(VERBPHRASE,{VERB,NOUNPHRASE}),
306  GPpair(VERBPHRASE,{VERB,PREPPHRASE}),
307  GPpair(VERBPHRASE,{VERB}),
308 // GPpair(VERBPHRASE,{AUXILARY,ADJPHRASE}),
309  GPpair(PREPPHRASE,{PREP,NOUNPHRASE}),
310  GPpair(PREPPHRASE,{PREP}),
311  GPpair(INTPHRASE,{WHPHRASE,AUXILARY}),
312  GPpair(INTPHRASE,{AUXILARY}),
313  GPpair(INTPHRASE,{WHPHRASE}),
314  GPpair(WHPHRASE,{WHWORD}),
315 // GPpair(ADJPHRASE,{NEGATION,ADJECTIVE,NOUNPHRASE}),
316 // GPpair(ADJPHRASE,{ADJECTIVE,NOUNPHRASE}),
317 // GPpair(ADJPHRASE,{NEGATION,NOUNPHRASE}),
318 // GPpair(ADJPHRASE,{ADJECTIVE})
319 // GPpair(AUXILARY,{VERB})
320  };
321 // others = 0,
322 // adjective , adverb , conjunction , dative,
323 // , interjections , imperative ,
324 // particple , preposition , pronoun , plural , singular,
325 // , transitive, intransitive, interrogative, object,
326 
327 // IGNORETHIS
328 
329  static std::map<WordType,GrammarPhrase> WTtoGP = {
330  {noun,NOUN},
331  {verb,VERB},
332  {preposition,PREP},
333  {determiner,DETERMINER},
334  {pronoun,NOUN},
335  {question,WHWORD},
336  {auxiliary,AUXILARY},
337  {particple,VERB},
338  {imperfect,VERB},
339 // {adjective,ADJECTIVE}
340  {adjective,NOUN}
341  };
342 
343  static std::map<GrammarPhrase,WordType> GPtoWT = {
344  {NOUN,noun},
345  {VERB,verb},
346  {PREP,preposition},
347  {DETERMINER,determiner},
348  {WHWORD,question},
349  {AUXILARY,auxiliary},
350 // {ADJECTIVE,adjective}
351 // {pronoun,NOUN}
352  };
353 
354 
355 
356 
357 } /* NLP */
std::pair< GrammarPhrase, GPlist > GPpair
GPpair typedef for pair<GrammarPhrase, vector<GrammarPhrase> >
Definition: config.h:273
SyntaxObject
Definition: config.h:167
const QString DB_PATH
Relative path of where Dictionary database is Note : Path is relative to where "build" folder is gene...
Definition: config.h:13
this stores information such as adjective, noun describing objects ,etc
Definition: config.h:176
std::multimap< GrammarPhrase, GPlist > mmap
mmap typedef for multimpa<GrammarPhrase, vector<GrammarPhrase> >
Definition: config.h:269
He kicks the ball to "him".
Definition: config.h:174
std::vector< GrammarPhrase > GPlist
GPlist typedef for vector<GrammarPhrase>
Definition: config.h:265
He eats "apple".
Definition: config.h:173
GrammarPhrase
The GrammarPhrase enum Denotes the Grammar Phrase.
Definition: config.h:99