CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / EarleyParser.h
blobf544db885aeda3112a1e493094ca4f3166d9f2e0
1 // Earley parser
2 // Copyright © 2009 The University of Chicago
3 #ifndef EARLEYPARSER_H
4 #define EARLEYPARSER_H
6 class CEarleyParser;
8 #include <QMap>
9 template<class T> class Q3PtrList;
11 class CEarleyParser {
12 protected:
13 QMap<unsigned int, Q3PtrList<class CEdge> > m_states;
14 QMap<class QString, Q3PtrList<class CGrammarRule> >* m_grammar;
15 class CParse* m_word;
16 QMap<QString, class CTerminalRuleCollection*>* m_lexicon;
17 /// Length of shortest non-wild-card terminal
18 int m_shortest;
20 Q3PtrList<class CEdge>* m_Roots;
21 int m_CurrentLocation;
22 unsigned int m_NumberOfStates;
24 class QTextStream* m_logFile;
26 QMap<class QString, int> m_minimumLengths;
27 bool m_validGrammarFlag;
28 int m_maximumParseDepth;
29 public:
30 // construction/destruction.
31 CEarleyParser(CParse* word,
32 QMap<QString, Q3PtrList<CGrammarRule> >* grammar,
33 QMap<QString, CTerminalRuleCollection*>* lexicon,
34 QTextStream* log = 0,
35 int maximumParseDepth = 5);
36 virtual ~CEarleyParser();
38 // the main event.
39 Q3PtrList<CEdge>* Parse();
41 bool Prediction(CEdge* edge);
42 bool Scanning(CEdge* edge);
43 bool Completion(CEdge* edge);
44 bool isValidGrammar() { return m_validGrammarFlag; }
45 void setMaximumParseDepth(int d) { m_maximumParseDepth = d; }
46 int getMaximumParseDepth() const { return m_maximumParseDepth; }
49 #endif // EARLEYPARSER_H