diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-10-07 19:44:26 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-10-07 19:44:26 +0400 |
commit | 8b9d4d1c7dac2f2a53e9a4d5949e10a4511aeb0c (patch) | |
tree | ab4c3af87d8e5ded4644f78c4cf06dc92742e6f7 /moses/TranslationOptionCollectionConfusionNet.cpp | |
parent | 67c294a7d8b621955c295dc838f9bf0086f62e98 (diff) |
limit size of input path for confusion networks and lattices. Prevent memory blowup. /Yulia Tsvetkov
Diffstat (limited to 'moses/TranslationOptionCollectionConfusionNet.cpp')
-rw-r--r-- | moses/TranslationOptionCollectionConfusionNet.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/moses/TranslationOptionCollectionConfusionNet.cpp b/moses/TranslationOptionCollectionConfusionNet.cpp index 1b2b1c552..6fe0bf914 100644 --- a/moses/TranslationOptionCollectionConfusionNet.cpp +++ b/moses/TranslationOptionCollectionConfusionNet.cpp @@ -24,11 +24,14 @@ TranslationOptionCollectionConfusionNet::TranslationOptionCollectionConfusionNet const InputFeature *inputFeature = StaticData::Instance().GetInputFeature(); CHECK(inputFeature); - size_t size = input.GetSize(); - m_inputPathMatrix.resize(size); + size_t inputSize = input.GetSize(); + m_inputPathMatrix.resize(inputSize); + + size_t maxSizePhrase = StaticData::Instance().GetMaxPhraseLength(); + maxSizePhrase = std::min(inputSize, maxSizePhrase); // 1-word phrases - for (size_t startPos = 0; startPos < size; ++startPos) { + for (size_t startPos = 0; startPos < inputSize; ++startPos) { vector<InputPathList> &vec = m_inputPathMatrix[startPos]; vec.push_back(InputPathList()); InputPathList &list = vec.back(); @@ -53,9 +56,9 @@ TranslationOptionCollectionConfusionNet::TranslationOptionCollectionConfusionNet } // subphrases of 2+ words - for (size_t phaseSize = 2; phaseSize <= size; ++phaseSize) { - for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) { - size_t endPos = startPos + phaseSize -1; + for (size_t phraseSize = 2; phraseSize <= maxSizePhrase; ++phraseSize) { + for (size_t startPos = 0; startPos < inputSize - phraseSize + 1; ++startPos) { + size_t endPos = startPos + phraseSize -1; WordsRange range(startPos, endPos); const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos); |