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