00001 #pragma once
00002
00003 #include "moses/Word.h"
00004 #include "StatelessFeatureFunction.h"
00005
00006 #ifdef WITH_THREADS
00007 #include <boost/thread/shared_mutex.hpp>
00008 #endif
00009
00010 namespace Moses
00011 {
00012
00013 class SoftMatchingFeature : public StatelessFeatureFunction
00014 {
00015 public:
00016 SoftMatchingFeature(const std::string &line);
00017
00018 bool IsUseable(const FactorMask &mask) const {
00019 return true;
00020 }
00021
00022 virtual void EvaluateWhenApplied(const ChartHypothesis& hypo,
00023 ScoreComponentCollection* accumulator) const;
00024
00025 void EvaluateInIsolation(const Phrase &source
00026 , const TargetPhrase &targetPhrase
00027 , ScoreComponentCollection &scoreBreakdown
00028 , ScoreComponentCollection &estimatedScores) const {};
00029 void EvaluateWithSourceContext(const InputType &input
00030 , const InputPath &inputPath
00031 , const TargetPhrase &targetPhrase
00032 , const StackVec *stackVec
00033 , ScoreComponentCollection &scoreBreakdown
00034 , ScoreComponentCollection *estimatedScores = NULL) const {};
00035
00036 void EvaluateTranslationOptionListWithSourceContext(const InputType &input
00037 , const TranslationOptionList &translationOptionList) const {
00038 }
00039
00040 void EvaluateWhenApplied(const Hypothesis& hypo,
00041 ScoreComponentCollection* accumulator) const {};
00042
00043 bool Load(const std::string &filePath);
00044
00045 std::vector<std::vector<Word> >& GetSoftMatches() {
00046 return m_softMatches;
00047 }
00048
00049 void ResizeCache() const;
00050
00051 const std::string& GetOrSetFeatureName(const Word& RHS, const Word& LHS) const;
00052 void SetParameter(const std::string& key, const std::string& value);
00053
00054
00055 private:
00056 mutable std::vector<std::vector<Word> > m_softMatches;
00057 mutable std::vector<std::vector<std::string> > m_nameCache;
00058 bool m_scoreIdentical;
00059
00060 #ifdef WITH_THREADS
00061
00062 mutable boost::shared_mutex m_accessLock;
00063 #endif
00064
00065 };
00066
00067 }
00068