[geocoder] Refactor for code review
This commit is contained in:
parent
c572f3e57e
commit
1d343ab5f4
2 changed files with 6 additions and 12 deletions
|
@ -150,13 +150,6 @@ strings::UniString MakeHouseNumber(Tokens const & tokens)
|
||||||
{
|
{
|
||||||
return strings::MakeUniString(strings::JoinStrings(tokens, " "));
|
return strings::MakeUniString(strings::JoinStrings(tokens, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
strings::UniString & AppendToHouseNumber(strings::UniString & houseNumber, std::string const & token)
|
|
||||||
{
|
|
||||||
houseNumber += strings::MakeUniString(" ");
|
|
||||||
houseNumber += strings::MakeUniString(token);
|
|
||||||
return houseNumber;
|
|
||||||
}
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Geocoder::Layer ---------------------------------------------------------------------------------
|
// Geocoder::Layer ---------------------------------------------------------------------------------
|
||||||
|
@ -522,7 +515,7 @@ void Geocoder::FillBuildingsLayer(
|
||||||
if (!parentCandidateCertainty)
|
if (!parentCandidateCertainty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto totalCertainty =
|
auto const totalCertainty =
|
||||||
*parentCandidateCertainty + SumHouseNumberSubqueryCertainty(matchResult);
|
*parentCandidateCertainty + SumHouseNumberSubqueryCertainty(matchResult);
|
||||||
auto const isOtherSimilar =
|
auto const isOtherSimilar =
|
||||||
matchResult.queryMismatchedTokensCount || matchResult.houseNumberMismatchedTokensCount;
|
matchResult.queryMismatchedTokensCount || matchResult.houseNumberMismatchedTokensCount;
|
||||||
|
@ -554,9 +547,9 @@ void Geocoder::FillRegularLayer(Context const & ctx, Type type, Tokens const & s
|
||||||
if (type > Type::Locality && !IsRelevantLocalityMember(ctx, d, subquery))
|
if (type > Type::Locality && !IsRelevantLocalityMember(ctx, d, subquery))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto subqueryWeight =
|
auto const subqueryWeight =
|
||||||
(d.m_kind != Kind::Unknown ? GetWeight(d.m_kind) : GetWeight(d.m_type)) * subquery.size();
|
(d.m_kind != Kind::Unknown ? GetWeight(d.m_kind) : GetWeight(d.m_type)) * subquery.size();
|
||||||
auto totalCertainty = *parentCandidateCertainty + subqueryWeight;
|
auto const totalCertainty = *parentCandidateCertainty + subqueryWeight;
|
||||||
|
|
||||||
candidates.push_back({docId, totalCertainty, false /* m_isOtherSimilar */});
|
candidates.push_back({docId, totalCertainty, false /* m_isOtherSimilar */});
|
||||||
});
|
});
|
||||||
|
@ -608,7 +601,8 @@ bool Geocoder::IsValidHouseNumberWithNextUnusedToken(
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto subqueryHouseNumber = MakeHouseNumber(subquery);
|
auto subqueryHouseNumber = MakeHouseNumber(subquery);
|
||||||
AppendToHouseNumber(subqueryHouseNumber, ctx.GetToken(nextTokenPos));
|
subqueryHouseNumber += strings::MakeUniString(" ");
|
||||||
|
subqueryHouseNumber += strings::MakeUniString(ctx.GetToken(nextTokenPos));
|
||||||
|
|
||||||
return search::house_numbers::LooksLikeHouseNumber(subqueryHouseNumber, false /* isPrefix */);
|
return search::house_numbers::LooksLikeHouseNumber(subqueryHouseNumber, false /* isPrefix */);
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,7 +536,7 @@ bool HouseNumbersMatch(strings::UniString const & houseNumber, strings::UniStrin
|
||||||
|
|
||||||
bool HouseNumbersMatch(strings::UniString const & houseNumber, vector<Token> const & queryParse)
|
bool HouseNumbersMatch(strings::UniString const & houseNumber, vector<Token> const & queryParse)
|
||||||
{
|
{
|
||||||
auto && matchResult = MatchResult{};
|
MatchResult matchResult{};
|
||||||
return HouseNumbersMatch(houseNumber, queryParse, matchResult);
|
return HouseNumbersMatch(houseNumber, queryParse, matchResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue