forked from organicmaps/organicmaps
[geocoder] Fix search of street with number and street synonym together
This commit is contained in:
parent
c11c41d677
commit
51bf87efa7
2 changed files with 44 additions and 3 deletions
|
@ -18,6 +18,8 @@
|
|||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace
|
||||
|
@ -268,15 +270,18 @@ void Geocoder::Go(Context & ctx, Type type) const
|
|||
continue;
|
||||
|
||||
ScopedMarkTokens mark(ctx, type, i, j + 1);
|
||||
boost::optional<ScopedMarkTokens> streetSynonymMark;
|
||||
|
||||
double certainty = 0;
|
||||
vector<Type> allTypes;
|
||||
for (size_t tokId = 0; tokId < ctx.GetNumTokens(); ++tokId)
|
||||
{
|
||||
auto const t = ctx.GetTokenType(tokId);
|
||||
|
||||
if (t == Type::Street && search::IsStreetSynonym(strings::MakeUniString(ctx.GetToken(tokId))))
|
||||
continue;
|
||||
if (type == Type::Street && t == Type::Count && !streetSynonymMark)
|
||||
{
|
||||
if (search::IsStreetSynonym(strings::MakeUniString(ctx.GetToken(tokId))))
|
||||
streetSynonymMark.emplace(ctx, Type::Street, tokId, tokId + 1);
|
||||
}
|
||||
|
||||
certainty += GetWeight(t);
|
||||
if (t != Type::Count)
|
||||
|
|
|
@ -153,6 +153,42 @@ UNIT_TEST(Geocoder_MismatchedLocality)
|
|||
TestGeocoder(geocoder, "Moscow Krymskaya 3", {});
|
||||
}
|
||||
|
||||
UNIT_TEST(Geocoder_StreetWithNumber)
|
||||
{
|
||||
string const kData = R"#(
|
||||
10 {"properties": {"address": {"locality": "Москва"}}}
|
||||
20 {"properties": {"address": {"locality": "Краснокамск"}}}
|
||||
|
||||
11 {"properties": {"address": {"locality": "Москва", "street": "улица 1905 года"}}}
|
||||
|
||||
12 {"properties": {"address": {"locality": "Москва", "street": "4-я улица 8 Марта"}}}
|
||||
|
||||
13 {"properties": {"address": {"locality": "Москва", "street": "8 Марта"}}}
|
||||
|
||||
21 {"properties": {"address": {"locality": "Краснокамск", "street": "улица 8 Марта"}}}
|
||||
25 {"properties": {"address": {"locality": "Краснокамск", "street": "Январская улица"}}}
|
||||
26 {"properties": {"address": {"locality": "Краснокамск", "street": "Январская улица", "building": "8"}}}
|
||||
)#";
|
||||
|
||||
ScopedFile const regionsJsonFile("regions.jsonl", kData);
|
||||
Geocoder geocoder(regionsJsonFile.GetFullPath());
|
||||
|
||||
using Id = base::GeoObjectId;
|
||||
TestGeocoder(geocoder, "Москва, улица 1905 года", {{Id{11}, 1.0}});
|
||||
TestGeocoder(geocoder, "Москва, 1905 года", {{Id{11}, 1.0}});
|
||||
TestGeocoder(geocoder, "Краснокамск, улица 1905 года", {});
|
||||
|
||||
TestGeocoder(geocoder, "Москва, 4-я улица 8 Марта", {{Id{12}, 1.0}});
|
||||
TestGeocoder(geocoder, "Москва, 4-я 8 Марта", {{Id{12}, 1.0}});
|
||||
|
||||
TestGeocoder(geocoder, "Москва, 8 Марта", {{Id{13}, 1.0}});
|
||||
TestGeocoder(geocoder, "Москва, улица 8 Марта", {{Id{13}, 1.0}});
|
||||
|
||||
TestGeocoder(geocoder, "Краснокамск, улица 8 Марта", {{Id{21}, 1.0}});
|
||||
TestGeocoder(geocoder, "Краснокамск, 8 Марта", {{Id{21}, 1.0}});
|
||||
TestGeocoder(geocoder, "Краснокамск, Январская 8", {{Id{26}, 1.0}});
|
||||
}
|
||||
|
||||
UNIT_TEST(Geocoder_LocalityBuilding)
|
||||
{
|
||||
string const kData = R"#(
|
||||
|
|
Loading…
Add table
Reference in a new issue