diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2014-05-12 22:44:31 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2014-05-12 22:44:31 +0400 |
commit | 6c9bc9f9887f27fab799bb42dad9f2df2ec96b34 (patch) | |
tree | 4cb12020d15a9ae50cd7413e9dcec7bee45ea72a /moses/ChartTranslationOptionList.cpp | |
parent | 5f7c424f7f2aca44768655b245e5bead0e336cbd (diff) |
delete chart translation option if -inf score. Add FF MaxSpanFreeNonTermSource to use it
Diffstat (limited to 'moses/ChartTranslationOptionList.cpp')
-rw-r--r-- | moses/ChartTranslationOptionList.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/moses/ChartTranslationOptionList.cpp b/moses/ChartTranslationOptionList.cpp index 89955dcee..a560a070b 100644 --- a/moses/ChartTranslationOptionList.cpp +++ b/moses/ChartTranslationOptionList.cpp @@ -176,6 +176,36 @@ void ChartTranslationOptionList::Evaluate(const InputType &input, const InputPat ChartTranslationOptions &transOpts = **iter; transOpts.Evaluate(input, inputPath); } + + // get rid of empty trans opts + size_t numDiscard = 0; + for (size_t i = 0; i < m_size; ++i) { + ChartTranslationOptions *transOpts = m_collection[i]; + if (transOpts->GetSize() == 0) { + //delete transOpts; + ++numDiscard; + } + else if (numDiscard) { + SwapTranslationOptions(i - numDiscard, i); + //m_collection[] = transOpts; + } + } + + size_t newSize = m_size - numDiscard; + + if (numDiscard) { + cerr << "LIST numDiscard=" << numDiscard << " newSize=" << newSize << endl; + } + m_size = newSize; + +} + +void ChartTranslationOptionList::SwapTranslationOptions(size_t a, size_t b) +{ + ChartTranslationOptions *transOptsA = m_collection[a]; + ChartTranslationOptions *transOptsB = m_collection[b]; + m_collection[a] = transOptsB; + m_collection[b] = transOptsA; } std::ostream& operator<<(std::ostream &out, const ChartTranslationOptionList &obj) |