00001 #include <sstream>
00002 #include "PhraseLengthFeature.h"
00003 #include "moses/Hypothesis.h"
00004 #include "moses/ScoreComponentCollection.h"
00005 #include "moses/TranslationOption.h"
00006 #include "util/string_stream.hh"
00007
00008 namespace Moses
00009 {
00010
00011 using namespace std;
00012
00013 PhraseLengthFeature::PhraseLengthFeature(const std::string &line)
00014 :StatelessFeatureFunction(0, line)
00015 {
00016 ReadParameters();
00017 }
00018
00019 void PhraseLengthFeature::EvaluateInIsolation(const Phrase &source
00020 , const TargetPhrase &targetPhrase
00021 , ScoreComponentCollection &scoreBreakdown
00022 , ScoreComponentCollection &estimatedScores) const
00023 {
00024
00025 size_t targetLength = targetPhrase.GetSize();
00026 size_t sourceLength = source.GetSize();
00027
00028
00029 util::StringStream nameSource;
00030 nameSource << "s" << sourceLength;
00031
00032 util::StringStream nameTarget;
00033 nameTarget << "t" << targetLength;
00034
00035 util::StringStream nameBoth;
00036 nameBoth << sourceLength << "," << targetLength;
00037
00038
00039 scoreBreakdown.PlusEquals(this,nameSource.str(),1);
00040 scoreBreakdown.PlusEquals(this,nameTarget.str(),1);
00041 scoreBreakdown.PlusEquals(this,nameBoth.str(),1);
00042
00043
00044 }
00045
00046 }