From 2c61fe08a031bd4ccbe47c62c021321e2dff7510 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Tue, 18 Mar 2025 23:07:27 +0100 Subject: [PATCH] use word_token length when penalizing against postcodes --- src/nominatim_api/search/icu_tokenizer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nominatim_api/search/icu_tokenizer.py b/src/nominatim_api/search/icu_tokenizer.py index b6cd3464..1bd0030d 100644 --- a/src/nominatim_api/search/icu_tokenizer.py +++ b/src/nominatim_api/search/icu_tokenizer.py @@ -269,10 +269,10 @@ class ICUQueryAnalyzer(AbstractQueryAnalyzer): """ for i, node, tlist in query.iter_token_lists(): if tlist.ttype == qmod.TOKEN_POSTCODE: + tlen = len(cast(ICUToken, tlist.tokens[0]).word_token) for repl in node.starting: if repl.end == tlist.end and repl.ttype != qmod.TOKEN_POSTCODE \ - and (repl.ttype != qmod.TOKEN_HOUSENUMBER - or len(tlist.tokens[0].lookup_word) > 4): + and (repl.ttype != qmod.TOKEN_HOUSENUMBER or tlen > 4): repl.add_penalty(0.39) elif (tlist.ttype == qmod.TOKEN_HOUSENUMBER and len(tlist.tokens[0].lookup_word) <= 3): -- 2.39.5