X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/63da70685a6f0232b8f13bfa158772e035586347..ae8694a6a6862d7cb66cd91102d2802c9899e7cf:/src/nominatim_api/search/db_search_fields.py diff --git a/src/nominatim_api/search/db_search_fields.py b/src/nominatim_api/search/db_search_fields.py index 8f674ecc..6bd33094 100644 --- a/src/nominatim_api/search/db_search_fields.py +++ b/src/nominatim_api/search/db_search_fields.py @@ -12,8 +12,8 @@ import dataclasses import sqlalchemy as sa -from nominatim_core.typing import SaFromClause, SaColumn, SaExpression -from nominatim_core.utils.json_writer import JsonWriter +from ..typing import SaFromClause, SaColumn, SaExpression +from ..utils.json_writer import JsonWriter from .query import Token from . import db_search_lookups as lookups @@ -28,11 +28,9 @@ class WeightedStrings: def __bool__(self) -> bool: return bool(self.values) - def __iter__(self) -> Iterator[Tuple[str, float]]: return iter(zip(self.values, self.penalties)) - def get_penalty(self, value: str, default: float = 1000.0) -> float: """ Get the penalty for the given value. Returns the given default if the value does not exist. @@ -54,11 +52,9 @@ class WeightedCategories: def __bool__(self) -> bool: return bool(self.values) - def __iter__(self) -> Iterator[Tuple[Tuple[str, str], float]]: return iter(zip(self.values, self.penalties)) - def get_penalty(self, value: Tuple[str, str], default: float = 1000.0) -> float: """ Get the penalty for the given value. Returns the given default if the value does not exist. @@ -69,7 +65,6 @@ class WeightedCategories: pass return default - def sql_restrict(self, table: SaFromClause) -> SaExpression: """ Return an SQLAlcheny expression that restricts the class and type columns of the given table to the values @@ -125,7 +120,6 @@ class FieldRanking: ranking.penalty -= min_penalty return min_penalty - def sql_penalty(self, table: SaFromClause) -> SaColumn: """ Create an SQL expression for the rankings. """ @@ -177,7 +171,6 @@ class SearchData: qualifiers: WeightedCategories = WeightedCategories([], []) - def set_strings(self, field: str, tokens: List[Token]) -> None: """ Set on of the WeightedStrings properties from the given token list. Adapt the global penalty, so that the @@ -191,7 +184,6 @@ class SearchData: setattr(self, field, wstrs) - def set_qualifiers(self, tokens: List[Token]) -> None: """ Set the qulaifier field from the given tokens. """ @@ -207,7 +199,6 @@ class SearchData: self.qualifiers = WeightedCategories(list(categories.keys()), list(categories.values())) - def set_ranking(self, rankings: List[FieldRanking]) -> None: """ Set the list of rankings and normalize the ranking. """