diff options
author | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2014-07-09 05:41:28 +0400 |
---|---|---|
committer | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2014-07-09 05:41:28 +0400 |
commit | 4d41211c2cd6eb75c5a229c10e98fdfa1acff3b4 (patch) | |
tree | 142dca24625b301147a931f728825dd40cf74e53 /moses/TranslationModel/UG/sapt_pscore_rareness.h | |
parent | 28d64e23396cba53a83b75e01e9977db636e2285 (diff) |
Major overhaul of Mmsapt. Reorganization of old and addition of new features in phrase tables. Many critical bug fixes.
Diffstat (limited to 'moses/TranslationModel/UG/sapt_pscore_rareness.h')
-rw-r--r-- | moses/TranslationModel/UG/sapt_pscore_rareness.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/moses/TranslationModel/UG/sapt_pscore_rareness.h b/moses/TranslationModel/UG/sapt_pscore_rareness.h new file mode 100644 index 000000000..58f204c88 --- /dev/null +++ b/moses/TranslationModel/UG/sapt_pscore_rareness.h @@ -0,0 +1,41 @@ +// -*- c++ -*- +// Phrase scorer that rewards the number of phrase pair occurrences in a bitext +// with the asymptotic function x/(j+x) where x > 0 is a function +// parameter that determines the steepness of the rewards curve +// written by Ulrich Germann + +#include "sapt_pscore_base.h" +#include <boost/dynamic_bitset.hpp> + +using namespace std; +namespace Moses { + namespace bitext { + + // rareness penalty: x/(n+x) + template<typename Token> + class + PScoreRareness : public SingleRealValuedParameterPhraseScorerFamily<Token> + { + public: + PScoreRareness(string const spec) + { + this->m_tag = "rare"; + this->init(spec); + } + + bool + isLogVal(int i) const { return false; } + + void + operator()(Bitext<Token> const& bt, + PhrasePair<Token>& pp, + vector<float> * dest = NULL) const + { + if (!dest) dest = &pp.fvals; + size_t i = this->m_index; + BOOST_FOREACH(float const x, this->m_x) + (*dest).at(i++) = x/(x + pp.joint); + } + }; + } // namespace bitext +} // namespace Moses |