diff options
author | Maxim Pimenov <m@maps.me> | 2016-05-31 13:26:03 +0300 |
---|---|---|
committer | Maxim Pimenov <m@maps.me> | 2016-06-07 12:14:54 +0300 |
commit | 90fe2ee57bc6ad49c5ff65b7412f88e5e5f5fca5 (patch) | |
tree | 6cb6d4a2f4047ee051c0a56fba90794103e6d6eb /search/geocoder.cpp | |
parent | eeb41dadb89642c8615f949e51476e3d55a9d332 (diff) |
[search] A probabilistic tweak to locality scorer.
Diffstat (limited to 'search/geocoder.cpp')
-rw-r--r-- | search/geocoder.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 0c50de6cc4..f8e3b7c9e6 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -694,9 +694,14 @@ void Geocoder::FillLocalityCandidates(coding::CompressedBitVector const * filter for (size_t startToken = 0; startToken < m_numTokens; ++startToken) { CBVPtr intersection; + CBVPtr unfilteredIntersection; intersection.SetFull(); + unfilteredIntersection.SetFull(); if (filter) + { intersection.Intersect(filter); + unfilteredIntersection.Intersect(m_addressFeatures[startToken].get()); + } intersection.Intersect(m_addressFeatures[startToken].get()); if (intersection.IsEmpty()) continue; @@ -713,6 +718,11 @@ void Geocoder::FillLocalityCandidates(coding::CompressedBitVector const * filter l.m_featureId = featureId; l.m_startToken = startToken; l.m_endToken = endToken; + if (filter) + { + l.m_prob = static_cast<double>(intersection->PopCount()) / + static_cast<double>(unfilteredIntersection->PopCount()); + } preLocalities.push_back(l); }); } @@ -720,6 +730,8 @@ void Geocoder::FillLocalityCandidates(coding::CompressedBitVector const * filter if (endToken < m_numTokens) { intersection.Intersect(m_addressFeatures[endToken].get()); + if (filter) + unfilteredIntersection.Intersect(m_addressFeatures[endToken].get()); if (intersection.IsEmpty()) break; } @@ -829,7 +841,7 @@ void Geocoder::FillVillageLocalities() #if defined(DEBUG) ft.GetName(StringUtf8Multilang::kDefaultCode, village.m_defaultName); - LOG(LDEBUG, ("Village =", village.m_defaultName)); + LOG(LDEBUG, ("Village =", village.m_defaultName, "prob =", village.m_prob)); #endif m_cities[{l.m_startToken, l.m_endToken}].push_back(village); |