Natural Language Processing  0.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
parser.h
1 #ifndef PARSER_H
2 #define PARSER_H
3 #include <iostream>
4 #include "syntaxtree.h"
5 using namespace NLP;
6 
10 typedef std::vector<SyntaxTree> STvector;
11 
15 typedef std::vector<Word> Wvector;
16 
20 typedef std::set<WordType> WTset;
21 
27 class Parser{
28 private:
29 
33  STvector _valid;
34 
38  Grammar _G;
39 
43  Wvector _words;
44 
45  bool recDescent(SyntaxTree& S, size_t &c);
46  bool findFirstIncomplete(SyntaxTree &S);
47  void removePartial(SyntaxTree& S);
48 
49 
50  TNpair *removePartial(TNpair* root, TNpair* target, bool &found);
51 
52  Word getNextWord(std::size_t i);
53  GPlist getNextDef(GrammarPhrase g, GPlist def);
54  WordType getNextType(const Word& W, WordType T);
55 
56  void attachWords(SyntaxTree& S);
57  void assignHeadWords(SyntaxTree& S);
58  void assignObjects(SyntaxTree& S);
59  void assignType(SyntaxTree& S);
60 
61  void removeAllOtherTypes(Word& W, WordType trueType);
62  void removeTrees();
63 
64 public:
65  Parser();
66  Parser(const Grammar& G, const Wvector& words);
67 
68  void setGrammar(const Grammar& G);
69  void setSentence(const Wvector& W);
70  Grammar getGrammar();
71  Wvector getSentence();
72  STvector getTrees();
73 
74  STvector parse();
75 
76  std::vector<SyntaxWord> getAll(const SyntaxTree& S);
77  std::vector<SyntaxWord> getObj(const SyntaxTree& S, SyntaxObject O);
78 };
79 
80 #endif // PARSER_H
SyntaxObject
Definition: config.h:167
Definition: word.h:21
The Grammar class A generic Grammar class that contains a multimap. It maps a Grammar Phrase to a vec...
Definition: grammar.h:24
std::vector< GrammarPhrase > GPlist
GPlist typedef for vector<GrammarPhrase>
Definition: config.h:265
GrammarPhrase
The GrammarPhrase enum Denotes the Grammar Phrase.
Definition: config.h:99
The SyntaxTree class The Tree specialized for holding syntax and words INHERITS: from Tree...
Definition: syntaxtree.h:68
The Parser class The Parser class. It takes a Grammar Structure and a vector of Words to create a vec...
Definition: parser.h:27