X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c3788d765ed4e7ddf00794085af757714bc102cf..baee6f3de09226c3dc41cb2314a0ac348e865561:/nominatim/tools/special_phrases/special_phrase.py diff --git a/nominatim/tools/special_phrases/special_phrase.py b/nominatim/tools/special_phrases/special_phrase.py index dc7f69fe..16935ccf 100644 --- a/nominatim/tools/special_phrases/special_phrase.py +++ b/nominatim/tools/special_phrases/special_phrase.py @@ -10,9 +10,7 @@ This class is a model used to transfer a special phrase through the process of load and importation. """ -import re - -class SpecialPhrase(): +class SpecialPhrase: """ Model representing a special phrase. """ @@ -20,7 +18,19 @@ class SpecialPhrase(): self.p_label = p_label.strip() self.p_class = p_class.strip() # Hack around a bug where building=yes was imported with quotes into the wiki - self.p_type = re.sub(r'\"|"', '', p_type.strip()) + self.p_type = p_type.strip() # Needed if some operator in the wiki are not written in english p_operator = p_operator.strip().lower() self.p_operator = '-' if p_operator not in ('near', 'in') else p_operator + + def __eq__(self, other): + if not isinstance(other, SpecialPhrase): + return False + + return self.p_label == other.p_label \ + and self.p_class == other.p_class \ + and self.p_type == other.p_type \ + and self.p_operator == other.p_operator + + def __hash__(self): + return hash((self.p_label, self.p_class, self.p_type, self.p_operator))