diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2013-11-20 15:59:36 +0400 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2013-11-20 15:59:36 +0400 |
commit | a77e928628caa7d0c6fdab66493c7891def9ee16 (patch) | |
tree | 641087cf9231e7d558c36af43d908dd455872d19 /moses/TreeInput.cpp | |
parent | c2ffc022eab102fc2e1593c435c1eaa389583278 (diff) |
replace CHECK with UTIL_THROW_IF in Moses
Diffstat (limited to 'moses/TreeInput.cpp')
-rw-r--r-- | moses/TreeInput.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/moses/TreeInput.cpp b/moses/TreeInput.cpp index 434f58aa4..3fcc31820 100644 --- a/moses/TreeInput.cpp +++ b/moses/TreeInput.cpp @@ -183,7 +183,8 @@ bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector<XMLParseOutput> } Word *targetLHS = new Word(true); targetLHS->CreateFromString(Output, outputFactorOrder, targetLHSstr, true); - CHECK(targetLHS->GetFactor(0) != NULL); + UTIL_THROW_IF(targetLHS->GetFactor(0) == NULL, util::Exception, + "Null factor left-hand-side"); targetPhrase.SetTargetLHS(targetLHS); // not tested @@ -202,7 +203,7 @@ bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector<XMLParseOutput> // set span and create XmlOption WordsRange range(startPos+1,endPos); XmlOption *option = new XmlOption(range,targetPhrase); - CHECK(option); + assert(option); xmlOptions.push_back(option); VERBOSE(2,"xml translation = [" << range << "] " << targetLHSstr << " -> " << altTexts[i] << " prob: " << probValue << endl); @@ -287,7 +288,8 @@ TranslationOptionCollection* TreeInput::CreateTranslationOptionCollection() cons void TreeInput::AddChartLabel(size_t startPos, size_t endPos, const Word &label , const std::vector<FactorType>& /* factorOrder */) { - CHECK(label.IsNonTerminal()); + UTIL_THROW_IF(!label.IsNonTerminal(), util::Exception, + "Label must be a non-terminal"); SourceLabelOverlap overlapType = StaticData::Instance().GetSourceLabelOverlap(); NonTerminalSet &list = GetLabelSet(startPos, endPos); @@ -328,9 +330,10 @@ std::ostream& operator<<(std::ostream &out, const TreeInput &input) NonTerminalSet::const_iterator iter; for (iter = labelSet.begin(); iter != labelSet.end(); ++iter) { const Word &word = *iter; + UTIL_THROW_IF(!word.IsNonTerminal(), util::Exception, + "Word must be a non-terminal"); out << "[" << startPos <<"," << endPos << "]=" << word << "(" << word.IsNonTerminal() << ") "; - CHECK(word.IsNonTerminal()); } } } |