00001 #pragma once
00002
00003 #include <stdexcept>
00004 #include <boost/unordered_set.hpp>
00005
00006 #include "StatelessFeatureFunction.h"
00007 #include "moses/Factor.h"
00008 #include "moses/Sentence.h"
00009
00010 namespace Moses
00011 {
00012
00016 class PhrasePairFeature: public StatelessFeatureFunction
00017 {
00018
00019 typedef std::map< char, short > CharHash;
00020 typedef std::vector< std::set<std::string> > DocumentVector;
00021
00022 boost::unordered_set<std::string> m_vocabSource;
00023 DocumentVector m_vocabDomain;
00024 FactorType m_sourceFactorId;
00025 FactorType m_targetFactorId;
00026 bool m_unrestricted;
00027 bool m_simple;
00028 bool m_sourceContext;
00029 bool m_domainTrigger;
00030 bool m_ignorePunctuation;
00031 CharHash m_punctuationHash;
00032 std::string m_filePathSource;
00033
00034 inline std::string ReplaceTilde(const StringPiece &str) const {
00035 std::string out = str.as_string();
00036 size_t pos = out.find('~');
00037 while ( pos != std::string::npos ) {
00038 out.replace(pos,1,"<TILDE>");
00039 pos = out.find('~',pos);
00040 }
00041 return out;
00042 };
00043
00044 public:
00045 PhrasePairFeature(const std::string &line);
00046
00047 void Load(AllOptions::ptr const& opts);
00048 void SetParameter(const std::string& key, const std::string& value);
00049
00050 bool IsUseable(const FactorMask &mask) const;
00051
00052 void EvaluateInIsolation(const Phrase &source
00053 , const TargetPhrase &targetPhrase
00054 , ScoreComponentCollection &scoreBreakdown
00055 , ScoreComponentCollection &estimatedScores) const;
00056
00057 void EvaluateTranslationOptionListWithSourceContext(const InputType &input
00058 , const TranslationOptionList &translationOptionList) const {
00059 }
00060 void EvaluateWithSourceContext(const InputType &input
00061 , const InputPath &inputPath
00062 , const TargetPhrase &targetPhrase
00063 , const StackVec *stackVec
00064 , ScoreComponentCollection &scoreBreakdown
00065 , ScoreComponentCollection *estimatedScores = NULL) const;
00066
00067 void EvaluateWhenApplied(const Hypothesis& hypo,
00068 ScoreComponentCollection* accumulator) const {
00069 }
00070
00071 void EvaluateWhenApplied(const ChartHypothesis& hypo,
00072 ScoreComponentCollection*) const {
00073 }
00074
00075
00076 };
00077
00078 }
00079