Merge branch 'master' of github.com:moses-smt/mosesdecoder

This commit is contained in:
Barry Haddow 2015-11-10 21:35:59 +00:00
commit 1996502fcb
36 changed files with 153 additions and 149 deletions

View File

@ -487,7 +487,7 @@ public:
}
// weighted score
nBestXMLItem["totalScore"] = xmlrpc_c::value_double(path.GetTotalScore());
nBestXMLItem["totalScore"] = xmlrpc_c::value_double(path.GetFutureScore());
nBestXml.push_back(xmlrpc_c::value_struct(nBestXMLItem));
}
retData.insert(pair<string, xmlrpc_c::value>("nbest", xmlrpc_c::value_array(nBestXml)));

View File

@ -120,14 +120,14 @@ public:
BackwardsEdge::BackwardsEdge(const BitmapContainer &prevBitmapContainer
, BitmapContainer &parent
, const TranslationOptionList &translations
, const SquareMatrix &futureScores,
, const SquareMatrix &estimatedScores,
const InputType& itype,
const bool deterministic)
: m_initialized(false)
, m_prevBitmapContainer(prevBitmapContainer)
, m_parent(parent)
, m_translations(translations)
, m_futureScores(futureScores)
, m_estimatedScores(estimatedScores)
, m_seenPosition()
, m_deterministic(deterministic)
{
@ -180,10 +180,10 @@ BackwardsEdge::BackwardsEdge(const BitmapContainer &prevBitmapContainer
}
if (m_hypotheses.size() > 1) {
UTIL_THROW_IF2(m_hypotheses[0]->GetTotalScore() < m_hypotheses[1]->GetTotalScore(),
UTIL_THROW_IF2(m_hypotheses[0]->GetFutureScore() < m_hypotheses[1]->GetFutureScore(),
"Non-monotonic total score"
<< m_hypotheses[0]->GetTotalScore() << " vs. "
<< m_hypotheses[1]->GetTotalScore());
<< m_hypotheses[0]->GetFutureScore() << " vs. "
<< m_hypotheses[1]->GetFutureScore());
}
HypothesisScoreOrdererWithDistortion orderer (&transOptRange, m_deterministic);
@ -209,7 +209,7 @@ BackwardsEdge::Initialize()
const Bitmap &bm = m_hypotheses[0]->GetWordsBitmap();
const Range &newRange = m_translations.Get(0)->GetSourceWordsRange();
m_futureScore = m_futureScores.CalcFutureScore2(bm, newRange.GetStartPos(), newRange.GetEndPos());
m_estimatedScore = m_estimatedScores.CalcEstimatedScore(bm, newRange.GetStartPos(), newRange.GetEndPos());
Hypothesis *expanded = CreateHypothesis(*m_hypotheses[0], *m_translations.Get(0));
m_parent.Enqueue(0, 0, expanded, this);
@ -228,7 +228,7 @@ Hypothesis *BackwardsEdge::CreateHypothesis(const Hypothesis &hypothesis, const
IFVERBOSE(2) {
hypothesis.GetManager().GetSentenceStats().StopTimeBuildHyp();
}
newHypo->EvaluateWhenApplied(m_futureScore);
newHypo->EvaluateWhenApplied(m_estimatedScore);
return newHypo;
}
@ -460,10 +460,10 @@ BitmapContainer::ProcessBestHypothesis()
// check we are pulling things off of priority queue in right order
if (!Empty()) {
HypothesisQueueItem *check = Dequeue(true);
UTIL_THROW_IF2(item->GetHypothesis()->GetTotalScore() < check->GetHypothesis()->GetTotalScore(),
UTIL_THROW_IF2(item->GetHypothesis()->GetFutureScore() < check->GetHypothesis()->GetFutureScore(),
"Non-monotonic total score: "
<< item->GetHypothesis()->GetTotalScore() << " vs. "
<< check->GetHypothesis()->GetTotalScore());
<< item->GetHypothesis()->GetFutureScore() << " vs. "
<< check->GetHypothesis()->GetFutureScore());
}
// Logging for the criminally insane

View File

@ -109,8 +109,8 @@ class QueueItemOrderer
{
public:
bool operator()(HypothesisQueueItem* itemA, HypothesisQueueItem* itemB) const {
float scoreA = itemA->GetHypothesis()->GetTotalScore();
float scoreB = itemB->GetHypothesis()->GetTotalScore();
float scoreA = itemA->GetHypothesis()->GetFutureScore();
float scoreB = itemB->GetHypothesis()->GetFutureScore();
if (scoreA < scoreB) {
return true;
@ -151,8 +151,8 @@ public:
bool operator()(const Hypothesis* hypoA, const Hypothesis* hypoB) const {
float scoreA = hypoA->GetTotalScore();
float scoreB = hypoB->GetTotalScore();
float scoreA = hypoA->GetFutureScore();
float scoreB = hypoB->GetFutureScore();
if (scoreA > scoreB) {
return true;
@ -184,8 +184,8 @@ private:
const BitmapContainer &m_prevBitmapContainer;
BitmapContainer &m_parent;
const TranslationOptionList &m_translations;
const SquareMatrix &m_futureScores;
float m_futureScore;
const SquareMatrix &m_estimatedScores;
float m_estimatedScore;
bool m_deterministic;
@ -206,7 +206,7 @@ public:
BackwardsEdge(const BitmapContainer &prevBitmapContainer
, BitmapContainer &parent
, const TranslationOptionList &translations
, const SquareMatrix &futureScores
, const SquareMatrix &estimatedScores
, const InputType& source
, const bool deterministic = false);
~BackwardsEdge();

View File

@ -136,8 +136,8 @@ const ChartHypothesis *ChartCell::GetBestHypothesis() const
const HypoList &sortedList = iter->second.GetSortedHypotheses();
if (sortedList.size() > 0) {
const ChartHypothesis *hypo = sortedList[0];
if (hypo->GetTotalScore() > bestScore) {
bestScore = hypo->GetTotalScore();
if (hypo->GetFutureScore() > bestScore) {
bestScore = hypo->GetFutureScore();
ret = hypo;
}
}

View File

@ -207,7 +207,7 @@ void ChartHypothesis::EvaluateWhenApplied()
// total scores from prev hypos
for (std::vector<const ChartHypothesis*>::const_iterator iter = m_prevHypos.begin(); iter != m_prevHypos.end(); ++iter) {
const ChartHypothesis &prevHypo = **iter;
m_totalScore += prevHypo.GetTotalScore();
m_totalScore += prevHypo.GetFutureScore();
}
}
@ -241,7 +241,7 @@ void ChartHypothesis::AddArc(ChartHypothesis *loserHypo)
// sorting helper
struct CompareChartHypothesisTotalScore {
bool operator()(const ChartHypothesis* hypo1, const ChartHypothesis* hypo2) const {
return hypo1->GetTotalScore() > hypo2->GetTotalScore();
return hypo1->GetFutureScore() > hypo2->GetFutureScore();
}
};
@ -350,7 +350,7 @@ std::ostream& operator<<(std::ostream& out, const ChartHypothesis& hypo)
out << " " << prevHypo.GetId();
}
out << " [total=" << hypo.GetTotalScore() << "]";
out << " [total=" << hypo.GetFutureScore() << "]";
out << " " << hypo.GetScoreBreakdown();
//out << endl;

View File

@ -167,7 +167,7 @@ public:
}
//! Get the weighted total score
float GetTotalScore() const {
float GetFutureScore() const {
// scores from current translation rule. eg. translation models & word penalty
return m_totalScore;
}

View File

@ -63,14 +63,14 @@ ChartHypothesisCollection::~ChartHypothesisCollection()
*/
bool ChartHypothesisCollection::AddHypothesis(ChartHypothesis *hypo, ChartManager &manager)
{
if (hypo->GetTotalScore() == - std::numeric_limits<float>::infinity()) {
if (hypo->GetFutureScore() == - std::numeric_limits<float>::infinity()) {
manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, -inf score" << std::endl);
delete hypo;
return false;
}
if (hypo->GetTotalScore() < m_bestScore + m_beamWidth) {
if (hypo->GetFutureScore() < m_bestScore + m_beamWidth) {
// really bad score. don't bother adding hypo into collection
manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, too bad for stack" << std::endl);
@ -97,7 +97,7 @@ bool ChartHypothesisCollection::AddHypothesis(ChartHypothesis *hypo, ChartManage
// found existing hypo with same target ending.
// keep the best 1
if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) {
if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) {
// incoming hypo is better than the one we have
VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, ");
if (m_nBestIsEnabled) {
@ -138,9 +138,9 @@ pair<ChartHypothesisCollection::HCType::iterator, bool> ChartHypothesisCollectio
VERBOSE(3,"added hyp to stack");
// Update best score, if this hypothesis is new best
if (hypo->GetTotalScore() > m_bestScore) {
if (hypo->GetFutureScore() > m_bestScore) {
VERBOSE(3,", best on stack");
m_bestScore = hypo->GetTotalScore();
m_bestScore = hypo->GetFutureScore();
}
// Prune only if stack is twice as big as needed (lazy pruning)
@ -189,7 +189,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager)
float score = 0;
while (iter != m_hypos.end()) {
ChartHypothesis *hypo = *iter;
score = hypo->GetTotalScore();
score = hypo->GetFutureScore();
if (score > m_bestScore+m_beamWidth) {
bestScores.push(score);
}
@ -209,7 +209,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager)
iter = m_hypos.begin();
while (iter != m_hypos.end()) {
ChartHypothesis *hypo = *iter;
float score = hypo->GetTotalScore();
float score = hypo->GetFutureScore();
if (score < scoreThreshold) {
HCType::iterator iterRemove = iter++;
Remove(iterRemove);
@ -224,7 +224,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager)
TRACE_ERR("stack now contains: ");
for(iter = m_hypos.begin(); iter != m_hypos.end(); iter++) {
ChartHypothesis *hypo = *iter;
TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") ");
TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") ");
}
TRACE_ERR( endl);
}

View File

@ -36,7 +36,7 @@ class ChartHypothesisScoreOrderer
{
public:
bool operator()(const ChartHypothesis* hypoA, const ChartHypothesis* hypoB) const {
return hypoA->GetTotalScore() > hypoB->GetTotalScore();
return hypoA->GetFutureScore() > hypoB->GetFutureScore();
}
};

View File

@ -54,7 +54,7 @@ void ChartKBestExtractor::Extract(
// recombined.
for (++p; p != topLevelHypos.end(); ++p) {
// Check that the first item in topLevelHypos really was the best.
UTIL_THROW_IF2((*p)->GetTotalScore() > bestTopLevelHypo.GetTotalScore(),
UTIL_THROW_IF2((*p)->GetFutureScore() > bestTopLevelHypo.GetFutureScore(),
"top-level hypotheses are not correctly sorted");
// Note: there's no need for a smart pointer here: supremeHypo will take
// ownership of altHypo.
@ -308,7 +308,7 @@ ChartKBestExtractor::Derivation::Derivation(const UnweightedHyperarc &e)
boost::shared_ptr<Derivation> sub(pred.kBestList[0]);
subderivations.push_back(sub);
}
score = edge.head->hypothesis.GetTotalScore();
score = edge.head->hypothesis.GetFutureScore();
}
// Construct a Derivation that neighbours an existing Derivation.

View File

@ -662,7 +662,7 @@ void ChartManager::OutputTranslationOption(std::ostream &out,
WriteApplicationContext(out, applicationContext);
out << ": " << hypo->GetCurrTargetPhrase().GetTargetLHS()
<< "->" << hypo->GetCurrTargetPhrase()
<< " " << hypo->GetTotalScore() << hypo->GetScoreBreakdown();
<< " " << hypo->GetFutureScore() << hypo->GetScoreBreakdown();
}
// Given a hypothesis and sentence, reconstructs the 'application context' --
@ -837,7 +837,7 @@ void ChartManager::OutputBestHypo(OutputCollector *collector, const ChartHypothe
VERBOSE(3,"0" << std::endl);
if (options().output.ReportHypoScore) {
out << hypo->GetTotalScore() << " ";
out << hypo->GetFutureScore() << " ";
}
if (options().output.RecoverPath) {

View File

@ -169,7 +169,7 @@ float ChartTranslationOptionList::GetBestScore(const ChartCellLabel *chartCell)
assert(stack);
assert(!stack->empty());
const ChartHypothesis &bestHypo = **(stack->begin());
return bestHypo.GetTotalScore();
return bestHypo.GetFutureScore();
}
void ChartTranslationOptionList::EvaluateWithSourceContext(const InputType &input, const InputPath &inputPath)

View File

@ -145,8 +145,12 @@ SetCache(TranslationOption& to) const
Phrase const& tphrase = to.GetTargetPhrase();
to.CacheLexReorderingScores(*this, this->GetProb(sphrase,tphrase));
} else { // e.g. OOV with Mmsapt
Scores vals(GetNumScoreComponents(), 0);
to.CacheLexReorderingScores(*this, vals);
if (m_haveDefaultScores) {
to.CacheLexReorderingScores(*this, m_defaultScores);
} else {
Scores vals(GetNumScoreComponents(), 0);
to.CacheLexReorderingScores(*this, vals);
}
}
}

View File

@ -53,8 +53,8 @@ Hypothesis(Manager& manager, InputType const& source, const TranslationOption &i
m_sourceCompleted.GetFirstGapPos()>0 ? m_sourceCompleted.GetFirstGapPos()-1 : NOT_FOUND)
, m_currTargetWordsRange(NOT_FOUND, NOT_FOUND)
, m_wordDeleted(false)
, m_totalScore(0.0f)
, m_futureScore(0.0f)
, m_estimatedScore(0.0f)
, m_ffStates(StatefulFeatureFunction::GetStatefulFeatureFunctions().size())
, m_arcList(NULL)
, m_transOpt(initialTransOpt)
@ -84,8 +84,8 @@ Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const
prevHypo.m_currTargetWordsRange.GetEndPos()
+ transOpt.GetTargetPhrase().GetSize())
, m_wordDeleted(false)
, m_totalScore(0.0f)
, m_futureScore(0.0f)
, m_estimatedScore(0.0f)
, m_ffStates(prevHypo.m_ffStates.size())
, m_arcList(NULL)
, m_transOpt(transOpt)
@ -170,7 +170,7 @@ EvaluateWhenApplied(const StatelessFeatureFunction& slff)
*/
void
Hypothesis::
EvaluateWhenApplied(float futureScore)
EvaluateWhenApplied(float estimatedScore)
{
IFVERBOSE(2) {
m_manager.GetSentenceStats().StartTimeOtherScore();
@ -206,11 +206,11 @@ EvaluateWhenApplied(float futureScore)
}
// FUTURE COST
m_futureScore = futureScore;
m_estimatedScore = estimatedScore;
// TOTAL
m_totalScore = m_currScoreBreakdown.GetWeightedScore() + m_futureScore;
if (m_prevHypo) m_totalScore += m_prevHypo->GetScore();
m_futureScore = m_currScoreBreakdown.GetWeightedScore() + m_estimatedScore;
if (m_prevHypo) m_futureScore += m_prevHypo->GetScore();
IFVERBOSE(2) {
m_manager.GetSentenceStats().StopTimeEstimateScore();
@ -247,7 +247,7 @@ PrintHypothesis() const
TRACE_ERR( m_prevHypo->GetCurrTargetPhrase().GetSubString(range) << " ");
}
TRACE_ERR( ")"<<endl);
TRACE_ERR( "\tbase score "<< (m_prevHypo->m_totalScore - m_prevHypo->m_futureScore) <<endl);
TRACE_ERR( "\tbase score "<< (m_prevHypo->m_futureScore - m_prevHypo->m_estimatedScore) <<endl);
TRACE_ERR( "\tcovering "<<m_currSourceWordsRange.GetStartPos()<<"-"<<m_currSourceWordsRange.GetEndPos()
<<": " << m_transOpt.GetInputPath().GetPhrase() << endl);
@ -257,7 +257,7 @@ PrintHypothesis() const
// 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( "\tscore "<<m_futureScore - m_estimatedScore<<" + future cost "<<m_estimatedScore<<" = "<<m_futureScore<<endl);
TRACE_ERR( "\tunweighted feature scores: " << m_currScoreBreakdown << endl);
//PrintLMScores();
}
@ -326,7 +326,7 @@ ostream& operator<<(ostream& out, const Hypothesis& hypo)
out << "[" << hypo.m_sourceCompleted << "] ";
// scores
out << " [total=" << hypo.GetTotalScore() << "]";
out << " [total=" << hypo.GetFutureScore() << "]";
out << " " << hypo.GetScoreBreakdown();
// alignment
@ -607,10 +607,10 @@ bool
Hypothesis::
beats(Hypothesis const& b) const
{
if (m_totalScore != b.m_totalScore)
return m_totalScore > b.m_totalScore;
else if (m_futureScore != b.m_futureScore)
if (m_futureScore != b.m_futureScore)
return m_futureScore > b.m_futureScore;
else if (m_estimatedScore != b.m_estimatedScore)
return m_estimatedScore > b.m_estimatedScore;
else if (m_prevHypo)
return b.m_prevHypo ? m_prevHypo->beats(*b.m_prevHypo) : true;
else return false;

View File

@ -71,8 +71,8 @@ protected:
Range m_currSourceWordsRange; /*! source word positions of the last phrase that was used to create this hypothesis */
Range m_currTargetWordsRange; /*! target word positions of the last phrase that was used to create this hypothesis */
bool m_wordDeleted;
float m_totalScore; /*! score so far */
float m_futureScore; /*! estimated future cost to translate rest of sentence */
float m_futureScore; /*! score so far */
float m_estimatedScore; /*! estimated future cost to translate rest of sentence */
/*! sum of scores of this hypothesis, and previous hypotheses. Lazily initialised. */
mutable boost::scoped_ptr<ScoreComponentCollection> m_scoreBreakdown;
ScoreComponentCollection m_currScoreBreakdown; /*! scores for this hypothesis only */
@ -119,7 +119,7 @@ public:
return m_currTargetWordsRange.GetNumWordsCovered();
}
void EvaluateWhenApplied(float futureScore);
void EvaluateWhenApplied(float estimatedScore);
int GetId()const {
return m_id;
@ -217,11 +217,11 @@ public:
}
return *(m_scoreBreakdown.get());
}
float GetTotalScore() const {
return m_totalScore;
float GetFutureScore() const {
return m_futureScore;
}
float GetScore() const {
return m_totalScore-m_futureScore;
return m_futureScore-m_estimatedScore;
}
const FFState* GetFFState(int idx) const {
return m_ffStates[idx];

View File

@ -61,9 +61,9 @@ pair<HypothesisStackCubePruning::iterator, bool> HypothesisStackCubePruning::Add
VERBOSE(3,"added hyp to stack");
// Update best score, if this hypothesis is new best
if (hypo->GetTotalScore() > m_bestScore) {
if (hypo->GetFutureScore() > m_bestScore) {
VERBOSE(3,", best on stack");
m_bestScore = hypo->GetTotalScore();
m_bestScore = hypo->GetFutureScore();
// this may also affect the worst score
if ( m_bestScore + m_beamWidth > m_worstScore )
m_worstScore = m_bestScore + m_beamWidth;
@ -83,14 +83,14 @@ pair<HypothesisStackCubePruning::iterator, bool> HypothesisStackCubePruning::Add
bool HypothesisStackCubePruning::AddPrune(Hypothesis *hypo)
{
if (hypo->GetTotalScore() == - std::numeric_limits<float>::infinity()) {
if (hypo->GetFutureScore() == - std::numeric_limits<float>::infinity()) {
m_manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, constraint" << std::endl);
delete hypo;
return false;
}
if (hypo->GetTotalScore() < m_worstScore) {
if (hypo->GetFutureScore() < m_worstScore) {
// too bad for stack. don't bother adding hypo into collection
m_manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, too bad for stack" << std::endl);
@ -114,7 +114,7 @@ bool HypothesisStackCubePruning::AddPrune(Hypothesis *hypo)
// found existing hypo with same target ending.
// keep the best 1
if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) {
if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) {
// incoming hypo is better than the one we have
VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, ");
if (m_nBestIsEnabled) {
@ -165,7 +165,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize)
float score = 0;
while (iter != m_hypos.end()) {
Hypothesis *hypo = *iter;
score = hypo->GetTotalScore();
score = hypo->GetFutureScore();
if (score > m_bestScore+m_beamWidth) {
bestScores.push(score);
}
@ -185,7 +185,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize)
iter = m_hypos.begin();
while (iter != m_hypos.end()) {
Hypothesis *hypo = *iter;
float score = hypo->GetTotalScore();
float score = hypo->GetFutureScore();
if (score < scoreThreshold) {
iterator iterRemove = iter++;
Remove(iterRemove);
@ -200,7 +200,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize)
TRACE_ERR("stack now contains: ");
for(iter = m_hypos.begin(); iter != m_hypos.end(); iter++) {
Hypothesis *hypo = *iter;
TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") ");
TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") ");
}
TRACE_ERR( endl);
}
@ -217,7 +217,7 @@ const Hypothesis *HypothesisStackCubePruning::GetBestHypothesis() const
Hypothesis *bestHypo = *iter;
while (++iter != m_hypos.end()) {
Hypothesis *hypo = *iter;
if (hypo->GetTotalScore() > bestHypo->GetTotalScore())
if (hypo->GetFutureScore() > bestHypo->GetFutureScore())
bestHypo = hypo;
}
return bestHypo;
@ -252,14 +252,14 @@ void HypothesisStackCubePruning::SetBitmapAccessor(const Bitmap &newBitmap
, HypothesisStackCubePruning &stack
, const Range &/*range*/
, BitmapContainer &bitmapContainer
, const SquareMatrix &futureScore
, const SquareMatrix &estimatedScores
, const TranslationOptionList &transOptList)
{
BitmapContainer *bmContainer = AddBitmapContainer(newBitmap, stack);
BackwardsEdge *edge = new BackwardsEdge(bitmapContainer
, *bmContainer
, transOptList
, futureScore
, estimatedScores
, m_manager.GetSource()
, m_deterministic);
bmContainer->AddBackwardsEdge(edge);

View File

@ -125,7 +125,7 @@ public:
, HypothesisStackCubePruning &stack
, const Range &range
, BitmapContainer &bitmapContainer
, const SquareMatrix &futureScore
, const SquareMatrix &estimatedScores
, const TranslationOptionList &transOptList);
/** pruning, if too large.

View File

@ -57,17 +57,17 @@ pair<HypothesisStackNormal::iterator, bool> HypothesisStackNormal::Add(Hypothesi
VERBOSE(3,"added hyp to stack");
// Update best score, if this hypothesis is new best
if (hypo->GetTotalScore() > m_bestScore) {
if (hypo->GetFutureScore() > m_bestScore) {
VERBOSE(3,", best on stack");
m_bestScore = hypo->GetTotalScore();
m_bestScore = hypo->GetFutureScore();
// this may also affect the worst score
if ( m_bestScore + m_beamWidth > m_worstScore )
m_worstScore = m_bestScore + m_beamWidth;
}
// update best/worst score for stack diversity 1
if ( m_minHypoStackDiversity == 1 &&
hypo->GetTotalScore() > GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) {
SetWorstScoreForBitmap( hypo->GetWordsBitmap().GetID(), hypo->GetTotalScore() );
hypo->GetFutureScore() > GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) {
SetWorstScoreForBitmap( hypo->GetWordsBitmap().GetID(), hypo->GetFutureScore() );
}
VERBOSE(3,", now size " << m_hypos.size());
@ -89,7 +89,7 @@ pair<HypothesisStackNormal::iterator, bool> HypothesisStackNormal::Add(Hypothesi
bool HypothesisStackNormal::AddPrune(Hypothesis *hypo)
{
if (hypo->GetTotalScore() == - std::numeric_limits<float>::infinity()) {
if (hypo->GetFutureScore() == - std::numeric_limits<float>::infinity()) {
m_manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, constraint" << std::endl);
delete hypo;
@ -98,9 +98,9 @@ bool HypothesisStackNormal::AddPrune(Hypothesis *hypo)
// too bad for stack. don't bother adding hypo into collection
if (!StaticData::Instance().GetDisableDiscarding() &&
hypo->GetTotalScore() < m_worstScore
hypo->GetFutureScore() < m_worstScore
&& ! ( m_minHypoStackDiversity > 0
&& hypo->GetTotalScore() >= GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) ) {
&& hypo->GetFutureScore() >= GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) ) {
m_manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, too bad for stack" << std::endl);
delete hypo;
@ -123,7 +123,7 @@ bool HypothesisStackNormal::AddPrune(Hypothesis *hypo)
// found existing hypo with same target ending.
// keep the best 1
if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) {
if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) {
// incoming hypo is better than the one we have
VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, ");
if (m_nBestIsEnabled) {
@ -181,7 +181,7 @@ void HypothesisStackNormal::PruneToSize(size_t newSize)
included[i] = true;
diversityCount[ coverage ]++;
if (diversityCount[ coverage ] == m_minHypoStackDiversity)
SetWorstScoreForBitmap( coverage, hyp->GetTotalScore());
SetWorstScoreForBitmap( coverage, hyp->GetFutureScore());
}
}
}
@ -192,12 +192,12 @@ void HypothesisStackNormal::PruneToSize(size_t newSize)
// add best remaining hypotheses
for(size_t i=0; i<hypos.size()
&& size() < newSize
&& hypos[i]->GetTotalScore() > m_bestScore+m_beamWidth; i++) {
&& hypos[i]->GetFutureScore() > m_bestScore+m_beamWidth; i++) {
if (! included[i]) {
m_hypos.insert( hypos[i] );
included[i] = true;
if (size() == newSize)
m_worstScore = hypos[i]->GetTotalScore();
m_worstScore = hypos[i]->GetFutureScore();
}
}
}
@ -217,7 +217,7 @@ void HypothesisStackNormal::PruneToSize(size_t newSize)
TRACE_ERR("stack now contains: ");
for(iterator iter = m_hypos.begin(); iter != m_hypos.end(); iter++) {
Hypothesis *hypo = *iter;
TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") ");
TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") ");
}
TRACE_ERR( endl);
}
@ -230,7 +230,7 @@ const Hypothesis *HypothesisStackNormal::GetBestHypothesis() const
Hypothesis *bestHypo = *iter;
while (++iter != m_hypos.end()) {
Hypothesis *hypo = *iter;
if (hypo->GetTotalScore() > bestHypo->GetTotalScore())
if (hypo->GetFutureScore() > bestHypo->GetFutureScore())
bestHypo = hypo;
}
return bestHypo;

View File

@ -90,7 +90,7 @@ LatticeMBRSolution::LatticeMBRSolution(const TrellisPath& path, bool isMap) :
}
}
if (isMap) {
m_mapScore = path.GetTotalScore();
m_mapScore = path.GetFutureScore();
} else {
m_mapScore = 0;
}

View File

@ -1522,7 +1522,7 @@ void Manager::OutputBest(OutputCollector *collector) const
bestHypo = GetBestHypothesis();
if (bestHypo) {
if (options().output.ReportHypoScore) {
out << bestHypo->GetTotalScore() << ' ';
out << bestHypo->GetFutureScore() << ' ';
}
if (options().output.RecoverPath) {
bestHypo->OutputInput(out);
@ -1691,7 +1691,7 @@ OutputNBest(std::ostream& out,
path.GetScoreBreakdown()->OutputAllFeatureScores(out, with_labels);
// total
out << " ||| " << path.GetTotalScore();
out << " ||| " << path.GetFutureScore();
//phrase-to-phrase segmentation
if (includeSegmentation) {

View File

@ -71,7 +71,7 @@ void RuleCubeItem::EstimateScore()
std::vector<HypothesisDimension>::const_iterator p;
for (p = m_hypothesisDimensions.begin();
p != m_hypothesisDimensions.end(); ++p) {
m_score += p->GetHypothesis()->GetTotalScore();
m_score += p->GetHypothesis()->GetFutureScore();
}
}
@ -80,7 +80,7 @@ void RuleCubeItem::CreateHypothesis(const ChartTranslationOptions &transOpt,
{
m_hypothesis = new ChartHypothesis(transOpt, *this, manager);
m_hypothesis->EvaluateWhenApplied();
m_score = m_hypothesis->GetTotalScore();
m_score = m_hypothesis->GetFutureScore();
}
ChartHypothesis *RuleCubeItem::ReleaseHypothesis()

View File

@ -24,8 +24,8 @@ public:
}
// Compare the top hypothesis of each bitmap container using the TotalScore, which includes future cost
const float scoreA = A->Top()->GetHypothesis()->GetTotalScore();
const float scoreB = B->Top()->GetHypothesis()->GetTotalScore();
const float scoreA = A->Top()->GetHypothesis()->GetFutureScore();
const float scoreB = B->Top()->GetHypothesis()->GetFutureScore();
if (scoreA < scoreB) {
return true;
@ -237,13 +237,13 @@ CreateForwardTodos(Bitmap const& bitmap, Range const& range,
size_t numCovered = newBitmap.GetNumWordsCovered();
const TranslationOptionList* transOptList;
transOptList = m_transOptColl.GetTranslationOptionList(range);
const SquareMatrix &futureScore = m_transOptColl.GetFutureScore();
const SquareMatrix &estimatedScores = m_transOptColl.GetEstimatedScores();
if (transOptList && transOptList->size() > 0) {
HypothesisStackCubePruning& newStack
= *static_cast<HypothesisStackCubePruning*>(m_hypoStackColl[numCovered]);
newStack.SetBitmapAccessor(newBitmap, newStack, range, bitmapContainer,
futureScore, *transOptList);
estimatedScores, *transOptList);
}
}

View File

@ -251,14 +251,14 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos
float expectedScore = 0.0f;
const Bitmap &sourceCompleted = hypothesis.GetWordsBitmap();
float futureScore = m_transOptColl.GetFutureScore().CalcFutureScore2( sourceCompleted, startPos, endPos );
float estimatedScore = m_transOptColl.GetEstimatedScores().CalcEstimatedScore( sourceCompleted, startPos, endPos );
if (m_options.search.UseEarlyDiscarding()) {
// expected score is based on score of current hypothesis
expectedScore = hypothesis.GetScore();
// add new future score estimate
expectedScore += futureScore;
expectedScore += estimatedScore;
}
// loop through all translation options
@ -274,7 +274,7 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos
TranslationOptionList::const_iterator iter;
for (iter = tol->begin() ; iter != tol->end() ; ++iter) {
const TranslationOption &transOpt = **iter;
ExpandHypothesis(hypothesis, transOpt, expectedScore, futureScore, nextBitmap);
ExpandHypothesis(hypothesis, transOpt, expectedScore, estimatedScore, nextBitmap);
}
}
@ -290,7 +290,7 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos
void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis,
const TranslationOption &transOpt,
float expectedScore,
float futureScore,
float estimatedScore,
const Bitmap &bitmap)
{
const StaticData &staticData = StaticData::Instance();
@ -307,7 +307,7 @@ void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis,
stats.StopTimeBuildHyp();
}
if (newHypo==NULL) return;
newHypo->EvaluateWhenApplied(futureScore);
newHypo->EvaluateWhenApplied(estimatedScore);
} else
// early discarding: check if hypothesis is too bad to build
{

View File

@ -45,7 +45,7 @@ protected:
ExpandHypothesis(const Hypothesis &hypothesis,
const TranslationOption &transOpt,
float expectedScore,
float futureScore,
float estimatedScore,
const Bitmap &bitmap);
public:

View File

@ -143,7 +143,7 @@ public:
void AddRecombination(const Hypothesis& worseHypo, const Hypothesis& betterHypo) {
m_recombinationInfos.push_back(RecombinationInfo(worseHypo.GetWordsBitmap().GetNumWordsCovered(),
betterHypo.GetTotalScore(), worseHypo.GetTotalScore()));
betterHypo.GetFutureScore(), worseHypo.GetFutureScore()));
}
void AddCreated() {
m_numHyposCreated++;

View File

@ -45,11 +45,11 @@ void SquareMatrix::InitTriangle(float val)
* /param bitmap coverage bitmap
*/
float SquareMatrix::CalcFutureScore( Bitmap const &bitmap ) const
float SquareMatrix::CalcEstimatedScore( Bitmap const &bitmap ) const
{
const size_t notInGap= numeric_limits<size_t>::max();
size_t startGap = notInGap;
float futureScore = 0.0f;
float estimatedScore = 0.0f;
for(size_t currPos = 0 ; currPos < bitmap.GetSize() ; currPos++) {
// start of a new gap?
if(bitmap.GetValue(currPos) == false && startGap == notInGap) {
@ -57,16 +57,16 @@ float SquareMatrix::CalcFutureScore( Bitmap const &bitmap ) const
}
// end of a gap?
else if(bitmap.GetValue(currPos) == true && startGap != notInGap) {
futureScore += GetScore(startGap, currPos - 1);
estimatedScore += GetScore(startGap, currPos - 1);
startGap = notInGap;
}
}
// coverage ending with gap?
if (startGap != notInGap) {
futureScore += GetScore(startGap, bitmap.GetSize() - 1);
estimatedScore += GetScore(startGap, bitmap.GetSize() - 1);
}
return futureScore;
return estimatedScore;
}
/**
@ -84,12 +84,12 @@ float SquareMatrix::CalcFutureScore( Bitmap const &bitmap ) const
* /param endPos end of the span that is added to the coverage
*/
float SquareMatrix::CalcFutureScore2( Bitmap const &bitmap, size_t startPos, size_t endPos ) const
float SquareMatrix::CalcEstimatedScore( Bitmap const &bitmap, size_t startPos, size_t endPos ) const
{
const size_t notInGap= numeric_limits<size_t>::max();
float futureScore = 0.0f;
float estimatedScore = 0.0f;
size_t startGap = bitmap.GetFirstGapPos();
if (startGap == NOT_FOUND) return futureScore; // everything filled
if (startGap == NOT_FOUND) return estimatedScore; // everything filled
// start loop at first gap
size_t startLoop = startGap+1;
@ -108,16 +108,16 @@ float SquareMatrix::CalcFutureScore2( Bitmap const &bitmap, size_t startPos, siz
}
// end of a gap?
else if(startGap != notInGap && (bitmap.GetValue(currPos) == true || (startPos <= currPos && currPos <= endPos))) {
futureScore += GetScore(startGap, currPos - 1);
estimatedScore += GetScore(startGap, currPos - 1);
startGap = notInGap;
}
}
// coverage ending with gap?
if (lastCovered != bitmap.GetSize() - 1) {
futureScore += GetScore(lastCovered+1, bitmap.GetSize() - 1);
estimatedScore += GetScore(lastCovered+1, bitmap.GetSize() - 1);
}
return futureScore;
return estimatedScore;
}
TO_STRING_BODY(SquareMatrix);

View File

@ -65,8 +65,8 @@ public:
inline void SetScore(size_t startPos, size_t endPos, float value) {
m_array[startPos * m_size + endPos] = value;
}
float CalcFutureScore( Bitmap const& ) const;
float CalcFutureScore2( Bitmap const&, size_t startPos, size_t endPos ) const;
float CalcEstimatedScore( Bitmap const& ) const;
float CalcEstimatedScore( Bitmap const&, size_t startPos, size_t endPos ) const;
TO_STRING();
};

View File

@ -34,7 +34,7 @@ PhraseDictionaryGroup::PhraseDictionaryGroup(const string &line)
: PhraseDictionary(line, true),
m_numModels(0),
m_restrict(false),
m_specifiedZeros(false)
m_haveDefaultScores(false)
{
ReadParameters();
}
@ -46,9 +46,9 @@ void PhraseDictionaryGroup::SetParameter(const string& key, const string& value)
m_numModels = m_memberPDStrs.size();
} else if (key == "restrict") {
m_restrict = Scan<bool>(value);
} else if (key == "zeros") {
m_specifiedZeros = true;
m_zeros = Scan<float>(Tokenize(value, ","));
} else if (key =="default-scores") {
m_haveDefaultScores = true;
m_defaultScores = Scan<float>(Tokenize(value, ","));
} else {
PhraseDictionary::SetParameter(key, value);
}
@ -77,13 +77,13 @@ void PhraseDictionaryGroup::Load()
"Total number of member model scores is unequal to specified number of scores");
// Determine "zero" scores for features
if (m_specifiedZeros) {
UTIL_THROW_IF2(m_zeros.size() != m_numScoreComponents,
"Number of specified zeros is unequal to number of member model scores");
if (m_haveDefaultScores) {
UTIL_THROW_IF2(m_defaultScores.size() != m_numScoreComponents,
"Number of specified default scores is unequal to number of member model scores");
} else {
// Default is all 0 (as opposed to e.g. -99 or similar to approximate log(0)
// or a smoothed "not in model" score)
m_zeros = vector<float>(m_numScoreComponents, 0);
m_defaultScores = vector<float>(m_numScoreComponents, 0);
}
}
@ -172,7 +172,7 @@ CreateTargetPhraseCollection(const ttasksptr& ttask, const Phrase& src) const
phrase->GetScoreBreakdown().ZeroDenseFeatures(&pd);
// Add phrase entry
allPhrases.push_back(phrase);
allScores[targetPhrase] = make_pair(phrase, vector<float>(m_zeros));
allScores[targetPhrase] = make_pair(phrase, vector<float>(m_defaultScores));
} else {
// For existing phrases: merge extra scores (such as lr-func scores for mmsapt)
TargetPhrase* phrase = iter->second.first;

View File

@ -68,8 +68,8 @@ protected:
std::vector<PhraseDictionary*> m_memberPDs;
size_t m_numModels;
bool m_restrict;
bool m_specifiedZeros;
std::vector<float> m_zeros;
bool m_haveDefaultScores;
std::vector<float> m_defaultScores;
std::vector<FeatureFunction*> m_pdFeature;
typedef std::vector<TargetPhraseCollection::shared_ptr > PhraseCache;

View File

@ -70,7 +70,7 @@ QueryEngine::QueryEngine(const char * filepath) : decoder(filepath)
binary_mmaped = read_binary_file(path_to_data_bin.c_str(), binary_filesize);
//Read hashtable
size_t table_filesize = Table::Size(tablesize, 1.2);
table_filesize = Table::Size(tablesize, 1.2);
mem = readTable(path_to_hashtable.c_str(), table_filesize);
Table table_init(mem, table_filesize);
table = table_init;

View File

@ -62,7 +62,7 @@ TranslationOptionCollection(ttasksptr const& ttask,
float translationOptionThreshold)
: m_ttask(ttask)
, m_source(src)
, m_futureScore(src.GetSize())
, m_estimatedScores(src.GetSize())
, m_maxNoTransOptPerCoverage(maxNoTransOptPerCoverage)
, m_translationOptionThreshold(translationOptionThreshold)
{
@ -254,10 +254,10 @@ ProcessOneUnknownWord(const InputPath &inputPath, size_t sourcePos,
*/
void
TranslationOptionCollection::
CalcFutureScore()
CalcEstimatedScore()
{
// setup the matrix (ignore lower triangle, set upper triangle to -inf
m_futureScore.InitTriangle(-numeric_limits<float>::infinity());
m_estimatedScores.InitTriangle(-numeric_limits<float>::infinity());
// walk all the translation options and record the cheapest option for each span
size_t size = m_source.GetSize(); // the width of the matrix
@ -268,8 +268,8 @@ CalcFutureScore()
for(toi = tol.begin() ; toi != tol.end() ; ++toi) {
const TranslationOption& to = **toi;
float score = to.GetFutureScore();
if (score > m_futureScore.GetScore(sPos, ePos))
m_futureScore.SetScore(sPos, ePos, score);
if (score > m_estimatedScores.GetScore(sPos, ePos))
m_estimatedScores.SetScore(sPos, ePos, score);
}
++ePos;
}
@ -287,8 +287,8 @@ CalcFutureScore()
size_t sPos = diagshift;
size_t ePos = colstart+diagshift;
for(size_t joinAt = sPos; joinAt < ePos ; joinAt++) {
float joinedScore = m_futureScore.GetScore(sPos, joinAt)
+ m_futureScore.GetScore(joinAt+1, ePos);
float joinedScore = m_estimatedScores.GetScore(sPos, joinAt)
+ m_estimatedScores.GetScore(joinAt+1, ePos);
// uncomment to see the cell filling scheme
// TRACE_ERR("[" << sPos << "," << ePos << "] <-? ["
// << sPos << "," << joinAt << "]+["
@ -296,8 +296,8 @@ CalcFutureScore()
// << colstart << ", diagshift: " << diagshift << ")"
// << endl);
if (joinedScore > m_futureScore.GetScore(sPos, ePos))
m_futureScore.SetScore(sPos, ePos, joinedScore);
if (joinedScore > m_estimatedScores.GetScore(sPos, ePos))
m_estimatedScores.SetScore(sPos, ePos, joinedScore);
}
}
}
@ -325,7 +325,7 @@ CalcFutureScore()
for(size_t row=0; row<size; row++)
for(size_t col=row; col<size; col++)
TRACE_ERR( "future cost from "<< row <<" to "<< col <<" is "
<< m_futureScore.GetScore(row, col) <<endl);
<< m_estimatedScores.GetScore(row, col) <<endl);
}
}
@ -380,7 +380,7 @@ CreateTranslationOptions()
VERBOSE(3,"Translation Option Collection\n " << *this << endl);
Prune();
Sort();
CalcFutureScore(); // future score matrix
CalcEstimatedScore(); // future score matrix
CacheLexReordering(); // Cached lex reodering costs
}

View File

@ -68,7 +68,7 @@ protected:
ttaskwptr m_ttask; // that is and must be a weak pointer!
std::vector< std::vector< TranslationOptionList > > m_collection; /*< contains translation options */
InputType const &m_source; /*< reference to the input */
SquareMatrix m_futureScore; /*< matrix of future costs for contiguous parts (span) of the input */
SquareMatrix m_estimatedScores; /*< matrix of future costs for contiguous parts (span) of the input */
const size_t m_maxNoTransOptPerCoverage; /*< maximum number of translation options per input span */
const float m_translationOptionThreshold; /*< threshold for translation options with regard to best option for input span */
std::vector<const Phrase*> m_unksrcs;
@ -78,7 +78,7 @@ protected:
InputType const& src, size_t maxNoTransOptPerCoverage,
float translationOptionThreshold);
void CalcFutureScore();
void CalcEstimatedScore();
//! Force a creation of a translation option where there are none for a particular source position.
void ProcessUnknownWord();
@ -163,8 +163,8 @@ public:
//! returns future cost matrix for sentence
inline virtual const SquareMatrix &GetFutureScore() const {
return m_futureScore;
inline virtual const SquareMatrix &GetEstimatedScores() const {
return m_estimatedScores;
}
//! list of trans opt for a particular span

View File

@ -168,7 +168,7 @@ void TranslationOptionCollectionLattice::CreateTranslationOptions()
Sort();
// future score matrix
CalcFutureScore();
CalcEstimatedScore();
// Cached lex reodering costs
CacheLexReordering();

View File

@ -31,7 +31,7 @@ namespace Moses
TrellisPath::TrellisPath(const Hypothesis *hypo)
: m_prevEdgeChanged(NOT_FOUND)
{
m_totalScore = hypo->GetTotalScore();
m_totalScore = hypo->GetFutureScore();
// enumerate path using prevHypo
while (hypo != NULL) {
@ -42,7 +42,7 @@ TrellisPath::TrellisPath(const Hypothesis *hypo)
void TrellisPath::InitTotalScore()
{
m_totalScore = m_path[0]->GetWinningHypo()->GetTotalScore();
m_totalScore = m_path[0]->GetWinningHypo()->GetFutureScore();
//calc score
size_t sizePath = m_path.size();
@ -50,7 +50,7 @@ void TrellisPath::InitTotalScore()
const Hypothesis *hypo = m_path[pos];
const Hypothesis *winningHypo = hypo->GetWinningHypo();
if (hypo != winningHypo) {
m_totalScore = m_totalScore - winningHypo->GetTotalScore() + hypo->GetTotalScore();
m_totalScore = m_totalScore - winningHypo->GetFutureScore() + hypo->GetFutureScore();
}
}
}
@ -167,7 +167,7 @@ void TrellisPath::CreateDeviantPaths(TrellisPathList &pathColl) const
const boost::shared_ptr<ScoreComponentCollection> TrellisPath::GetScoreBreakdown() const
{
if (!m_scoreBreakdown) {
float totalScore = m_path[0]->GetWinningHypo()->GetTotalScore(); // calculated for sanity check only
float totalScore = m_path[0]->GetWinningHypo()->GetFutureScore(); // calculated for sanity check only
m_scoreBreakdown = boost::shared_ptr<ScoreComponentCollection>(new ScoreComponentCollection());
m_scoreBreakdown->PlusEquals(ScoreComponentCollection(m_path[0]->GetWinningHypo()->GetScoreBreakdown()));
@ -178,7 +178,7 @@ const boost::shared_ptr<ScoreComponentCollection> TrellisPath::GetScoreBreakdown
const Hypothesis *hypo = m_path[pos];
const Hypothesis *winningHypo = hypo->GetWinningHypo();
if (hypo != winningHypo) {
totalScore = totalScore - winningHypo->GetTotalScore() + hypo->GetTotalScore();
totalScore = totalScore - winningHypo->GetFutureScore() + hypo->GetFutureScore();
m_scoreBreakdown->MinusEquals(winningHypo->GetScoreBreakdown());
m_scoreBreakdown->PlusEquals(hypo->GetScoreBreakdown());
}

View File

@ -70,7 +70,7 @@ public:
TrellisPath(const TrellisPath &copy, size_t edgeIndex, const Hypothesis *arc);
//! get score for this path throught trellis
inline float GetTotalScore() const {
inline float GetFutureScore() const {
return m_totalScore;
}
@ -113,7 +113,7 @@ inline std::ostream& operator<<(std::ostream& out, const TrellisPath& path)
out << edge->GetId() << " " << sourceRange.GetStartPos() << "-" << sourceRange.GetEndPos() << ", ";
}
// scores
out << " total=" << path.GetTotalScore()
out << " total=" << path.GetFutureScore()
<< " " << path.GetScoreBreakdown()
<< std::endl;

View File

@ -31,7 +31,7 @@ namespace Moses
struct CompareTrellisPathCollection {
bool operator()(const TrellisPath* pathA, const TrellisPath* pathB) const {
return (pathA->GetTotalScore() > pathB->GetTotalScore());
return (pathA->GetFutureScore() > pathB->GetFutureScore());
}
};

View File

@ -205,7 +205,7 @@ outputNBest(const Manager& manager, map<string, xmlrpc_c::value>& retData)
}
// weighted score
nBestXmlItem["totalScore"] = xmlrpc_c::value_double(path->GetTotalScore());
nBestXmlItem["totalScore"] = xmlrpc_c::value_double(path->GetFutureScore());
nBestXml.push_back(xmlrpc_c::value_struct(nBestXmlItem));
}
retData["nbest"] = xmlrpc_c::value_array(nBestXml);