diff options
author | Hieu Hoang <s0565741@hel.inf.ed.ac.uk> | 2012-05-17 18:50:14 +0400 |
---|---|---|
committer | Hieu Hoang <s0565741@hel.inf.ed.ac.uk> | 2012-05-17 18:50:14 +0400 |
commit | d554cd04e4d6b385065fca322143f0f775a52bd0 (patch) | |
tree | 7f4b205946a6618176657bbf154137a8e3db9fb6 /moses | |
parent | 7d457f5049b1d9f33a733306bbb0103c48c0a7d0 (diff) |
Error when using XML with multiple translation tables. Reported by Rafael Carrascosa
Diffstat (limited to 'moses')
-rw-r--r-- | moses/src/TranslationOptionCollection.cpp | 27 | ||||
-rw-r--r-- | moses/src/TranslationOptionCollection.h | 3 |
2 files changed, 16 insertions, 14 deletions
diff --git a/moses/src/TranslationOptionCollection.cpp b/moses/src/TranslationOptionCollection.cpp index ec1350db4..667035058 100644 --- a/moses/src/TranslationOptionCollection.cpp +++ b/moses/src/TranslationOptionCollection.cpp @@ -165,13 +165,13 @@ void TranslationOptionCollection::ProcessUnknownWord() const vector<DecodeGraph*>& decodeGraphList = m_system->GetDecodeGraphs(); size_t size = m_source.GetSize(); // try to translation for coverage with no trans by expanding table limit - for (size_t graph = 0 ; graph < decodeGraphList.size() ; graph++) { - const DecodeGraph &decodeGraph = *decodeGraphList[graph]; + for (size_t graphInd = 0 ; graphInd < decodeGraphList.size() ; graphInd++) { + const DecodeGraph &decodeGraph = *decodeGraphList[graphInd]; for (size_t pos = 0 ; pos < size ; ++pos) { TranslationOptionList &fullList = GetTranslationOptionList(pos, pos); size_t numTransOpt = fullList.size(); if (numTransOpt == 0) { - CreateTranslationOptionsForRange(decodeGraph, pos, pos, false); + CreateTranslationOptionsForRange(decodeGraph, pos, pos, false, graphInd); } } } @@ -367,12 +367,12 @@ void TranslationOptionCollection::CreateTranslationOptions() size_t size = m_source.GetSize(); // loop over all decoding graphs, each generates translation options - for (size_t graph = 0 ; graph < decodeGraphList.size() ; graph++) { + for (size_t graphInd = 0 ; graphInd < decodeGraphList.size() ; graphInd++) { if (decodeGraphList.size() > 1) { - VERBOSE(3,"Creating translation options from decoding graph " << graph << endl); + VERBOSE(3,"Creating translation options from decoding graph " << graphInd << endl); } - const DecodeGraph &decodeGraph = *decodeGraphList[graph]; + const DecodeGraph &decodeGraph = *decodeGraphList[graphInd]; // generate phrases that start at startPos ... for (size_t startPos = 0 ; startPos < size; startPos++) { size_t maxSize = size - startPos; // don't go over end of sentence @@ -381,17 +381,17 @@ void TranslationOptionCollection::CreateTranslationOptions() // ... and that end at endPos for (size_t endPos = startPos ; endPos < startPos + maxSize ; endPos++) { - if (graph > 0 && // only skip subsequent graphs - decodeGraphBackoff[graph] != 0 && // use of backoff specified - (endPos-startPos+1 >= decodeGraphBackoff[graph] || // size exceeds backoff limit or ... + if (graphInd > 0 && // only skip subsequent graphs + decodeGraphBackoff[graphInd] != 0 && // use of backoff specified + (endPos-startPos+1 >= decodeGraphBackoff[graphInd] || // size exceeds backoff limit or ... m_collection[startPos][endPos-startPos].size() > 0)) { // no phrases found so far - VERBOSE(3,"No backoff to graph " << graph << " for span [" << startPos << ";" << endPos << "]" << endl); + VERBOSE(3,"No backoff to graph " << graphInd << " for span [" << startPos << ";" << endPos << "]" << endl); // do not create more options continue; } // create translation options for that range - CreateTranslationOptionsForRange( decodeGraph, startPos, endPos, true); + CreateTranslationOptionsForRange( decodeGraph, startPos, endPos, true, graphInd); } } } @@ -440,7 +440,8 @@ void TranslationOptionCollection::CreateTranslationOptionsForRange( const DecodeGraph &decodeGraph , size_t startPos , size_t endPos - , bool adhereTableLimit) + , bool adhereTableLimit + , size_t graphInd) { if ((StaticData::Instance().GetXmlInputType() != XmlExclusive) || !HasXmlOptionsOverlappingRange(startPos,endPos)) { Phrase *sourcePhrase = NULL; // can't initialise with substring, in case it's confusion network @@ -529,7 +530,7 @@ void TranslationOptionCollection::CreateTranslationOptionsForRange( delete sourcePhrase; } // if ((StaticData::Instance().GetXmlInputType() != XmlExclusive) || !HasXmlOptionsOverlappingRange(startPos,endPos)) - if ((StaticData::Instance().GetXmlInputType() != XmlPassThrough) && HasXmlOptionsOverlappingRange(startPos,endPos)) { + if (graphInd == 0 && StaticData::Instance().GetXmlInputType() != XmlPassThrough && HasXmlOptionsOverlappingRange(startPos,endPos)) { CreateXmlOptionsForRange(startPos, endPos); } } diff --git a/moses/src/TranslationOptionCollection.h b/moses/src/TranslationOptionCollection.h index e1fa26a15..c6452559c 100644 --- a/moses/src/TranslationOptionCollection.h +++ b/moses/src/TranslationOptionCollection.h @@ -116,7 +116,8 @@ public: virtual void CreateTranslationOptionsForRange(const DecodeGraph &decodeStepList , size_t startPosition , size_t endPosition - , bool adhereTableLimit); + , bool adhereTableLimit + , size_t graphInd); //!Check if this range has XML options virtual bool HasXmlOptionsOverlappingRange(size_t startPosition, size_t endPosition) const; |