void TranslationOption::CalcScore(const TranslationSystem* system) { // LM scores float ngramScore = 0; float retFullScore = 0; float oovScore = 0; const LMList &allLM = system->GetLanguageModels(); allLM.CalcScore(GetTargetPhrase(), retFullScore, ngramScore, oovScore, &m_scoreBreakdown); size_t phraseSize = GetTargetPhrase().GetSize(); /* // future score if (m_osmScore == 0 && GetTargetPhrase().GetWord(0).GetFactor(1) != NULL) // Getting OSM - Future cost for the unknown word ... { CalcOSMFutureScore(system, m_targetPhrase, m_targetPhrase.GetSourcePhrase()); } m_futureScore = retFullScore - ngramScore + oovScore + m_scoreBreakdown.InnerProduct(StaticData::Instance().GetAllWeights()) - phraseSize * system->GetWeightWordPenalty() + m_osmScore; */ m_futureScore = retFullScore - ngramScore + oovScore + m_scoreBreakdown.InnerProduct(StaticData::Instance().GetAllWeights()) - phraseSize * system->GetWeightWordPenalty(); //cerr<<"Yahan "<<GetSourcePhrase()->GetWord(0)<<" "<<GetTargetPhrase().GetWord(0).GetFactor(1)<<" "<<m_osmScore<<endl; }
void TranslationOption::CalcScore() { // LM scores float ngramScore = 0; float retFullScore = 0; const LMList &allLM = StaticData::Instance().GetAllLM(); allLM.CalcScore(GetTargetPhrase(), retFullScore, ngramScore, &m_scoreBreakdown); size_t phraseSize = GetTargetPhrase().GetSize(); // future score m_futureScore = retFullScore - ngramScore + m_scoreBreakdown.InnerProduct(StaticData::Instance().GetAllWeights()) - phraseSize * StaticData::Instance().GetWeightWordPenalty(); }
Phrase TrellisPath::GetSurfacePhrase() const { const std::vector<FactorType> &outputFactor = StaticData::Instance().GetOutputFactorOrder(); Phrase targetPhrase = GetTargetPhrase() ,ret(targetPhrase.GetSize()); for (size_t pos = 0 ; pos < targetPhrase.GetSize() ; ++pos) { Word &newWord = ret.AddWord(); for (size_t i = 0 ; i < outputFactor.size() ; i++) { FactorType factorType = outputFactor[i]; const Factor *factor = targetPhrase.GetFactor(pos, factorType); CHECK(factor); newWord[factorType] = factor; } } return ret; }
Phrase TrellisPath::GetSurfacePhrase() const { std::vector<FactorType> const& oFactor = manager().options()->output.factor_order; Phrase targetPhrase = GetTargetPhrase(); Phrase ret(targetPhrase.GetSize()); for (size_t pos = 0 ; pos < targetPhrase.GetSize() ; ++pos) { Word &newWord = ret.AddWord(); for (size_t i = 0 ; i < oFactor.size() ; i++) { FactorType factorType = oFactor[i]; const Factor *factor = targetPhrase.GetFactor(pos, factorType); UTIL_THROW_IF2(factor == NULL, "No factor " << factorType << " at position " << pos); newWord[factorType] = factor; } } return ret; }