1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2024 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Module containing the class SpecialPhrase.
10 This class is a model used to transfer a special phrase through
11 the process of load and importation.
13 from typing import Any
18 Model representing a special phrase.
20 def __init__(self, p_label: str, p_class: str, p_type: str, p_operator: str) -> None:
21 self.p_label = p_label.strip()
22 self.p_class = p_class.strip()
23 self.p_type = p_type.strip()
24 # Needed if some operator in the wiki are not written in english
25 p_operator = p_operator.strip().lower()
26 self.p_operator = '-' if p_operator not in ('near', 'in') else p_operator
28 def __eq__(self, other: Any) -> bool:
29 if not isinstance(other, SpecialPhrase):
32 return self.p_label == other.p_label \
33 and self.p_class == other.p_class \
34 and self.p_type == other.p_type \
35 and self.p_operator == other.p_operator
37 def __hash__(self) -> int:
38 return hash((self.p_label, self.p_class, self.p_type, self.p_operator))