00001 // -*- c++ -*- 00002 // Phrase scorer that rewards the number of phrase pair occurrences in a bitext 00003 // with the asymptotic function j/(j+x) where x > 0 is a function 00004 // parameter that determines the steepness of the rewards curve 00005 // written by Ulrich Germann 00006 00007 #include "sapt_pscore_base.h" 00008 #include <boost/dynamic_bitset.hpp> 00009 00010 namespace sapt { 00011 00012 // asymptotic provenance feature n/(n+x) 00013 template<typename Token> 00014 class 00015 PScoreProvenance : public SingleRealValuedParameterPhraseScorerFamily<Token> 00016 { 00017 public: 00018 00019 virtual ~PScoreProvenance() {} 00020 PScoreProvenance(std::string const& spec) 00021 { 00022 this->m_tag = "prov"; 00023 this->init(spec); 00024 } 00025 00026 bool 00027 isLogVal(int i) const { return false; } 00028 00029 void 00030 operator()(Bitext<Token> const& bt, 00031 PhrasePair<Token>& pp, 00032 std::vector<float> * dest = NULL) const 00033 { 00034 if (!dest) dest = &pp.fvals; 00035 size_t i = this->m_index; 00036 BOOST_FOREACH(float const x, this->m_x) 00037 (*dest).at(i++) = pp.joint/(x + pp.joint); 00038 } 00039 00040 bool 00041 allowPooling() const 00042 { return false; } 00043 00044 }; 00045 } // namespace sapt 00046