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-17 04:40:25 +0400
committerHieu Hoang <hieuhoang@gmail.com>2013-09-17 04:40:25 +0400
commit8b2bed458c0c52bc65449cc6105cba60afb16120 (patch)
tree66f0a2a70e84cc1bfdaa9fc5f9be2f1bbe74f182 /moses/Phrase.cpp
parentef2f6167e7bb9f75d221e41401c08ba6a5fc72b5 (diff)
implement ConstrainedDecoding FF
Diffstat (limited to 'moses/Phrase.cpp')
-rw-r--r--moses/Phrase.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/moses/Phrase.cpp b/moses/Phrase.cpp
index 77e099830..77d117163 100644
--- a/moses/Phrase.cpp
+++ b/moses/Phrase.cpp
@@ -375,7 +375,30 @@ void Phrase::InitStartEndWord()
bool Phrase::Contains(const Phrase &sought) const
{
-
+ size_t maxStartPos = GetSize() - sought.GetSize();
+ for (size_t startThisPos = 0; startThisPos <= maxStartPos; ++startThisPos) {
+ size_t thisPos = startThisPos;
+ size_t soughtPos;
+ for (soughtPos = 0; soughtPos < sought.GetSize(); ++soughtPos) {
+ const Word &soughtWord = sought.GetWord(soughtPos);
+ const Word &thisWord = GetWord(thisPos);
+
+ if (soughtWord == thisWord) {
+ ++thisPos;
+ }
+ else {
+ break;
+ }
+ }
+
+ if (soughtPos == sought.GetSize()) {
+ cerr << "searched=" << *this << endl;
+ cerr << "sought=" << sought << endl;
+ return true;
+ }
+ }
+
+ return false;
}
TO_STRING_BODY(Phrase);