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/OSM-Feature/osmHyp.h"
00009 #include "KenOSM.h"
00010
00011 namespace Moses
00012 {
00013
00014 class OpSequenceModel : public StatefulFeatureFunction
00015 {
00016 public:
00017
00018 OSMLM* OSM;
00019 float unkOpProb;
00020 int sFactor;
00021 int tFactor;
00022 int numFeatures;
00023 util::LoadMethod load_method;
00024
00025 OpSequenceModel(const std::string &line);
00026 ~OpSequenceModel();
00027
00028 void readLanguageModel(const char *);
00029 void Load(AllOptions::ptr const& opts);
00030
00031 FFState* EvaluateWhenApplied(
00032 const Hypothesis& cur_hypo,
00033 const FFState* prev_state,
00034 ScoreComponentCollection* accumulator) const;
00035
00036 virtual FFState* EvaluateWhenApplied(
00037 const ChartHypothesis& ,
00038 int ,
00039 ScoreComponentCollection* accumulator) const;
00040
00041 void EvaluateInIsolation(const Phrase &source
00042 , const TargetPhrase &targetPhrase
00043 , ScoreComponentCollection &scoreBreakdown
00044 , ScoreComponentCollection &estimatedScores) const;
00045
00046 virtual const FFState* EmptyHypothesisState(const InputType &input) const;
00047
00048 virtual std::string GetScoreProducerWeightShortName(unsigned idx=0) const;
00049
00050 std::vector<float> GetFutureScores(const Phrase &source, const Phrase &target) const;
00051 void SetParameter(const std::string& key, const std::string& value);
00052
00053 bool IsUseable(const FactorMask &mask) const;
00054
00055 protected:
00056 typedef std::pair<Phrase, Phrase> ParallelPhrase;
00057 typedef std::vector<float> Scores;
00058 std::map<ParallelPhrase, Scores> m_futureCost;
00059
00060 std::vector < std::pair < std::set <int> , std::set <int> > > ceptsInPhrase;
00061 std::set <int> targetNullWords;
00062 std::string m_lmPath;
00063
00064
00065 };
00066
00067
00068 }