forked from organicmaps/organicmaps
[search] Multiple TokenRanges in PreRankingInfo.
This commit is contained in:
parent
ff4b04d361
commit
3e76f806c6
7 changed files with 31 additions and 17 deletions
|
@ -1264,11 +1264,7 @@ void Geocoder::EmitResult(BaseContext const & ctx, MwmSet::MwmId const & mwmId,
|
|||
// TODO (@y, @m): need to skip zero rank features that are too
|
||||
// distant from the pivot when there're enough results close to the
|
||||
// pivot.
|
||||
PreRankingInfo info;
|
||||
info.m_searchType = type;
|
||||
info.m_tokenRange = tokenRange;
|
||||
|
||||
m_preRanker.Emplace(id, info);
|
||||
m_preRanker.Emplace(id, PreRankingInfo(type, tokenRange));
|
||||
}
|
||||
|
||||
void Geocoder::EmitResult(BaseContext const & ctx, Region const & region,
|
||||
|
|
|
@ -42,7 +42,7 @@ struct ComparePreResult1
|
|||
auto const & rinfo = rhs.GetInfo();
|
||||
if (linfo.GetNumTokens() != rinfo.GetNumTokens())
|
||||
return linfo.GetNumTokens() > rinfo.GetNumTokens();
|
||||
return linfo.m_tokenRange.Begin() < rinfo.m_tokenRange.Begin();
|
||||
return linfo.InnermostTokenRange().Begin() < rinfo.InnermostTokenRange().Begin();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -9,7 +9,14 @@ string DebugPrint(PreRankingInfo const & info)
|
|||
ostringstream os;
|
||||
os << "PreRankingInfo [";
|
||||
os << "m_distanceToPivot:" << info.m_distanceToPivot << ",";
|
||||
os << "m_tokenRange:" << DebugPrint(info.m_tokenRange) << ",";
|
||||
for (size_t i = 0; i < static_cast<size_t>(SearchModel::SEARCH_TYPE_COUNT); ++i)
|
||||
{
|
||||
if (info.m_tokenRange[i].Empty())
|
||||
continue;
|
||||
|
||||
auto const type = static_cast<SearchModel::SearchType>(i);
|
||||
os << "m_tokenRange[" << DebugPrint(type) << "]:" << DebugPrint(info.m_tokenRange[i]) << ",";
|
||||
}
|
||||
os << "m_rank:" << info.m_rank << ",";
|
||||
os << "m_searchType:" << info.m_searchType;
|
||||
os << "]";
|
||||
|
|
|
@ -5,13 +5,28 @@
|
|||
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
#include "std/cstdint.hpp"
|
||||
|
||||
namespace search
|
||||
{
|
||||
struct PreRankingInfo
|
||||
{
|
||||
inline size_t GetNumTokens() const { return m_tokenRange.Size(); }
|
||||
PreRankingInfo(SearchModel::SearchType type, TokenRange const & range)
|
||||
{
|
||||
ASSERT_LESS(type, SearchModel::SEARCH_TYPE_COUNT, ());
|
||||
m_searchType = type;
|
||||
m_tokenRange[m_searchType] = range;
|
||||
}
|
||||
|
||||
inline TokenRange const & InnermostTokenRange() const
|
||||
{
|
||||
ASSERT_LESS(m_searchType, SearchModel::SEARCH_TYPE_COUNT, ());
|
||||
return m_tokenRange[m_searchType];
|
||||
}
|
||||
|
||||
inline size_t GetNumTokens() const { return InnermostTokenRange().Size(); }
|
||||
|
||||
// An abstract distance from the feature to the pivot. Measurement
|
||||
// units do not matter here.
|
||||
|
@ -21,7 +36,7 @@ struct PreRankingInfo
|
|||
bool m_centerLoaded = false;
|
||||
|
||||
// Tokens match to the feature name or house number.
|
||||
TokenRange m_tokenRange;
|
||||
TokenRange m_tokenRange[SearchModel::SEARCH_TYPE_COUNT];
|
||||
|
||||
// Rank of the feature.
|
||||
uint8_t m_rank = 0;
|
||||
|
|
|
@ -179,8 +179,8 @@ class PreResult2Maker
|
|||
info.m_searchType = preInfo.m_searchType;
|
||||
info.m_nameScore = NAME_SCORE_ZERO;
|
||||
|
||||
TokenSlice slice(m_params, preInfo.m_tokenRange);
|
||||
TokenSliceNoCategories sliceNoCategories(m_params, preInfo.m_tokenRange);
|
||||
TokenSlice slice(m_params, preInfo.InnermostTokenRange());
|
||||
TokenSliceNoCategories sliceNoCategories(m_params, preInfo.InnermostTokenRange());
|
||||
|
||||
for (auto const & lang : m_params.GetLangs())
|
||||
{
|
||||
|
|
|
@ -131,11 +131,7 @@ UNIT_CLASS_TEST(PreRankerTest, Smoke)
|
|||
FeaturesVectorTest fv(mwmId.GetInfo()->GetLocalFile().GetPath(MapOptions::Map));
|
||||
fv.GetVector().ForEach([&](FeatureType & ft, uint32_t index) {
|
||||
FeatureID id(mwmId, index);
|
||||
|
||||
PreRankingInfo info;
|
||||
info.m_tokenRange = TokenRange(0, 1);
|
||||
info.m_searchType = SearchModel::SEARCH_TYPE_POI;
|
||||
preRanker.Emplace(id, info);
|
||||
preRanker.Emplace(id, PreRankingInfo(SearchModel::SEARCH_TYPE_POI, TokenRange(0, 1)));
|
||||
|
||||
TEST_LESS(index, pois.size(), ());
|
||||
distances[index] = MercatorBounds::DistanceOnEarth(feature::GetCenter(ft), kPivot);
|
||||
|
|
|
@ -78,7 +78,7 @@ private:
|
|||
inline std::string DebugPrint(TokenRange const & tokenRange)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "TokenRange [" << tokenRange.m_begin << ", " << tokenRange.m_end << ")";
|
||||
os << "TokenRange [" << tokenRange.Begin() << ", " << tokenRange.End() << ")";
|
||||
return os.str();
|
||||
}
|
||||
} // namespace search
|
||||
|
|
Loading…
Add table
Reference in a new issue