std::vector<float> LexicalReordering::CalcScore(Hypothesis* hypothesis) const { std::vector<float> score(GetNumScoreComponents(), 0); std::vector<float> values; //for every direction for(size_t i = 0; i < m_Direction.size(); ++i){ //grab data if(Forward == m_Direction[i]){ //relates to prev hypothesis as we dont know next phrase for current yet //sanity check: is there a previous hypothesis? if(0 == hypothesis->GetPrevHypo()->GetId()){ continue; //no score continue with next direction } //grab probs for prev hypothesis const ScoreComponentCollection &reorderingScoreColl = hypothesis->GetPrevHypo()->GetCachedReorderingScore(); values = reorderingScoreColl.GetScoresForProducer(this); /* values = m_Table->GetScore((hypothesis->GetPrevHypo()->GetSourcePhrase()).GetSubString(hypothesis->GetPrevHypo()->GetCurrSourceWordsRange()), hypothesis->GetPrevHypo()->GetCurrTargetPhrase(), auxGetContext(hypothesis->GetPrevHypo())); */ } if(Backward == m_Direction[i]) { const ScoreComponentCollection &reorderingScoreColl = hypothesis->GetCachedReorderingScore(); values = reorderingScoreColl.GetScoresForProducer(this); /* values = m_Table->GetScore(hypothesis->GetSourcePhrase().GetSubString(hypothesis->GetCurrSourceWordsRange()), hypothesis->GetCurrTargetPhrase(), auxGetContext(hypothesis)); */ } //add score //sanity check: do we have any probs? assert(values.size() == (GetNumOrientationTypes() * m_Direction.size())); OrientationType orientation = GetOrientationType(hypothesis); float value = values[orientation + i * GetNumOrientationTypes()]; if(m_OneScorePerDirection){ //one score per direction score[i] = value; } else { //one score per direction and orientation score[orientation + i * GetNumOrientationTypes()] = value; } } return score; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- QAngle CPathTrack::GetOrientation( bool bForwardDir ) { TrackOrientationType_t eOrient = GetOrientationType(); if ( eOrient == TrackOrientation_FacePathAngles ) { return GetLocalAngles(); } CPathTrack *pPrev = this; CPathTrack *pNext = GetNextInDir( bForwardDir ); if ( !pNext ) { pPrev = GetNextInDir( !bForwardDir ); pNext = this; } Vector vecDir = pNext->GetLocalOrigin() - pPrev->GetLocalOrigin(); QAngle angDir; VectorAngles( vecDir, angDir ); return angDir; }