delete last TargetPhrase::SetScore()

This commit is contained in:
Hieu Hoang 2013-05-02 18:36:34 +01:00
parent f46c8d66e2
commit 187e09a5d2
5 changed files with 9 additions and 81 deletions

View File

@ -286,10 +286,10 @@ protected:
}
}
std::vector<float> wpScore(1, -(float)targetPhrase.GetSize());
targetPhrase.SetScore(staticData.GetWordPenaltyProducer(), wpScore);
targetPhrase.SetScore(m_obj, scoreVector, sparseFeatures, weights, weightWP, *m_languageModels);
targetPhrase.SetSourcePhrase(*srcPtr);
targetPhrase.SetScore(m_obj, scoreVector);
targetPhrase.Evaluate();
}
TargetPhraseCollection* PruneTargetCandidates(std::vector<TargetPhrase> const & tCands,

View File

@ -117,61 +117,6 @@ void TargetPhrase::SetInputScore(const Scores &scoreVector)
SetScore(prod, sizedScoreVector);
}
void TargetPhrase::SetScore(const FeatureFunction* translationScoreProducer,
const Scores &scoreVector,
const ScoreComponentCollection &sparseScoreVector,
const vector<float> &weightT,
float weightWP, const LMList &languageModels)
{
const StaticData &staticData = StaticData::Instance();
CHECK(weightT.size() == scoreVector.size());
// calc average score if non-best
m_scoreBreakdown.PlusEquals(translationScoreProducer, scoreVector);
m_scoreBreakdown.PlusEquals(sparseScoreVector);
float transScore = m_scoreBreakdown.GetWeightedScore();
// Replicated from TranslationOptions.cpp
float totalNgramScore = 0;
float totalFullScore = 0;
float totalOOVScore = 0;
LMList::const_iterator lmIter;
for (lmIter = languageModels.begin(); lmIter != languageModels.end(); ++lmIter) {
const LanguageModel &lm = **lmIter;
if (lm.Useable(*this)) {
// contains factors used by this LM
const float weightLM = lm.GetWeight();
const float oovWeightLM = lm.GetOOVWeight();
float fullScore, nGramScore;
size_t oovCount;
lm.CalcScore(*this, fullScore, nGramScore, oovCount);
if (StaticData::Instance().GetLMEnableOOVFeature()) {
vector<float> scores(2);
scores[0] = nGramScore;
scores[1] = oovCount;
m_scoreBreakdown.Assign(&lm, scores);
totalOOVScore += oovCount * oovWeightLM;
} else {
m_scoreBreakdown.Assign(&lm, nGramScore);
}
// total LM score so far
totalNgramScore += nGramScore * weightLM;
totalFullScore += fullScore * weightLM;
}
}
m_fullScore = transScore + totalFullScore + totalOOVScore;
}
// used to set translation or gen score
void TargetPhrase::SetScore(const FeatureFunction* producer, const Scores &scoreVector)
{

View File

@ -63,25 +63,6 @@ public:
void Evaluate();
/*** Called immediately after creation to initialize scores.
*
* @param translationScoreProducer The PhraseDictionaryMemory that this TargetPhrase is contained by.
* Used to identify where the scores for this phrase belong in the list of all scores.
* @param scoreVector the vector of scores (log probs) associated with this translation
* @param weighT the weights for the individual scores (t-weights in the .ini file)
* @param languageModels all the LanguageModels that should be used to compute the LM scores
* @param weightWP the weight of the word penalty
*
* @TODO should this be part of the constructor? If not, add explanation why not.
*/
void SetScore(const FeatureFunction* translationScoreProducer,
const Scores &scoreVector,
const ScoreComponentCollection &sparseScoreVector,
const std::vector<float> &weightT,
float weightWP,
const LMList &languageModels);
void SetSparseScore(const FeatureFunction* translationScoreProducer, const StringPiece &sparseString);
// used to set translation or gen score

View File

@ -439,9 +439,8 @@ TargetPhraseVectorPtr PhraseDecoder::DecodeCollection(
if(scores.size() == m_numScoreComponent)
{
std::vector<float> wp(1, -targetPhrase->GetSize());
targetPhrase->SetScore(StaticData::Instance().GetWordPenaltyProducer(), wp);
targetPhrase->SetScore(&m_phraseDictionary, scores, ScoreComponentCollection() /*sparse*/,*m_weight, m_weightWP, *m_languageModels);
targetPhrase->SetScore(&m_phraseDictionary, scores);
targetPhrase->Evaluate();
if(m_containsAlignmentInfo)
state = Alignment;

View File

@ -51,7 +51,10 @@ const TargetPhraseCollection *PhraseDictionaryDynSuffixArray::GetTargetPhraseCol
TargetPhrase *targetPhrase = itr->second;
//std::transform(scoreVector.begin(),scoreVector.end(),scoreVector.begin(),NegateScore);
std::transform(scoreVector.begin(),scoreVector.end(),scoreVector.begin(),FloorScore);
targetPhrase->SetScore(this, scoreVector, ScoreComponentCollection(), m_weight, m_weightWP, *m_languageModels);
targetPhrase->SetScore(this, scoreVector);
targetPhrase->Evaluate();
//cout << *targetPhrase << "\t" << std::setprecision(8) << scoreVector[2] << endl;
ret->Add(targetPhrase);
}