Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Parser.H

Go to the documentation of this file.
00001 
00002 
00006 #ifndef _Parser_H_
00007 #define _Parser_H_
00008 
00009 #include "MazMemPool.H"
00010 #include "Timer.H"
00011 #include "ParseStats.H"
00012 
00013 #include "Grammar.H"
00014 #include "Logic.H"
00015 
00016 class Logic;
00017 class Agenda;
00018 
00019 using namespace std;
00020 
00022 class Parser : public Dbug {
00023 
00024 public:
00025 
00026   enum SearchStrategy {BottomUp, BestFirst};
00027 
00028   // Constructor with a config file.
00029   Parser(const string& configFile, Grammar* pGrammar = NULL);
00030 
00031   // the grammar is not deleted. You need to delete the 
00032   // grammar outside Parser.
00033   virtual ~Parser();
00034 
00036   virtual vector<pair<BilexMTree*, SCORE> > getParse(SentenceTuple&);
00039   virtual vector<pair<BilexMTree*, SCORE> > getParse();
00040 
00042   // This is useful in cases where some parent process needs info
00043   // about some subparses, but not necessarily the whole tree.
00044   // \return bool whether the goal has been reached
00045   virtual bool silentParse(SentenceTuple&);
00046 
00047 //   /// Exports the parsing statistics.
00048 //   virtual ParseStats getStats() const;
00049 
00053   virtual void clear();
00054 
00056   // configure the parser.
00058 
00060   virtual void setGrammar(Grammar* pGrammar);
00061   virtual Grammar* getGrammar() const;
00062 
00063  protected: // methods
00064 
00065   // no default constructor from outside
00066   Parser()  {}
00067 
00069   virtual void initialize(SentenceTuple&);
00070 
00075   virtual bool onePassParse();
00076 
00083   /* multiPassParse is a backoff technique that is used when parser fails
00084      to find a parse tree with sufficiently high probability within a
00085      sufficiently short time period.  It involves making use of
00086      partial parses for the sentence tuple and backing off to a
00087      simpler smoothing model.
00088   */
00089   virtual bool multiPassParse();
00090 
00091  private:
00092 
00094   void parse()
00095   {
00096     cerr << "Please use either getParse() or silentParse() to avoid confusion." << endl;
00097     exit(1);
00098   }
00099   
00100  protected:  // components
00101 
00103   Logic* m_pLogic;
00104 
00106   Agenda* m_pAgenda;
00107 
00109   Grammar* m_pGrammar;
00110 
00111   // diagnostic info
00112   ParseStats m_parseStats;
00113 
00114  protected:  // configuration variables
00115 
00117   bool m_multiPassParse;
00118 
00119 };
00120 
00121 #endif

Generated on Thu Jul 7 23:19:01 2005 for Generalized Parsers (GenPar) by  doxygen 1.4.1