Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2013-09-18 17:47:49 +0400
committerHieu Hoang <hieuhoang@gmail.com>2013-09-18 17:47:49 +0400
commit24f1760c05619419c304c254d75bf210b145f8ee (patch)
treed3a293532deeae97b909e9f4ffd66b0be6d64b60 /moses/Phrase.cpp
parent5625d30a2626630673a5c5c559d7cb7b2f7f76a8 (diff)
add max-unknowns arg to ConstrainedDecoding FF
Diffstat (limited to 'moses/Phrase.cpp')
-rw-r--r--moses/Phrase.cpp8
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;
}