2 Wrapper around place information the indexer gets from the database and hands to
9 """ Data class containing all information the tokenizer gets about a
10 place it should process the names for.
13 def __init__(self, info):
17 def analyze(self, analyzer):
18 """ Process this place with the given tokenizer and return the
19 result in psycopg2-compatible Json.
21 return psycopg2.extras.Json(analyzer.process_place(self))
26 """ A dictionary with the names of the place or None if the place
29 return self._info.get('name')
34 """ A dictionary with the address elements of the place
35 or None if no address information is available.
37 return self._info.get('address')
41 def country_code(self):
42 """ The country code of the country the place is in. Guaranteed
43 to be a two-letter lower-case string or None, if no country
46 return self._info.get('country_code')
50 def rank_address(self):
51 """ The computed rank address before rank correction.
53 return self._info.get('rank_address')
56 def is_a(self, key, value):
57 """ Check if the place's primary tag corresponds to the given
60 return self._info.get('class') == key and self._info.get('type') == value
64 """ Check if the place is a valid country boundary.
66 return self.rank_address == 4 \
67 and self.is_a('boundary', 'administrative') \
68 and self.country_code is not None