Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2013-11-21 18:55:41 +0400
committerHieu Hoang <hieuhoang@gmail.com>2013-11-21 18:55:41 +0400
commit3c0eaac9a39a1b4395176799c7619ad1e9e95e6c (patch)
treebaa9aa28cd5033cdd103a64bf365f6ece7cf5d59 /moses/ChartParser.cpp
parent8381f0c95c6af9a0b6e67740eb8dcbabf8ccf62e (diff)
replace CHECK with UTIL_THROW_IF in Moses
Diffstat (limited to 'moses/ChartParser.cpp')
-rw-r--r--moses/ChartParser.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/moses/ChartParser.cpp b/moses/ChartParser.cpp
index d81332c87..ceec4aa47 100644
--- a/moses/ChartParser.cpp
+++ b/moses/ChartParser.cpp
@@ -83,7 +83,7 @@ void ChartParserUnknown::Process(const Word &sourceWord, const WordsRange &range
Word *targetLHS = new Word(true);
targetLHS->CreateFromString(Output, staticData.GetOutputFactorOrder(), targetLHSStr, true);
- CHECK(targetLHS->GetFactor(0) != NULL);
+ UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS");
// add to dictionary
TargetPhrase *targetPhrase = new TargetPhrase();
@@ -119,7 +119,7 @@ void ChartParserUnknown::Process(const Word &sourceWord, const WordsRange &range
Word *targetLHS = new Word(true);
targetLHS->CreateFromString(Output, staticData.GetOutputFactorOrder(), targetLHSStr, true);
- CHECK(targetLHS->GetFactor(0) != NULL);
+ UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS");
targetPhrase->GetScoreBreakdown().Assign(unknownWordPenaltyProducer, unknownScore);
targetPhrase->Evaluate(*unksrc);
@@ -204,7 +204,8 @@ void ChartParser::CreateInputPaths(const InputType &input)
size_t size = input.GetSize();
m_inputPathMatrix.resize(size);
- CHECK(input.GetType() == SentenceInput || input.GetType() == TreeInputType);
+ UTIL_THROW_IF2(input.GetType() != SentenceInput && input.GetType() != TreeInputType,
+ "Input must be a sentence or a tree, not lattice or confusion networks");
for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) {
for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
size_t endPos = startPos + phaseSize -1;
@@ -237,14 +238,16 @@ const InputPath &ChartParser::GetInputPath(WordsRange &range) const
const InputPath &ChartParser::GetInputPath(size_t startPos, size_t endPos) const
{
size_t offset = endPos - startPos;
- CHECK(offset < m_inputPathMatrix[startPos].size());
+ UTIL_THROW_IF2(offset >= m_inputPathMatrix[startPos].size(),
+ "Out of bound: " << offset);
return *m_inputPathMatrix[startPos][offset];
}
InputPath &ChartParser::GetInputPath(size_t startPos, size_t endPos)
{
size_t offset = endPos - startPos;
- CHECK(offset < m_inputPathMatrix[startPos].size());
+ UTIL_THROW_IF2(offset >= m_inputPathMatrix[startPos].size(),
+ "Out of bound: " << offset);
return *m_inputPathMatrix[startPos][offset];
}
/*