A parser for Canadian postal addresses
From PyPi
pip install ez-address-parser
From GitHub
pip install git+https://github.com/zehengl/ez-address-parser.git
python -m ez_address_parser --address <some-address>
from ez_address_parser import AddressParser
ap = AddressParser()
address = input("Address: ")
result = ap.parse(address)
for token, label in result:
print(f"{token:20s} -> {label}")
from ez_address_parser import AddressParser
ap = AddressParser(use_pretrained=False)
data = [
[
('123', 'StreetNumber'),
('Main', 'StreetName'),
('St', 'StreetType'),
('E', 'StreetDirection')
],
...
] # list of list of (<token>, <label>) tuple
ap.train(data)
address = input("Address: ")
result = ap.parse(address)
for token, label in result:
print(f"{token:20s} -> {label}")