00001 #pragma once 00002 00003 #include <string> 00004 #include <map> 00005 #include <vector> 00006 #include "moses/FF/StatefulFeatureFunction.h" 00007 #include "moses/Manager.h" 00008 #include "moses/FF/Dsg-Feature/dsgHyp.h" 00009 #include "moses/FF/Dsg-Feature/Desegmenter.h" 00010 #include "KenDsg.h" 00011 00012 00013 namespace Moses 00014 { 00015 00016 class DesegModel : public StatefulFeatureFunction 00017 { 00018 public: 00019 00020 DsgLM * DSGM; 00021 Desegmenter* desegT; 00022 int tFactor;// Target Factor ... 00023 int order; 00024 int numFeatures; // Number of features used an be 1 (unsegmented LM)or 5 (with 3 contiguity features and 1 UnsegWP) 00025 bool optimistic; 00026 00027 DesegModel(const std::string &line); 00028 ~DesegModel(); 00029 00030 void readLanguageModel(const char *); 00031 void Load(AllOptions::ptr const& opts); 00032 00033 FFState* EvaluateWhenApplied( 00034 const Hypothesis& cur_hypo, 00035 const FFState* prev_state, 00036 ScoreComponentCollection* accumulator) const; 00037 00038 virtual FFState* EvaluateWhenApplied( 00039 const ChartHypothesis& /* cur_hypo */, 00040 int /* featureID - used to index the state in the previous hypotheses */, 00041 ScoreComponentCollection* accumulator) const; 00042 00043 void EvaluateInIsolation(const Phrase &source 00044 , const TargetPhrase &targetPhrase 00045 , ScoreComponentCollection &scoreBreakdown 00046 , ScoreComponentCollection &estimatedScores) const; 00047 00048 virtual const FFState* EmptyHypothesisState(const InputType &input) const; 00049 00050 virtual std::string GetScoreProducerWeightShortName(unsigned idx=0) const; 00051 00052 void SetParameter(const std::string& key, const std::string& value); 00053 00054 bool IsUseable(const FactorMask &mask) const; 00055 00056 protected: 00057 typedef std::vector<float> Scores; 00058 std::string m_lmPath; 00059 std::string m_desegPath; 00060 bool m_simple; //desegmentation scheme; if 1 then use simple, else use rule and backoff to simple 00061 }; 00062 00063 00064 }