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.
15 Model representing a special phrase.
17 def __init__(self, p_label, p_class, p_type, p_operator):
18 self.p_label = p_label.strip()
19 self.p_class = p_class.strip()
20 # Hack around a bug where building=yes was imported with quotes into the wiki
21 self.p_type = p_type.strip()
22 # Needed if some operator in the wiki are not written in english
23 p_operator = p_operator.strip().lower()
24 self.p_operator = '-' if p_operator not in ('near', 'in') else p_operator
26 def __eq__(self, other):
27 if not isinstance(other, SpecialPhrase):
30 return self.p_label == other.p_label \
31 and self.p_class == other.p_class \
32 and self.p_type == other.p_type \
33 and self.p_operator == other.p_operator
36 return hash((self.p_label, self.p_class, self.p_type, self.p_operator))