00001
00002
00003
00004
00005 #include "util/exception.hh"
00006 #include "sapt_pscore_base.h"
00007 #include <boost/dynamic_bitset.hpp>
00008 #include <cstdio>
00009
00010 namespace sapt {
00011
00012 template<typename Token>
00013 class
00014 PScoreCumBias : public PhraseScorer<Token>
00015 {
00016 float m_floor;
00017 public:
00018 PScoreCumBias(std::string const spec)
00019 {
00020 this->m_index = -1;
00021 this->m_feature_names.push_back("cumb");
00022 this->m_num_feats = this->m_feature_names.size();
00023 this->m_floor = std::atof(spec.c_str());
00024 }
00025
00026 bool
00027 isIntegerValued(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 (*dest)[this->m_index] = log(std::max(m_floor,pp.cum_bias));
00036 }
00037 };
00038 }
00039