00001 #pragma once
00002
00003 #include <string>
00004 #include "StatefulFeatureFunction.h"
00005 #include "FFState.h"
00006
00007 namespace Moses
00008 {
00009
00010 class ExampleState : public FFState
00011 {
00012 int m_targetLen;
00013 public:
00014 ExampleState(int targetLen)
00015 :m_targetLen(targetLen) {
00016 }
00017
00018 virtual size_t hash() const {
00019 return (size_t) m_targetLen;
00020 }
00021 virtual bool operator==(const FFState& o) const {
00022 const ExampleState& other = static_cast<const ExampleState&>(o);
00023 return m_targetLen == other.m_targetLen;
00024 }
00025
00026 };
00027
00028 class ExampleStatefulFF : public StatefulFeatureFunction
00029 {
00030 public:
00031 ExampleStatefulFF(const std::string &line);
00032
00033 bool IsUseable(const FactorMask &mask) const {
00034 return true;
00035 }
00036 virtual const FFState* EmptyHypothesisState(const InputType &input) const {
00037 return new ExampleState(0);
00038 }
00039
00040
00041
00042
00043
00044 void
00045 EvaluateInIsolation(const Phrase &source
00046 , const TargetPhrase &targetPhrase
00047 , ScoreComponentCollection &scoreBreakdown
00048 , ScoreComponentCollection &estimatedScores) const;
00049
00050
00051
00052
00053
00054 void
00055 EvaluateWithSourceContext(const InputType &input
00056 , const InputPath &inputPath
00057 , const TargetPhrase &targetPhrase
00058 , const StackVec *stackVec
00059 , ScoreComponentCollection &scoreBreakdown
00060 , ScoreComponentCollection *estimatedScores = NULL) const;
00061
00062
00063
00064
00065
00066 void
00067 EvaluateTranslationOptionListWithSourceContext
00068 ( const InputType &input , const TranslationOptionList &translationOptionList) const;
00069
00070 FFState* EvaluateWhenApplied(
00071 const Hypothesis& cur_hypo,
00072 const FFState* prev_state,
00073 ScoreComponentCollection* accumulator) const;
00074 FFState* EvaluateWhenApplied(
00075 const ChartHypothesis& ,
00076 int ,
00077 ScoreComponentCollection* accumulator) const;
00078
00079 void SetParameter(const std::string& key, const std::string& value);
00080
00081 };
00082
00083
00084 }
00085