- NONE = 0
- """ No specific designation (i.e. source is free-form query). """
- AMENITY = enum.auto()
- """ Contains name or type of a POI. """
- STREET = enum.auto()
- """ Contains a street name optionally with a housenumber. """
- CITY = enum.auto()
- """ Contains the postal city. """
- COUNTY = enum.auto()
- """ Contains the equivalent of a county. """
- STATE = enum.auto()
- """ Contains a state or province. """
- POSTCODE = enum.auto()
- """ Contains a postal code. """
- COUNTRY = enum.auto()
- """ Contains the country name or code. """
-
- def compatible_with(self, ttype: TokenType,
- is_full_phrase: bool) -> bool:
- """ Check if the given token type can be used with the phrase type.
- """
- if self == PhraseType.NONE:
- return not is_full_phrase or ttype != TokenType.QUALIFIER
- if self == PhraseType.AMENITY:
- return ttype in (TokenType.WORD, TokenType.PARTIAL)\
- or (is_full_phrase and ttype == TokenType.NEAR_ITEM)\
- or (not is_full_phrase and ttype == TokenType.QUALIFIER)
- if self == PhraseType.STREET:
- return ttype in (TokenType.WORD, TokenType.PARTIAL, TokenType.HOUSENUMBER)
- if self == PhraseType.POSTCODE:
- return ttype == TokenType.POSTCODE
- if self == PhraseType.COUNTRY:
- return ttype == TokenType.COUNTRY
-
- return ttype in (TokenType.WORD, TokenType.PARTIAL)
+ if ptype == PHRASE_ANY:
+ return not is_full_phrase or ttype != TOKEN_QUALIFIER
+ if ptype == PHRASE_AMENITY:
+ return ttype in (TOKEN_WORD, TOKEN_PARTIAL)\
+ or (is_full_phrase and ttype == TOKEN_NEAR_ITEM)\
+ or (not is_full_phrase and ttype == TOKEN_QUALIFIER)
+ if ptype == PHRASE_STREET:
+ return ttype in (TOKEN_WORD, TOKEN_PARTIAL, TOKEN_HOUSENUMBER)
+ if ptype == PHRASE_POSTCODE:
+ return ttype == TOKEN_POSTCODE
+ if ptype == PHRASE_COUNTRY:
+ return ttype == TOKEN_COUNTRY
+
+ return ttype in (TOKEN_WORD, TOKEN_PARTIAL)