mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
move function calls with side effects out of asserts
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@3403 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
7b06173064
commit
ef09298824
@ -136,7 +136,8 @@ bool OnDiskWrapper::BeginSave(const std::string &filePath
|
||||
|
||||
void OnDiskWrapper::EndSave()
|
||||
{
|
||||
assert(m_rootSourceNode->Saved());
|
||||
bool ret = m_rootSourceNode->Saved();
|
||||
assert(ret);
|
||||
|
||||
GetVocab().Save(*this);
|
||||
|
||||
|
@ -113,7 +113,6 @@ void PhraseNode::Save(OnDiskWrapper &onDiskWrapper, size_t pos, size_t tableLimi
|
||||
const Word &childWord = iter->first;
|
||||
PhraseNode &childNode = iter->second;
|
||||
|
||||
//assert(childNode.Saved());
|
||||
// recursive
|
||||
if (!childNode.Saved())
|
||||
childNode.Save(onDiskWrapper, pos + 1, tableLimit);
|
||||
|
@ -267,8 +267,9 @@ pair<float, float> BilingualDynSuffixArray::GetLexicalWeight(const PhrasePair& p
|
||||
void BilingualDynSuffixArray::CacheWordProbs(wordID_t srcWord) const
|
||||
{
|
||||
std::map<wordID_t, int> counts;
|
||||
std::vector<wordID_t> vword(1, srcWord), wrdIndices;
|
||||
assert(m_srcSA->GetCorpusIndex(&vword, &wrdIndices));
|
||||
std::vector<wordID_t> vword(1, srcWord), wrdIndices;
|
||||
bool ret = m_srcSA->GetCorpusIndex(&vword, &wrdIndices);
|
||||
assert(ret);
|
||||
std::vector<int> sntIndexes = GetSntIndexes(wrdIndices, 1);
|
||||
float denom(0);
|
||||
// for each occurrence of this word
|
||||
|
@ -22,7 +22,10 @@ namespace Moses {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else
|
||||
assert(setStreamBuffer(flags & std::ios::in));
|
||||
{
|
||||
bool ret = setStreamBuffer(flags & std::ios::in);
|
||||
assert(ret);
|
||||
}
|
||||
this->precision(32);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,9 @@ namespace Moses {
|
||||
m_ids2words.clear();
|
||||
std::string line, word_str;
|
||||
wordID_t id;
|
||||
assert(getline(*vcbin, line));
|
||||
|
||||
void *ret = getline(*vcbin, line);
|
||||
assert(ret);
|
||||
std::istringstream first(line.c_str());
|
||||
uint32_t vcbsize(0);
|
||||
first >> vcbsize;
|
||||
|
@ -38,7 +38,8 @@ class Vocab {
|
||||
m_kBOSWordID(1)
|
||||
{
|
||||
InitSpecialWords();
|
||||
assert( Load(vocab_path, direction, factors, closed));
|
||||
bool ret = Load(vocab_path, direction, factors, closed);
|
||||
assert(ret);
|
||||
}
|
||||
Vocab(FileHandler * fin, const FactorDirection& direction,
|
||||
const FactorList& factors, bool closed = true):
|
||||
@ -46,7 +47,8 @@ class Vocab {
|
||||
m_kBOSWordID(1)
|
||||
{
|
||||
InitSpecialWords();
|
||||
assert( Load(fin, direction, factors, closed));
|
||||
bool ret = Load(fin, direction, factors, closed);
|
||||
assert(ret);
|
||||
}
|
||||
~Vocab() {}
|
||||
// parse 'word' into factored Word and get id
|
||||
|
@ -76,37 +76,39 @@ PhraseDictionary* PhraseDictionaryFeature::LoadPhraseTable(const TranslationSyst
|
||||
const StaticData& staticData = StaticData::Instance();
|
||||
if (m_implementation == Memory)
|
||||
{ // memory phrase table
|
||||
VERBOSE(2,"using standard phrase tables" << std::endl);
|
||||
if (!FileExists(m_filePath) && FileExists(m_filePath + ".gz")) {
|
||||
m_filePath += ".gz";
|
||||
VERBOSE(2,"Using gzipped file" << std::endl);
|
||||
}
|
||||
if (staticData.GetInputType() != SentenceInput)
|
||||
{
|
||||
UserMessage::Add("Must use binary phrase table for this input type");
|
||||
assert(false);
|
||||
}
|
||||
|
||||
PhraseDictionaryMemory* pdm = new PhraseDictionaryMemory(m_numScoreComponent,this);
|
||||
assert(pdm->Load(GetInput(), GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWeightWordPenalty()));
|
||||
return pdm;
|
||||
VERBOSE(2,"using standard phrase tables" << std::endl);
|
||||
if (!FileExists(m_filePath) && FileExists(m_filePath + ".gz")) {
|
||||
m_filePath += ".gz";
|
||||
VERBOSE(2,"Using gzipped file" << std::endl);
|
||||
}
|
||||
if (staticData.GetInputType() != SentenceInput)
|
||||
{
|
||||
UserMessage::Add("Must use binary phrase table for this input type");
|
||||
assert(false);
|
||||
}
|
||||
|
||||
PhraseDictionaryMemory* pdm = new PhraseDictionaryMemory(m_numScoreComponent,this);
|
||||
bool ret = pdm->Load(GetInput(), GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWeightWordPenalty());
|
||||
assert(ret);
|
||||
return pdm;
|
||||
}
|
||||
else if (m_implementation == Binary)
|
||||
{
|
||||
PhraseDictionaryTreeAdaptor* pdta = new PhraseDictionaryTreeAdaptor(m_numScoreComponent, m_numInputScores,this);
|
||||
assert(pdta->Load( GetInput()
|
||||
bool ret = pdta->Load( GetInput()
|
||||
, GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWeightWordPenalty()));
|
||||
return pdta;
|
||||
, system->GetWeightWordPenalty());
|
||||
assert(ret);
|
||||
return pdta;
|
||||
}
|
||||
else if (m_implementation == SCFG)
|
||||
{ // memory phrase table
|
||||
@ -117,42 +119,42 @@ PhraseDictionary* PhraseDictionaryFeature::LoadPhraseTable(const TranslationSyst
|
||||
}
|
||||
|
||||
PhraseDictionarySCFG* pdm = new PhraseDictionarySCFG(m_numScoreComponent,this);
|
||||
assert(pdm->Load(GetInput()
|
||||
, GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWordPenaltyProducer()));
|
||||
return pdm;
|
||||
bool ret = pdm->Load(GetInput()
|
||||
, GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWordPenaltyProducer());
|
||||
assert(ret);
|
||||
return pdm;
|
||||
}
|
||||
else if (m_implementation == OnDisk)
|
||||
{
|
||||
|
||||
PhraseDictionaryOnDisk* pdta = new PhraseDictionaryOnDisk(m_numScoreComponent, this);
|
||||
pdta->Load(
|
||||
GetInput()
|
||||
, GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWordPenaltyProducer());
|
||||
assert(pdta);
|
||||
return pdta;
|
||||
bool ret = pdta->Load(GetInput()
|
||||
, GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWordPenaltyProducer());
|
||||
assert(ret);
|
||||
return pdta;
|
||||
}
|
||||
else if (m_implementation == Binary)
|
||||
{
|
||||
PhraseDictionaryTreeAdaptor* pdta = new PhraseDictionaryTreeAdaptor(m_numScoreComponent, m_numInputScores,this);
|
||||
assert(pdta->Load(
|
||||
GetInput()
|
||||
, GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWeightWordPenalty()));
|
||||
return pdta;
|
||||
bool ret = pdta->Load(GetInput()
|
||||
, GetOutput()
|
||||
, m_filePath
|
||||
, m_weight
|
||||
, m_tableLimit
|
||||
, system->GetLanguageModels()
|
||||
, system->GetWeightWordPenalty());
|
||||
assert(ret);
|
||||
return pdta;
|
||||
}
|
||||
else if (m_implementation == SuffixArray)
|
||||
{
|
||||
|
@ -247,10 +247,11 @@ struct PDTimp {
|
||||
else if(p.imp->isRoot())
|
||||
{
|
||||
if(wi<data.size() && data[wi])
|
||||
{
|
||||
assert(data[wi]->findKeyPtr(wi));
|
||||
return PPtr(pPool.get(PPimp(data[wi],data[wi]->findKey(wi),0)));
|
||||
}
|
||||
{
|
||||
const void* ptr = data[wi]->findKeyPtr(wi);
|
||||
assert(ptr);
|
||||
return PPtr(pPool.get(PPimp(data[wi],data[wi]->findKey(wi),0)));
|
||||
}
|
||||
}
|
||||
else if(PTF const* nextP=p.imp->ptr()->getPtr(p.imp->idx))
|
||||
{
|
||||
|
@ -205,7 +205,8 @@ PPimp* PrefixTreeMap::Extend(PPimp* p, LabelId wi) {
|
||||
|
||||
} else if(p->isRoot()) {
|
||||
if(wi < m_Data.size() && m_Data[wi]){
|
||||
assert(m_Data[wi]->findKeyPtr(wi));
|
||||
const void* ptr = m_Data[wi]->findKeyPtr(wi);
|
||||
assert(ptr);
|
||||
return m_PtrPool.get(PPimp(m_Data[wi],m_Data[wi]->findKey(wi),0));
|
||||
}
|
||||
} else if(PTF const* nextP = p->ptr()->getPtr(p->idx)) {
|
||||
|
Loading…
Reference in New Issue
Block a user