forked from organicmaps/organicmaps
[search] Tweak LangKeywordsScorer to differentiate between languages in one tier.
This commit is contained in:
parent
6038450b70
commit
827edbfb4e
2 changed files with 11 additions and 6 deletions
|
@ -30,12 +30,15 @@ uint32_t LangKeywordsScorer::Score(int8_t lang, strings::UniString const & name)
|
|||
uint32_t LangKeywordsScorer::Score(int8_t lang,
|
||||
strings::UniString const * tokens, int tokenCount) const
|
||||
{
|
||||
uint32_t keywordScore = m_keywordMatcher.Score(tokens, tokenCount);
|
||||
uint32_t const keywordScore = m_keywordMatcher.Score(tokens, tokenCount);
|
||||
for (uint32_t i = 0; i < NUM_LANG_PRIORITY_TIERS; ++i)
|
||||
if (find(m_languagePriorities[i].begin(), m_languagePriorities[i].end(), lang) !=
|
||||
m_languagePriorities[i].end())
|
||||
return i * KeywordMatcher::MAX_SCORE + keywordScore;
|
||||
return NUM_LANG_PRIORITY_TIERS * KeywordMatcher::MAX_SCORE + keywordScore;
|
||||
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, MAX_LANGS_IN_TIER);
|
||||
return NUM_LANG_PRIORITY_TIERS * KeywordMatcher::MAX_SCORE * (MAX_LANGS_IN_TIER + 1)
|
||||
+ keywordScore * (MAX_LANGS_IN_TIER + 1);
|
||||
}
|
||||
|
||||
} // namespace search
|
||||
|
|
|
@ -10,7 +10,9 @@ class LangKeywordsScorer
|
|||
{
|
||||
public:
|
||||
enum { NUM_LANG_PRIORITY_TIERS = 3 };
|
||||
enum { MAX_SCORE = KeywordMatcher::MAX_SCORE * (NUM_LANG_PRIORITY_TIERS + 1) };
|
||||
enum { MAX_LANGS_IN_TIER = 3 };
|
||||
enum { MAX_SCORE = KeywordMatcher::MAX_SCORE
|
||||
* (NUM_LANG_PRIORITY_TIERS + 1) * (MAX_LANGS_IN_TIER + 1) };
|
||||
|
||||
explicit LangKeywordsScorer(vector<vector<int8_t> > const & languagePriorities,
|
||||
strings::UniString const * keywords, size_t keywordCount,
|
||||
|
|
Loading…
Add table
Reference in a new issue