[search] Fix feature names scoring for results.

This commit is contained in:
vng 2011-12-14 21:27:11 +03:00 committed by Alex Zolotarev
parent 57c034f104
commit c96b27fb33

View file

@ -31,12 +31,16 @@ uint32_t LangKeywordsScorer::Score(int8_t lang,
strings::UniString const * tokens, int tokenCount) const
{
uint32_t const keywordScore = m_keywordMatcher.Score(tokens, tokenCount);
if (keywordScore == KeywordMatcher::MAX_SCORE)
return MAX_SCORE; // TODO: Differentiate between langs with MAX_SCORE score.
for (uint32_t i = 0; i < NUM_LANG_PRIORITY_TIERS; ++i)
for (uint32_t j = 0; j < m_languagePriorities[i].size(); ++j)
if (m_languagePriorities[i][j] == lang)
return i * KeywordMatcher::MAX_SCORE * (MAX_LANGS_IN_TIER + 1)
+ keywordScore * (MAX_LANGS_IN_TIER + 1)
+ min(j, static_cast<uint32_t>(MAX_LANGS_IN_TIER));
return NUM_LANG_PRIORITY_TIERS * KeywordMatcher::MAX_SCORE * (MAX_LANGS_IN_TIER + 1)
+ keywordScore * (MAX_LANGS_IN_TIER + 1);
}