diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2013-07-08 20:58:22 +0400 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2013-07-08 20:58:22 +0400 |
commit | b03ac10a2df0f44f18c554ac05a1b7912127e031 (patch) | |
tree | 3ac1433f4ee59bd299e756963ffc331770e13ff9 | |
parent | 29b895a97a0b7016e6afe8fa9cb2d232fec766a1 (diff) |
error processing OOV when using OnDisk pt
-rw-r--r-- | moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp index 89a02d966..d20ed7c73 100644 --- a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp +++ b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp @@ -122,25 +122,30 @@ void PhraseDictionaryOnDisk::SetTargetPhraseFromPtMatrix(const std::vector<Input lastWord.OnlyTheseFactors(m_inputFactors); OnDiskPt::Word *lastWordOnDisk = wrapper.ConvertFromMoses(m_input, lastWord); - const OnDiskPt::PhraseNode *ptNode = prevPtNode->GetChild(*lastWordOnDisk, wrapper); - if (ptNode) { - vector<float> weightT = StaticData::Instance().GetWeights(this); - OnDiskPt::Vocab &vocab = wrapper.GetVocab(); - - const OnDiskPt::TargetPhraseCollection *targetPhrasesOnDisk = ptNode->GetTargetPhraseCollection(m_tableLimit, wrapper); - const TargetPhraseCollection *targetPhrases - = targetPhrasesOnDisk->ConvertToMoses(m_input, m_output, *this, weightT, vocab); + if (lastWordOnDisk == NULL) { + // OOV according to this phrase table. Not possible to extend + node.SetTargetPhrases(*this, NULL, NULL); + } + else { + const OnDiskPt::PhraseNode *ptNode = prevPtNode->GetChild(*lastWordOnDisk, wrapper); + if (ptNode) { + vector<float> weightT = StaticData::Instance().GetWeights(this); + OnDiskPt::Vocab &vocab = wrapper.GetVocab(); - node.SetTargetPhrases(*this, targetPhrases, ptNode); + const OnDiskPt::TargetPhraseCollection *targetPhrasesOnDisk = ptNode->GetTargetPhraseCollection(m_tableLimit, wrapper); + const TargetPhraseCollection *targetPhrases + = targetPhrasesOnDisk->ConvertToMoses(m_input, m_output, *this, weightT, vocab); - delete targetPhrasesOnDisk; + node.SetTargetPhrases(*this, targetPhrases, ptNode); - } else { - node.SetTargetPhrases(*this, NULL, NULL); - } + delete targetPhrasesOnDisk; - delete lastWordOnDisk; + } else { + node.SetTargetPhrases(*this, NULL, NULL); + } + delete lastWordOnDisk; + } } } } |