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
path: root/moses
diff options
context:
space:
mode:
authorphkoehn <phkoehn@1f5c12ca-751b-0410-a591-d2e778427230>2006-08-30 21:02:04 +0400
committerphkoehn <phkoehn@1f5c12ca-751b-0410-a591-d2e778427230>2006-08-30 21:02:04 +0400
commit821c14ec313b6cc12db4b1d33d9100dda03b6b5c (patch)
tree2a1d65b03e9126746fcd52110b03a5c6c990905e /moses
parentbafe7fc2abbb3bec9c70f44e5cc93422e9fb51c2 (diff)
a bit more cleanup of verbose logging
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@799 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses')
-rwxr-xr-xmoses/src/Hypothesis.cpp14
-rwxr-xr-xmoses/src/HypothesisCollection.cpp26
-rw-r--r--moses/src/PhraseDictionaryTreeAdaptor.cpp2
-rw-r--r--moses/src/TranslationOptionCollection.cpp24
4 files changed, 30 insertions, 36 deletions
diff --git a/moses/src/Hypothesis.cpp b/moses/src/Hypothesis.cpp
index 4c9534a98..b08c30e9f 100755
--- a/moses/src/Hypothesis.cpp
+++ b/moses/src/Hypothesis.cpp
@@ -51,11 +51,12 @@ Hypothesis::Hypothesis(InputType const& source, const TargetPhrase &emptyTarget)
, m_wordDeleted(false)
, m_languageModelStates(StaticData::Instance()->GetLMSize(), LanguageModelSingleFactor::UnknownState)
, m_arcList(NULL)
- , m_id(s_HypothesesCreated++)
+ , m_id(0)
, _lmstats(0)
{ // used for initial seeding of trans process
// initialize scores
_hash_computed = false;
+ s_HypothesesCreated = 0;
ResetScore();
}
@@ -387,12 +388,11 @@ void Hypothesis::PrintHypothesis(const InputType &source, float /*weightDistorti
TRACE_ERR(")"<<endl);
TRACE_ERR("\tbase score "<< (m_prevHypo->m_totalScore - m_prevHypo->m_futureScore) <<endl);
TRACE_ERR("\tcovering "<<m_currSourceWordsRange.GetStartPos()<<"-"<<m_currSourceWordsRange.GetEndPos()<<": "<< source.GetSubString(m_currSourceWordsRange) <<endl);
- TRACE_ERR("\ttranslated as: "<<m_targetPhrase); // <<" => translation cost "<<m_score[ScoreType::PhraseTrans];
- if (m_wordDeleted) TRACE_ERR(" word_deleted");
- TRACE_ERR(endl);
- TRACE_ERR("\tdistance: "<<GetCurrSourceWordsRange().CalcDistortion(m_prevHypo->GetCurrSourceWordsRange())); // << " => distortion cost "<<(m_score[ScoreType::Distortion]*weightDistortion)<<endl;
- TRACE_ERR("\tlanguage model cost "); // <<m_score[ScoreType::LanguageModelScore]<<endl;
- TRACE_ERR("\tword penalty "); // <<(m_score[ScoreType::WordPenalty]*weightWordPenalty)<<endl;
+ TRACE_ERR("\ttranslated as: "<<m_targetPhrase<<endl); // <<" => translation cost "<<m_score[ScoreType::PhraseTrans];
+ if (m_wordDeleted) TRACE_ERR("\tword deleted"<<endl);
+ // TRACE_ERR("\tdistance: "<<GetCurrSourceWordsRange().CalcDistortion(m_prevHypo->GetCurrSourceWordsRange())); // << " => distortion cost "<<(m_score[ScoreType::Distortion]*weightDistortion)<<endl;
+ // TRACE_ERR("\tlanguage model cost "); // <<m_score[ScoreType::LanguageModelScore]<<endl;
+ // TRACE_ERR("\tword penalty "); // <<(m_score[ScoreType::WordPenalty]*weightWordPenalty)<<endl;
TRACE_ERR("\tscore "<<m_totalScore - m_futureScore<<" + future cost "<<m_futureScore<<" = "<<m_totalScore<<endl);
TRACE_ERR( "\tunweighted feature scores: " << m_scoreBreakdown << endl);
//PrintLMScores();
diff --git a/moses/src/HypothesisCollection.cpp b/moses/src/HypothesisCollection.cpp
index 7ba4718ef..4569b77e0 100755
--- a/moses/src/HypothesisCollection.cpp
+++ b/moses/src/HypothesisCollection.cpp
@@ -48,21 +48,28 @@ void HypothesisCollection::RemoveAll()
/** add a hypothesis to the collection, prune if necessary */
void HypothesisCollection::Add(Hypothesis *hypo)
{
-
AddNoPrune(hypo);
+ VERBOSE(3,"added hyp to stack");
+ // Update best score, if this hypothesis is new best
if (hypo->GetTotalScore() > m_bestScore)
{
+ VERBOSE(3,", best on stack");
m_bestScore = hypo->GetTotalScore();
+ // this may also affect the worst score
if ( m_bestScore + m_beamThreshold > m_worstScore )
m_worstScore = m_bestScore + m_beamThreshold;
}
// Prune only if stack is twice as big as needed (lazy pruning)
- if (m_hypos.size() > 2*m_maxHypoStackSize-10)
+ VERBOSE(3,", now size " << m_hypos.size());
+ if (m_hypos.size() > 2*m_maxHypoStackSize-1)
{
PruneToSize(m_maxHypoStackSize);
}
+ else {
+ VERBOSE(3,std::endl);
+ }
}
/** add hypothesis to stack (unless worse than minimum score) */
@@ -72,6 +79,8 @@ void HypothesisCollection::AddPrune(Hypothesis *hypo)
if (hypo->GetTotalScore() < m_worstScore)
{ // really bad score. don't bother adding hypo into collection
+ StaticData::Instance()->GetSentenceStats().AddDiscarded();
+ VERBOSE(3,"discarded, too bad for stack" << std::endl);
ObjectPool<Hypothesis> &pool = Hypothesis::GetObjectPool();
pool.freeObject(hypo);
return;
@@ -92,7 +101,8 @@ void HypothesisCollection::AddPrune(Hypothesis *hypo)
// keep the best 1
Hypothesis *hypoExisting = *iter;
if (hypo->GetTotalScore() > hypoExisting->GetTotalScore())
- { // incoming hypo is better than the 1 we have
+ { // incoming hypo is better than the one we have
+ VERBOSE(3,"better than matching hyp, recombining, ");
if (m_nBestIsEnabled) {
hypo->AddArc(hypoExisting);
Detach(iter);
@@ -104,6 +114,7 @@ void HypothesisCollection::AddPrune(Hypothesis *hypo)
}
else
{ // already storing the best hypo. discard current hypo
+ VERBOSE(3,"worse than matching hyp, recombining" << std::endl)
if (m_nBestIsEnabled) {
(*iter)->AddArc(hypo);
} else {
@@ -127,24 +138,19 @@ void HypothesisCollection::PruneToSize(size_t newSize)
{
priority_queue<float> bestScores;
- // cerr << "About to prune from " << size() << " to " << newSize << endl;
// push all scores to a heap
- // (but never push scores below m_bestScore+m_beamThreshold)
+ // (but never push scores below m_bestScore+m_beamThreshold)
iterator iter = m_hypos.begin();
float score = 0;
while (iter != m_hypos.end())
{
Hypothesis *hypo = *iter;
score = hypo->GetTotalScore();
- // cerr << "H score: " << score << ", mbestscore: " << m_bestScore << " + m_beamThreshold "<< m_beamThreshold << " = " << m_bestScore+m_beamThreshold;
if (score > m_bestScore+m_beamThreshold) {
bestScores.push(score);
- // cerr << " pushed.";
}
- // cerr << endl;
++iter;
}
- // cerr << "Heap contains " << bestScores.size() << " items" << endl;
// pop the top newSize scores (and ignore them, these are the scores of hyps that will remain)
// ensure to never pop beyond heap size
@@ -175,7 +181,7 @@ void HypothesisCollection::PruneToSize(size_t newSize)
++iter;
}
}
- // cerr << "Stack size after pruning: " << size() << endl;
+ VERBOSE(3,", pruned to size " << size() << endl);
// set the worstScore, so that newly generated hypotheses will not be added if worse than the worst in the stack
m_worstScore = scoreThreshold;
diff --git a/moses/src/PhraseDictionaryTreeAdaptor.cpp b/moses/src/PhraseDictionaryTreeAdaptor.cpp
index f5cafc463..fc9374d5e 100644
--- a/moses/src/PhraseDictionaryTreeAdaptor.cpp
+++ b/moses/src/PhraseDictionaryTreeAdaptor.cpp
@@ -64,7 +64,7 @@ void PhraseDictionaryTreeAdaptor::Create(const std::vector<FactorType> &input
// set Dictionary members
m_inputFactors = FactorMask(input);
m_outputFactors = FactorMask(output);
- std::cerr << "PhraseDictionaryTreeAdaptor: input=" << m_inputFactors << " output=" << m_outputFactors << std::endl;
+ VERBOSE(2,"PhraseDictionaryTreeAdaptor: input=" << m_inputFactors << " output=" << m_outputFactors << std::endl);
// set PhraseDictionaryBase members
m_tableLimit=tableLimit;
diff --git a/moses/src/TranslationOptionCollection.cpp b/moses/src/TranslationOptionCollection.cpp
index b125cffae..5e3f0e6e4 100644
--- a/moses/src/TranslationOptionCollection.cpp
+++ b/moses/src/TranslationOptionCollection.cpp
@@ -103,11 +103,8 @@ void TranslationOptionCollection::Prune()
fullList.resize(m_maxNoTransOptPerCoverage);
}
}
- if (StaticData::Instance()->GetVerboseLevel() >= 1)
- {
- std::cerr << " Total translation options: " << total << std::endl;
- std::cerr << "Total translation options pruned: " << totalPruned << std::endl;
- }
+ VERBOSE(2," Total translation options: " << total << std::endl
+ << "Total translation options pruned: " << totalPruned << std::endl);
}
void TranslationOptionCollection::ProcessUnknownWord(const std::list < DecodeStep* > &decodeStepList, FactorCollection &factorCollection)
@@ -205,7 +202,7 @@ void TranslationOptionCollection::CalcFutureScore()
}
}
- if(StaticData::Instance()->GetVerboseLevel() >= 3)
+ IFVERBOSE(3)
{
int total = 0;
for(size_t row=0; row<size; row++)
@@ -405,10 +402,7 @@ void TranslationOptionCollection::ProcessInitialTranslation(
const TargetPhraseCollection *phraseColl = phraseDictionary.GetTargetPhraseCollection(m_source,wordsRange);
if (phraseColl != NULL)
{
- if (StaticData::Instance()->GetVerboseLevel() >= 3)
- {
- TRACE_ERR("[" << m_source.GetSubString(wordsRange) << "; " << startPos << "-" << endPos << "]\n");
- }
+ VERBOSE(3,"[" << m_source.GetSubString(wordsRange) << "; " << startPos << "-" << endPos << "]\n");
TargetPhraseCollection::const_iterator iterTargetPhrase, iterEnd;
iterEnd = (!observeTableLimit || tableLimit == 0 || phraseColl->GetSize() < tableLimit) ? phraseColl->end() : phraseColl->begin() + tableLimit;
@@ -418,15 +412,9 @@ void TranslationOptionCollection::ProcessInitialTranslation(
const TargetPhrase &targetPhrase = **iterTargetPhrase;
outputPartialTranslOptColl.Add ( new TranslationOption(wordsRange, targetPhrase) );
- if (StaticData::Instance()->GetVerboseLevel() >= 3)
- {
- TRACE_ERR("\t" << targetPhrase << "\n");
- }
- }
- if (StaticData::Instance()->GetVerboseLevel() >= 3)
- {
- TRACE_ERR(endl);
+ VERBOSE(3,"\t" << targetPhrase << "\n");
}
+ VERBOSE(3,endl);
}
}