Consistent naming: m_futureScore --> m_estimatedScore

This commit is contained in:
Hieu Hoang 2015-11-09 13:40:31 +00:00
parent d0be56f8ab
commit 32e29d6b8a
14 changed files with 50 additions and 50 deletions

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)
{
@ -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;
}

View File

@ -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

@ -170,7 +170,7 @@ EvaluateWhenApplied(const StatelessFeatureFunction& slff)
*/
void
Hypothesis::
EvaluateWhenApplied(float futureScore)
EvaluateWhenApplied(float estimatedScore)
{
IFVERBOSE(2) {
m_manager.GetSentenceStats().StartTimeOtherScore();
@ -206,7 +206,7 @@ EvaluateWhenApplied(float futureScore)
}
// FUTURE COST
m_estimatedScore = futureScore;
m_estimatedScore = estimatedScore;
// TOTAL
m_futureScore = m_currScoreBreakdown.GetWeightedScore() + m_estimatedScore;

View File

@ -119,7 +119,7 @@ public:
return m_currTargetWordsRange.GetNumWordsCovered();
}
void EvaluateWhenApplied(float futureScore);
void EvaluateWhenApplied(float estimatedScore);
int GetId()const {
return m_id;

View File

@ -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

@ -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

@ -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

@ -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();