mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-22 12:06:27 +03:00
also switch legacy tokenizer to new street/place choice behaviour
This commit is contained in:
parent
6c5589c9d2
commit
d7a3039c2a
@ -44,14 +44,14 @@ $$ LANGUAGE SQL IMMUTABLE STRICT;
|
||||
CREATE OR REPLACE FUNCTION token_is_street_address(info JSONB)
|
||||
RETURNS BOOLEAN
|
||||
AS $$
|
||||
SELECT info->>'street' is not null or info->>'place' is null;
|
||||
SELECT info->>'street' is not null or info->>'place_search' is null;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION token_has_addr_street(info JSONB)
|
||||
RETURNS BOOLEAN
|
||||
AS $$
|
||||
SELECT info->>'street' is not null;
|
||||
SELECT info->>'street' is not null and info->>'street' != '{}';
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
|
||||
|
@ -564,14 +564,13 @@ class _TokenInfo:
|
||||
def add_street(self, conn: Connection, street: str) -> None:
|
||||
""" Add addr:street match terms.
|
||||
"""
|
||||
def _get_street(name: str) -> List[int]:
|
||||
def _get_street(name: str) -> Optional[str]:
|
||||
with conn.cursor() as cur:
|
||||
return cast(List[int],
|
||||
return cast(Optional[str],
|
||||
cur.scalar("SELECT word_ids_from_name(%s)::text", (name, )))
|
||||
|
||||
tokens = self.cache.streets.get(street, _get_street)
|
||||
if tokens:
|
||||
self.data['street'] = tokens
|
||||
self.data['street'] = tokens or '{}'
|
||||
|
||||
|
||||
def add_place(self, conn: Connection, place: str) -> None:
|
||||
|
@ -549,7 +549,7 @@ class TestPlaceAddress:
|
||||
def test_process_place_street_empty(self):
|
||||
info = self.process_address(street='🜵')
|
||||
|
||||
assert 'street' not in info
|
||||
assert info['street'] == '{}'
|
||||
|
||||
|
||||
def test_process_place_place(self):
|
||||
|
Loading…
Reference in New Issue
Block a user