diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2013-09-18 17:47:49 +0400 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2013-09-18 17:47:49 +0400 |
commit | 24f1760c05619419c304c254d75bf210b145f8ee (patch) | |
tree | d3a293532deeae97b909e9f4ffd66b0be6d64b60 /moses/Phrase.cpp | |
parent | 5625d30a2626630673a5c5c559d7cb7b2f7f76a8 (diff) |
add max-unknowns arg to ConstrainedDecoding FF
Diffstat (limited to 'moses/Phrase.cpp')
-rw-r--r-- | moses/Phrase.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/moses/Phrase.cpp b/moses/Phrase.cpp index ae0572357..14f764115 100644 --- a/moses/Phrase.cpp +++ b/moses/Phrase.cpp @@ -373,11 +373,12 @@ void Phrase::InitStartEndWord() AddWord(endWord); } -size_t Phrase::Find(const Phrase &sought) const +size_t Phrase::Find(const Phrase &sought, int maxUnknown) const { size_t maxStartPos = GetSize() - sought.GetSize(); for (size_t startThisPos = 0; startThisPos <= maxStartPos; ++startThisPos) { size_t thisPos = startThisPos; + int currUnknowns = 0; size_t soughtPos; for (soughtPos = 0; soughtPos < sought.GetSize(); ++soughtPos) { const Word &soughtWord = sought.GetWord(soughtPos); @@ -386,6 +387,11 @@ size_t Phrase::Find(const Phrase &sought) const if (soughtWord == thisWord) { ++thisPos; } + else if (soughtWord.IsOOV() && (maxUnknown < 0 || currUnknowns < maxUnknown)) { + // the output has an OOV word. Allow a certain number of OOVs + ++currUnknowns; + ++thisPos; + } else { break; } |