def __init__(self, field: str, name: str) -> None: super().__init__(LeaseDocument, field, name, FieldType.FIELD_TYPE_CONCRETE_STRING, [ FieldDetector(select=r'(?:premises|property)\s+located\s+in(.*)', process_selected=lambda sentence, match: find_addresses_str(match), fill_fields=lambda sentence, addresses: {'address': addresses[0]}, exclude=AddressFieldConfig.ADDRESSES_EXCLUDE_SENTENCES_RE), ])
doc.address_state_province = None doc.address_country = None doc.address_longitude = None doc.address_latitude = None else: print('Unable to detect address via Google geocoder: {0}'.format( g.status)) return doc.address DOCUMENT_FIELDS = [ FieldConfig( LeaseDocument, 'property_type', 'Property Type', FieldType.FIELD_TYPE_CONCRETE_STRING, [ FieldDetector( select= r'.*(?:tenant|lessee|premises|property|agreed).+use.+storage.*', fill_fields={'property_types__set': 'storage'}), FieldDetector( select= r'.*(?:tenant|lessee|premises|property|agreed).+use.+farming.*', fill_fields={'property_types__set': 'farming'}), FieldDetector( select= r'.*(?:tenant|lessee|premises|property|agreed).+use.+office.*', fill_fields={'property_types__set': 'office'}), FieldDetector( select= r'.*(?:tenant|lessee|premises|property|agreed).+use.+(?:sale|retail).*', fill_fields={'property_types__set': 'retail'}), FieldDetector(select=r'.*storage.+lease.*', fill_fields={'property_types__set': 'storage'}),