00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef moses_LanguageModel_h
00024 #define moses_LanguageModel_h
00025
00026 #include <string>
00027 #include <cstddef>
00028
00029 #include "moses/FF/StatefulFeatureFunction.h"
00030
00031 namespace Moses
00032 {
00033
00034 namespace Incremental
00035 {
00036 class Manager;
00037 }
00038
00039 class FactorCollection;
00040 class Factor;
00041 class Phrase;
00042
00044 class LanguageModel : public StatefulFeatureFunction
00045 {
00046 protected:
00047 LanguageModel(const std::string &line);
00048
00049 bool m_enableOOVFeature;
00050
00051 public:
00052 static const LanguageModel &GetFirstLM();
00053
00054 virtual ~LanguageModel();
00055
00056 bool OOVFeatureEnabled() const {
00057 return m_enableOOVFeature;
00058 }
00059
00060 virtual void SetParameter(const std::string& key, const std::string& value);
00061
00062 virtual const FFState* EmptyHypothesisState(const InputType &input) const = 0;
00063
00064
00065
00066
00067
00068
00069
00070
00071 virtual void CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, std::size_t &oovCount) const = 0;
00072
00073 virtual void CalcScoreFromCache(const Phrase &phrase, float &fullScore, float &ngramScore, std::size_t &oovCount) const {
00074 }
00075
00076 virtual void IssueRequestsFor(Hypothesis& hypo,
00077 const FFState* input_state) {
00078 }
00079 virtual void sync() {
00080 }
00081 virtual void SetFFStateIdx(int state_idx) {
00082 }
00083
00084
00085 virtual void IncrementalCallback(Incremental::Manager &manager) const;
00086 virtual void ReportHistoryOrder(std::ostream &out,const Phrase &phrase) const;
00087
00088 virtual void EvaluateInIsolation(const Phrase &source
00089 , const TargetPhrase &targetPhrase
00090 , ScoreComponentCollection &scoreBreakdown
00091 , ScoreComponentCollection &estimatedScores) const;
00092
00093 };
00094
00095 }
00096
00097 #endif