00001 // -*- c++ -*- 00002 // written by Ulrich Germann 00003 #pragma once 00004 #include "moses/TranslationModel/UG/mm/ug_bitext.h" 00005 #include "util/exception.hh" 00006 #include "boost/format.hpp" 00007 00008 namespace sapt 00009 { 00010 template<typename Token> 00011 class 00012 PScoreCoherence : public PhraseScorer<Token> 00013 { 00014 public: 00015 PScoreCoherence(std::string const dummy) 00016 { 00017 this->m_index = -1; 00018 this->m_num_feats = 1; 00019 this->m_feature_names.push_back(std::string("coherence")); 00020 } 00021 00022 void 00023 operator()(Bitext<Token> const& bt, 00024 PhrasePair<Token>& pp, 00025 std::vector<float> * dest = NULL) const 00026 { 00027 if (!dest) dest = &pp.fvals; 00028 (*dest)[this->m_index] = log(pp.good1) - log(pp.sample1); 00029 } 00030 }; 00031 } 00032