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 <hieu@hoang.co.uk>2013-03-07 23:12:49 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-03-07 23:12:49 +0400
commit66ad6f32cec628e7c56eee9c04171e3ed4d027b4 (patch)
treec104c0227d2c31c1a870def4cff95f27e49c160b /moses/Phrase.cpp
parent1f6592aaa93ff107cba2871d6efbd8e403b667cf (diff)
start merging PhraseDictionaryMemory and PhraseDictionarySCFG
Diffstat (limited to 'moses/Phrase.cpp')
-rw-r--r--moses/Phrase.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/moses/Phrase.cpp b/moses/Phrase.cpp
index d5696b763..cae05222a 100644
--- a/moses/Phrase.cpp
+++ b/moses/Phrase.cpp
@@ -189,9 +189,26 @@ void Phrase::CreateFromStringNewFormat(FactorDirection direction
// to
// "KOMMA|none" "ART|Def.Z" "NN|Neut.NotGen.Sg" "VVFIN|none"
- m_words.reserve(annotatedWordVector.size()-1);
+ size_t numWords;
+ const StringPiece &annotatedWord = annotatedWordVector.back();
+ if (annotatedWord.size() >= 2
+ && *annotatedWord.data() == '['
+ && annotatedWord.data()[annotatedWord.size() - 1] == ']') {
+
+ numWords = annotatedWordVector.size()-1;
- for (size_t phrasePos = 0 ; phrasePos < annotatedWordVector.size() - 1 ; phrasePos++) {
+ // lhs
+ lhs.CreateFromString(direction, factorOrder, annotatedWord.substr(1, annotatedWord.size() - 2), true);
+ assert(lhs.IsNonTerminal());
+ }
+ else {
+ numWords = annotatedWordVector.size();
+ }
+
+ // parse each word
+ m_words.reserve(numWords);
+
+ for (size_t phrasePos = 0 ; phrasePos < numWords; phrasePos++) {
StringPiece &annotatedWord = annotatedWordVector[phrasePos];
bool isNonTerminal;
if (annotatedWord.size() >= 2 && *annotatedWord.data() == '[' && annotatedWord.data()[annotatedWord.size() - 1] == ']') {
@@ -214,12 +231,7 @@ void Phrase::CreateFromStringNewFormat(FactorDirection direction
}
- // lhs
- const StringPiece &annotatedWord = annotatedWordVector.back();
- CHECK(annotatedWord.size() >= 2 && *annotatedWord.data() == '[' && annotatedWord.data()[annotatedWord.size() - 1] == ']');
- lhs.CreateFromString(direction, factorOrder, annotatedWord.substr(1, annotatedWord.size() - 2), true);
- assert(lhs.IsNonTerminal());
}
int Phrase::Compare(const Phrase &other) const