]> git.openstreetmap.org Git - nominatim.git/blobdiff - src/nominatim_api/search/icu_tokenizer.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / src / nominatim_api / search / icu_tokenizer.py
index 6f1dcf7902ab65e5a4481d6a3d7b65e6274deab8..44afce9f3f69baf6475b0090eb388906bdef3c26 100644 (file)
@@ -208,6 +208,12 @@ class ICUQueryAnalyzer(AbstractQueryAnalyzer):
         log().section('Analyze query (using ICU tokenizer)')
         for func in self.preprocessors:
             phrases = func(phrases)
+
+        if len(phrases) == 1 \
+                and phrases[0].text.count(' ') > 3 \
+                and max(len(s) for s in phrases[0].text.split()) < 3:
+            normalized = []
+
         query = qmod.QueryStruct(phrases)
 
         log().var_dump('Normalized query', query.source)
@@ -244,7 +250,7 @@ class ICUQueryAnalyzer(AbstractQueryAnalyzer):
             standardized form search will work with. All information removed
             at this stage is inevitably lost.
         """
-        return cast(str, self.normalizer.transliterate(text))
+        return cast(str, self.normalizer.transliterate(text)).strip('-: ')
 
     def split_query(self, query: qmod.QueryStruct) -> Tuple[QueryParts, WordDict]:
         """ Transliterate the phrases and split them into tokens.