Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ’ in special_chars #11

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pypostalwin/src/pypostalwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _validate_address(address):

@staticmethod
def _remove_special_chars(address):
special_chars = r"≈≠><+≥≤±*÷√°⊥~Δπ≡≜∝∞≪≫⌈⌉⌋⌊∑∏γφ⊃⋂⋃μσρλχ⊄⊆⊂⊇⊅⊖∈∉⊕⇒⇔↔∀∃∄∴∵ε∫∮∯∰δψΘθαβζηικξτω∇"
special_chars = r"≈≠><+≥≤±*÷√°⊥~Δπ≡≜∝∞≪≫⌈⌉⌋⌊∑∏γφ⊃⋂⋃μσρλχ⊄⊆⊂⊇⊅⊖∈∉⊕⇒⇔↔∀∃∄∴∵ε∫∮∯∰δψΘθαβζηικξτω∇"
translator = str.maketrans("", "", special_chars)
return address.translate(translator)

Expand All @@ -48,8 +48,6 @@ def parse_address(self, address):
json_data = result[json_start:json_end]
return json.loads(json_data)



def expand_address(self, address):
self._validate_address(address)
address = self._remove_special_chars(address)
Expand All @@ -63,14 +61,14 @@ def terminate_parser(self):


if __name__ == '__main__':
address_parser_path = "<path-to-address-parser>"
libpostal_path = "<path-to-libpostal>"
address_parser_path = r'C:\Workbench\libpostal\src\address_parser.exe'
libpostal_path = r'C:\Workbench\libpostal\src\libpostal.exe'

logging.basicConfig(level=logging.INFO)

parser = AddressParser(address_parser_path, libpostal_path)

address = "123 Main Street, City"
address = 'District Science Cntr, Kokkirakulam’ Rd, Tirunelveli, Tamil Nadu 627009'
try:
parsed_address = parser.parse_address(address)
logging.info("Parsed Address: %s", parsed_address)
Expand Down