forked from organicmaps/organicmaps
[search] Simple category scoring by minimal prefix to show category name.
This commit is contained in:
parent
4b21f08765
commit
3e09ca0c85
4 changed files with 12 additions and 5 deletions
|
@ -4,7 +4,7 @@ ru:2банкомат|наличка
|
|||
|
||||
amenity-bank
|
||||
en:bank
|
||||
ru:банк
|
||||
ru:1банк
|
||||
|
||||
amenity-bar|amenity-pub
|
||||
en:1bar|pub|beer
|
||||
|
|
|
@ -37,9 +37,9 @@ IntermediateResult::IntermediateResult(m2::RectD const & viewportRect,
|
|||
m_direction = ResultDirection(viewportRect.Center(), m_rect.Center());
|
||||
}
|
||||
|
||||
IntermediateResult::IntermediateResult(string name, string completionString)
|
||||
IntermediateResult::IntermediateResult(string name, string completionString, int penalty)
|
||||
: m_str(name), m_completionString(completionString),
|
||||
m_matchPenalty(0), m_minVisibleScale(0), m_distance(0), m_direction(0),
|
||||
m_matchPenalty(0), m_minVisibleScale(penalty), m_distance(0), m_direction(0),
|
||||
m_resultType(RESULT_CATEGORY)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
IntermediateResult(m2::RectD const & viewportRect, double lat, double lon, double precision);
|
||||
|
||||
// For RESULT_CATEGORY.
|
||||
IntermediateResult(string name, string completionString);
|
||||
IntermediateResult(string name, string completionString, int penalty);
|
||||
|
||||
bool operator < (IntermediateResult const & o) const;
|
||||
|
||||
|
|
|
@ -157,8 +157,15 @@ void Query::Search(function<void (Result const &)> const & f)
|
|||
if (matcher.GetPrefixMatchScore() <= GetMaxPrefixMatchScore(m_prefix.size()) &&
|
||||
matcher.GetMatchScore() <= GetMaxKeywordMatchScore())
|
||||
{
|
||||
int minPrefixMatchLength = 0;
|
||||
for (vector<Category::Name>::const_iterator iName = iCategory->m_synonyms.begin();
|
||||
iName != iCategory->m_synonyms.end(); ++iName)
|
||||
if (iName->m_Name == matcher.GetBestMatchName())
|
||||
minPrefixMatchLength = iName->m_prefixLengthToSuggest;
|
||||
|
||||
AddResult(IntermediateResult(matcher.GetBestMatchName(),
|
||||
matcher.GetBestMatchName() + ' '));
|
||||
matcher.GetBestMatchName() + ' ',
|
||||
minPrefixMatchLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue