1 # SPDX-License-Identifier: GPL-2.0-only
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2022 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
17 Model representing a special phrase.
19 def __init__(self, p_label: str, p_class: str, p_type: str, p_operator: str) -> None:
20 self.p_label = p_label.strip()
21 self.p_class = p_class.strip()
22 self.p_type = p_type.strip()
23 # Needed if some operator in the wiki are not written in english
24 p_operator = p_operator.strip().lower()
25 self.p_operator = '-' if p_operator not in ('near', 'in') else p_operator
27 def __eq__(self, other: Any) -> bool:
28 if not isinstance(other, SpecialPhrase):
31 return self.p_label == other.p_label \
32 and self.p_class == other.p_class \
33 and self.p_type == other.p_type \
34 and self.p_operator == other.p_operator
36 def __hash__(self) -> int:
37 return hash((self.p_label, self.p_class, self.p_type, self.p_operator))