Review fixes.
This commit is contained in:
parent
683250079a
commit
6334404df5
4 changed files with 35 additions and 15 deletions
|
@ -143,4 +143,16 @@ UNIT_TEST(StreetTokensFilter)
|
|||
|
||||
TEST_EQUAL(expected, actual, ());
|
||||
}
|
||||
|
||||
{
|
||||
TList expected = {{"улица", 0}, {"набережная", 1}, {"проспект", 2}};
|
||||
TList actual;
|
||||
|
||||
Utf8StreetTokensFilter filter(actual);
|
||||
filter.Put("улица", false /* isPrefix */, 0 /* tag */);
|
||||
filter.Put("набережная", true /* isPrefix */, 1 /* tag */);
|
||||
filter.Put("проспект", false /* isPrefix */, 2 /* tag */);
|
||||
|
||||
TEST_EQUAL(expected, actual, ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,16 +234,11 @@ void StreetTokensFilter::Put(strings::UniString const & token, bool isPrefix, si
|
|||
{
|
||||
m_delayedToken = token;
|
||||
m_delayedTag = tag;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_numSynonyms == 2)
|
||||
EmitToken(m_delayedToken, m_delayedTag);
|
||||
EmitToken(token, tag);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EmitToken(token, tag);
|
||||
}
|
||||
EmitToken(token, tag);
|
||||
}
|
||||
} // namespace search
|
||||
|
|
|
@ -57,7 +57,10 @@ bool ContainsNormalized(string const & str, string const & substr);
|
|||
|
||||
// This class can be used as a filter for street tokens. As there can
|
||||
// be street synonyms in the street name, single street synonym is
|
||||
// skipped, but multiple synonyms are left as is.
|
||||
// skipped, but multiple synonyms are left as is. For example, when
|
||||
// applied to ["улица", "ленина"] the filter must emit only
|
||||
// ["ленина"], but when applied to ["улица", "набережная"] the filter
|
||||
// must emit both tokens as is, i.e. ["улица", "набережная"].
|
||||
class StreetTokensFilter
|
||||
{
|
||||
public:
|
||||
|
@ -70,10 +73,10 @@ public:
|
|||
}
|
||||
|
||||
// Puts token to the filter. Filter checks following cases:
|
||||
// * if |token| is the first street synonym met so far, it's delayed
|
||||
// * if |token| is a street synonym, but not the first, callback is called
|
||||
// for the |token| and for the previously delayed token
|
||||
// * if |token| is not a street synonym, callback is called for the |token|
|
||||
// * when |token| is the first street synonym met so far, it's delayed
|
||||
// * when |token| is the second street synonym met so far,
|
||||
// callback is called for the |token| and for the previously delayed token
|
||||
// * otherwise, callback is called for the |token|
|
||||
void Put(strings::UniString const & token, bool isPrefix, size_t tag);
|
||||
|
||||
private:
|
||||
|
|
|
@ -466,8 +466,8 @@ void Geocoder::SetParams(Params const & params)
|
|||
}
|
||||
}
|
||||
|
||||
LOG(LDEBUG, ("Tokens = ", m_params.m_tokens));
|
||||
LOG(LDEBUG, ("Prefix tokens = ", m_params.m_prefixTokens));
|
||||
LOG(LDEBUG, ("Tokens =", m_params.m_tokens));
|
||||
LOG(LDEBUG, ("Prefix tokens =", m_params.m_prefixTokens));
|
||||
LOG(LDEBUG, ("Languages =", m_params.m_langs));
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1091,12 @@ void Geocoder::GreedilyMatchStreets()
|
|||
// arguments.
|
||||
size_t lastToken = startToken;
|
||||
|
||||
// When true, no bit vectors were intersected with allFeatures at
|
||||
// all.
|
||||
bool emptyIntersection = true;
|
||||
|
||||
// When true, allFeatures is in the incomplete state and can't be
|
||||
// used for creation of street layers.
|
||||
bool incomplete = false;
|
||||
|
||||
auto createStreetsLayerAndMatchLowerLayers = [&]()
|
||||
|
@ -1109,8 +1114,13 @@ void Geocoder::GreedilyMatchStreets()
|
|||
*allFeatures, *m_addressFeatures[tag]);
|
||||
if (tag < curToken)
|
||||
{
|
||||
// This is the case for delayed
|
||||
// street synonym. Therefore,
|
||||
// allFeatures is temporarily in the
|
||||
// incomplete state.
|
||||
allFeatures.Set(move(buffer));
|
||||
emptyIntersection = false;
|
||||
|
||||
incomplete = true;
|
||||
return;
|
||||
}
|
||||
|
|
Reference in a new issue