diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-04-21 19:41:33 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-04-21 19:41:33 +0300 |
commit | 8a921f5dc96eb110641f2924f541620001d5c27b (patch) | |
tree | e5fa4cffb6667f91a6b8b41c0967e70d2a860545 /moses | |
parent | adc80953e476dd48fc75a57512d6409fff606bee (diff) |
Initial check-in.
Diffstat (limited to 'moses')
-rw-r--r-- | moses/TranslationModel/UG/mm/ug_phrasepair.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/moses/TranslationModel/UG/mm/ug_phrasepair.cc b/moses/TranslationModel/UG/mm/ug_phrasepair.cc new file mode 100644 index 000000000..ec3423fdc --- /dev/null +++ b/moses/TranslationModel/UG/mm/ug_phrasepair.cc @@ -0,0 +1,44 @@ +#include "ug_phrasepair.h" + +namespace Moses { +namespace bitext { + +void +fill_lr_vec2 +( LRModel::ModelType mdl, float const* const cnt, + float const total, float* v) +{ + if (mdl == LRModel::Monotonic) + { + float denom = log(total + 2); + v[LRModel::M] = log(cnt[LRModel::M] + 1.) - denom; + v[LRModel::NM] = log(total - v[LRModel::M] + 1) - denom; + } + else if (mdl == LRModel::LeftRight) + { + float denom = log(total + 2); + v[LRModel::R] = log(cnt[LRModel::M] + cnt[LRModel::DR] + 1.) - denom; + v[LRModel::L] = log(cnt[LRModel::S] + cnt[LRModel::DL] + 1.) - denom; + } + else if (mdl == LRModel::MSD) + { + float denom = log(total + 3); + v[LRModel::M] = log(cnt[LRModel::M] + 1) - denom; + v[LRModel::S] = log(cnt[LRModel::S] + 1) - denom; + v[LRModel::D] = log(cnt[LRModel::DR] + + cnt[LRModel::DL] + 1) - denom; + } + else if (mdl == LRModel::MSLR) + { + float denom = log(total + 4); + v[LRModel::M] = log(cnt[LRModel::M] + 1) - denom; + v[LRModel::S] = log(cnt[LRModel::S] + 1) - denom; + v[LRModel::DL] = log(cnt[LRModel::DL] + 1) - denom; + v[LRModel::DR] = log(cnt[LRModel::DR] + 1) - denom; + } + else UTIL_THROW2("Reordering type not recognized!"); +} + + +} // namespace bitext +} // namespace Moses |