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
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.
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.
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
ranking.penalty -= min_penalty
return min_penalty
-
def sql_penalty(self, table: SaFromClause) -> SaColumn:
""" Create an SQL expression for the rankings.
"""
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
setattr(self, field, wstrs)
-
def set_qualifiers(self, tokens: List[Token]) -> None:
""" Set the qulaifier field from the given tokens.
"""
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.
"""