mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 05:14:36 +03:00
minor error. Segfault if phrase length is bigger than max-phrase-length
This commit is contained in:
parent
d4b270e796
commit
2beed771d2
@ -1781,6 +1781,16 @@
|
|||||||
<type>1</type>
|
<type>1</type>
|
||||||
<locationURI>PARENT-3-PROJECT_LOC/moses/TranslationModel/SkeletonPT.h</locationURI>
|
<locationURI>PARENT-3-PROJECT_LOC/moses/TranslationModel/SkeletonPT.h</locationURI>
|
||||||
</link>
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>TranslationModel/UnknownWordPenalty2.cpp</name>
|
||||||
|
<type>1</type>
|
||||||
|
<locationURI>PARENT-3-PROJECT_LOC/moses/TranslationModel/UnknownWordPenalty2.cpp</locationURI>
|
||||||
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>TranslationModel/UnknownWordPenalty2.h</name>
|
||||||
|
<type>1</type>
|
||||||
|
<locationURI>PARENT-3-PROJECT_LOC/moses/TranslationModel/UnknownWordPenalty2.h</locationURI>
|
||||||
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>TranslationModel/WordCoocTable.cpp</name>
|
<name>TranslationModel/WordCoocTable.cpp</name>
|
||||||
<type>1</type>
|
<type>1</type>
|
||||||
|
@ -102,14 +102,6 @@ void Manager::ProcessSentence()
|
|||||||
}
|
}
|
||||||
m_transOptColl->CreateTranslationOptions();
|
m_transOptColl->CreateTranslationOptions();
|
||||||
|
|
||||||
for (size_t i = 0; i < m_transOptColl->GetInputPaths().size(); ++i) {
|
|
||||||
const InputPath &path = *m_transOptColl->GetInputPaths()[i];
|
|
||||||
|
|
||||||
if (path.GetTotalRuleSize()) {
|
|
||||||
cerr << "path=" << path << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// some reporting on how long this took
|
// some reporting on how long this took
|
||||||
IFVERBOSE(1) {
|
IFVERBOSE(1) {
|
||||||
GetSentenceStats().StopTimeCollectOpts();
|
GetSentenceStats().StopTimeCollectOpts();
|
||||||
|
0
moses/TranslationModel/UnknownWordPenalty2.cpp
Normal file
0
moses/TranslationModel/UnknownWordPenalty2.cpp
Normal file
0
moses/TranslationModel/UnknownWordPenalty2.h
Normal file
0
moses/TranslationModel/UnknownWordPenalty2.h
Normal file
@ -610,6 +610,12 @@ void TranslationOptionCollection::CreateXmlOptionsForRange(size_t, size_t)
|
|||||||
void TranslationOptionCollection::Add(TranslationOption *translationOption)
|
void TranslationOptionCollection::Add(TranslationOption *translationOption)
|
||||||
{
|
{
|
||||||
const WordsRange &coverage = translationOption->GetSourceWordsRange();
|
const WordsRange &coverage = translationOption->GetSourceWordsRange();
|
||||||
|
|
||||||
|
if (coverage.GetEndPos() - coverage.GetStartPos() >= m_collection[coverage.GetStartPos()].size()) {
|
||||||
|
cerr << "translationOption=" << *translationOption << endl;
|
||||||
|
cerr << "coverage=" << coverage << endl;
|
||||||
|
}
|
||||||
|
|
||||||
UTIL_THROW_IF2(coverage.GetEndPos() - coverage.GetStartPos() >= m_collection[coverage.GetStartPos()].size(),
|
UTIL_THROW_IF2(coverage.GetEndPos() - coverage.GetStartPos() >= m_collection[coverage.GetStartPos()].size(),
|
||||||
"Out of bound access: " << coverage);
|
"Out of bound access: " << coverage);
|
||||||
m_collection[coverage.GetStartPos()][coverage.GetEndPos() - coverage.GetStartPos()].Add(translationOption);
|
m_collection[coverage.GetStartPos()][coverage.GetEndPos() - coverage.GetStartPos()].Add(translationOption);
|
||||||
|
@ -46,6 +46,11 @@ TranslationOptionCollectionLattice::TranslationOptionCollectionLattice(
|
|||||||
size_t endPos = startPos + nextNode - 1;
|
size_t endPos = startPos + nextNode - 1;
|
||||||
|
|
||||||
WordsRange range(startPos, endPos);
|
WordsRange range(startPos, endPos);
|
||||||
|
|
||||||
|
if (range.GetNumWordsCovered() > maxPhraseLength) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos);
|
const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos);
|
||||||
|
|
||||||
Phrase subphrase;
|
Phrase subphrase;
|
||||||
@ -91,6 +96,12 @@ void TranslationOptionCollectionLattice::Extend(const InputPath &prevPath, const
|
|||||||
size_t endPos = nextPos + nextNode - 1;
|
size_t endPos = nextPos + nextNode - 1;
|
||||||
|
|
||||||
WordsRange range(startPos, endPos);
|
WordsRange range(startPos, endPos);
|
||||||
|
|
||||||
|
size_t maxPhraseLength = StaticData::Instance().GetMaxPhraseLength();
|
||||||
|
if (range.GetNumWordsCovered() > maxPhraseLength) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos);
|
const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos);
|
||||||
|
|
||||||
Phrase subphrase(prevPhrase);
|
Phrase subphrase(prevPhrase);
|
||||||
|
Loading…
Reference in New Issue
Block a user