mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-29 15:04:05 +03:00
More informative error message about <s> errors
This commit is contained in:
parent
314313ad89
commit
1c72f79698
@ -99,7 +99,10 @@ void LanguageModelImplementation::CalcScore(const Phrase &phrase, float &fullSco
|
||||
|
||||
if (word == GetSentenceStartArray()) {
|
||||
// do nothing, don't include prob for <s> unigram
|
||||
assert(currPos == 0);
|
||||
if (currPos != 0) {
|
||||
std::cerr << "Your data contains <s> in a position other than the first word." << std::endl;
|
||||
abort();
|
||||
}
|
||||
} else {
|
||||
LMResult result = GetValueGivenState(contextFactor, *state);
|
||||
fullScore += result.score;
|
||||
|
@ -198,6 +198,10 @@ template <class Model> void LanguageModelKen<Model>::CalcScore(const Phrase &phr
|
||||
*state0 = m_ngram->NullContextState();
|
||||
} else {
|
||||
lm::WordIndex index = TranslateID(word);
|
||||
if (index == m_ngram->GetVocabulary().BeginSentence()) {
|
||||
std::cerr << "Your data contains <s> in a position other than the first word." << std::endl;
|
||||
abort();
|
||||
}
|
||||
float score = TransformLMScore(m_ngram->Score(*state0, index, *state1));
|
||||
std::swap(state0, state1);
|
||||
if (position >= ngramBoundary) ngramScore += score;
|
||||
|
Loading…
Reference in New Issue
Block a user