00001 #pragma once
00002
00003 #include <string>
00004 #include <vector>
00005 #include <set>
00006 #include <iostream>
00007 #include "StatefulFeatureFunction.h"
00008 #include "FFState.h"
00009 #include "util/exception.hh"
00010 #include <stdint.h>
00011
00012 namespace Moses
00013 {
00014
00015 class TargetConstituentAdjacencyFeatureState : public FFState
00016 {
00017
00018 public:
00019
00020 friend class TargetConstituentAdjacencyFeature;
00021
00022 TargetConstituentAdjacencyFeatureState(bool recombine)
00023 : m_recombine(recombine)
00024 {};
00025
00026 size_t hash() const;
00027
00028 virtual bool operator==(const FFState& other) const;
00029
00030 private:
00031
00032 const bool m_recombine;
00033 std::map<const Factor*, float> m_collection;
00034
00035 };
00036
00037
00038 class TargetConstituentAdjacencyFeature : public StatefulFeatureFunction
00039 {
00040
00041 public:
00042
00043 TargetConstituentAdjacencyFeature(const std::string &line);
00044
00045 ~TargetConstituentAdjacencyFeature()
00046 {};
00047
00048 bool IsUseable(const FactorMask &mask) const {
00049 return true;
00050 };
00051
00052 virtual const FFState* EmptyHypothesisState(const InputType &input) const {
00053 return new TargetConstituentAdjacencyFeatureState(m_recombine);
00054 };
00055
00056 void SetParameter(const std::string& key, const std::string& value);
00057
00058 void Load(AllOptions::ptr const& opts)
00059 {};
00060
00061 void EvaluateInIsolation(const Phrase &source
00062 , const TargetPhrase &targetPhrase
00063 , ScoreComponentCollection &scoreBreakdown
00064 , ScoreComponentCollection &estimatedFutureScore) const
00065 {};
00066
00067 void EvaluateWithSourceContext(const InputType &input
00068 , const InputPath &inputPath
00069 , const TargetPhrase &targetPhrase
00070 , const StackVec *stackVec
00071 , ScoreComponentCollection &scoreBreakdown
00072 , ScoreComponentCollection *estimatedFutureScore = NULL) const
00073 {};
00074
00075 void EvaluateTranslationOptionListWithSourceContext(const InputType &input
00076 , const TranslationOptionList &translationOptionList) const
00077 {};
00078
00079 FFState* EvaluateWhenApplied(
00080 const Hypothesis& cur_hypo,
00081 const FFState* prev_state,
00082 ScoreComponentCollection* accumulator) const;
00083
00084 FFState* EvaluateWhenApplied(
00085 const ChartHypothesis& cur_hypo,
00086 int featureID,
00087 ScoreComponentCollection* accumulator) const {
00088 UTIL_THROW2(GetScoreProducerDescription() << ": feature currently not implemented for chart-based decoding.");
00089 return new TargetConstituentAdjacencyFeatureState(m_recombine);
00090 };
00091
00092
00093 private:
00094
00095 size_t m_featureVariant;
00096 bool m_recombine;
00097
00098 };
00099
00100 }
00101