00001 // 00002 00003 #ifndef moses_SyntacticLanguageModel_h 00004 #define moses_SyntacticLanguageModel_h 00005 00006 #include "FeatureFunction.h" 00007 #include <stdexcept> 00008 00009 class YModel; // hidden model 00010 class XModel; // observed model 00011 00012 namespace Moses 00013 { 00014 00015 template <class MH, class MO> class SyntacticLanguageModelFiles; 00016 00017 class SyntacticLanguageModel : public StatefulFeatureFunction 00018 { 00019 00020 public: 00021 SyntacticLanguageModel(const std::string &line); 00022 00023 ~SyntacticLanguageModel(); 00024 00025 size_t GetNumScoreComponents() const; 00026 00027 const FFState* EmptyHypothesisState(const InputType &input) const; 00028 00029 FFState* Evaluate(const Hypothesis& cur_hypo, 00030 const FFState* prev_state, 00031 ScoreComponentCollection* accumulator) const; 00032 00033 FFState* EvaluateWhenApplied(const ChartHypothesis& cur_hypo, 00034 int featureID, 00035 ScoreComponentCollection* accumulator) const { 00036 throw std::runtime_error("Syntactic LM can only be used with phrase-based decoder."); 00037 } 00038 00039 00040 // double perplexity(); 00041 00042 private: 00043 00044 const size_t m_NumScoreComponents; 00045 SyntacticLanguageModelFiles<YModel,XModel>* m_files; 00046 const FactorType m_factorType; 00047 const size_t m_beamWidth; 00048 00049 }; 00050 00051 00052 } 00053 00054 #endif