also switch legacy tokenizer to new street/place choice behaviour

This commit is contained in:
Sarah Hoffmann 2023-06-30 15:28:00 +02:00
parent 6c5589c9d2
commit d7a3039c2a
3 changed files with 6 additions and 7 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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):