Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zehengl/ez-address-parser

A parser for Canadian postal addresses
https://github.com/zehengl/ez-address-parser

address-parser canadian conditional-random-fields python

Last synced: about 1 month ago
JSON representation

A parser for Canadian postal addresses

Awesome Lists containing this project

README

        


logo

# ez-address-parser

[![pytest](https://github.com/zehengl/ez-address-parser/actions/workflows/pytest.yml/badge.svg)](https://github.com/zehengl/ez-address-parser/actions/workflows/pytest.yml)
![coding_style](https://img.shields.io/badge/code%20style-black-000000.svg)
![PyPI - License](https://img.shields.io/pypi/l/ez-address-parser)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ez-address-parser)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/ez-address-parser)
[![Downloads](https://static.pepy.tech/badge/ez-address-parser)](https://pepy.tech/project/ez-address-parser)
[![GitHub Pages](https://github.com/zehengl/ez-address-parser/actions/workflows/gh-deploy.yml/badge.svg)](https://github.com/zehengl/ez-address-parser/actions/workflows/gh-deploy.yml)

A parser for Canadian postal addresses

## Install

From [PyPi](https://pypi.org/project/ez-address-parser/)

pip install ez-address-parser

From [GitHub](https://github.com/zehengl/ez-address-parser)

pip install git+https://github.com/zehengl/ez-address-parser.git

## Usage

### Command Line

python -m ez_address_parser --address

### Code (with pretrained model)

```python
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}")
```

### Code (without pretrained model)

```python
from ez_address_parser import AddressParser

ap = AddressParser(use_pretrained=False)

data = [
[
('123', 'StreetNumber'),
('Main', 'StreetName'),
('St', 'StreetType'),
('E', 'StreetDirection')
],
...
] # list of list of (, ) tuple

ap.train(data)

address = input("Address: ")
result = ap.parse(address)
for token, label in result:
print(f"{token:20s} -> {label}")
```

## Credits

- [Icon][1] by [Rakhmat Setiawan][2]

[1]: https://www.iconfinder.com/icons/3059893/find_magnifier_search_seo_word_icon
[2]: https://www.iconfinder.com/rsetiawan93