Skip to main content

A Python package for converting and normalizing Vietnamese addresses

Project description

Vietnam Address Converter

This is the result of my vibe coding experiment to fully use AI to solve a problem. Check out my blog here.

Vietnam recently merged 63 provinces into 34, creating a need to convert old addresses to the new administrative format. This Python package provides a solution for converting old Vietnamese addresses to the new format.

Most of the code is written with Github Copilot using GPT 4.1 and Claude Sonet 4 model.

The mapping data is sourced from here. Initially, I tried to parse from this wiki page, but the result was so bad that I ended up abandoning the parser.

Disclaimer

This package is experimental and may not be 100% accurate. Please verify results and contribute improvements!

Installation

pip install vn-address-converter

Usage Example

Basic Address Conversion

from vn_address_converter import convert_to_new_address, Address

address = Address(
    street_address="720A Điện Biên Phủ",
    ward="Phường 22",
    district="Quận Bình Thạnh",
    province="Thành phố Hồ Chí Minh"
)

new_address = convert_to_new_address(address)
print(new_address)
# Output: Address(street_address='720A Điện Biên Phủ', ward='Phường Thạnh Mỹ Tây', district=None, province='Thành phố Hồ Chí Minh')

# Format address as string
print(new_address.format())
# Output: 720A Điện Biên Phủ, Phường Thạnh Mỹ Tây, Thành phố Hồ Chí Minh

Parse Address from String

from vn_address_converter import parse_address, convert_to_new_address

# Parse address string with different separators
address_str = "123 Nguyễn Huệ, Phường 1, Quận 1, Thành phố Hồ Chí Minh"
address = parse_address(address_str)
print(address)
# Output: Address(street_address='123 Nguyễn Huệ', ward='Phường 1', district='Quận 1', province='Thành phố Hồ Chí Minh')

# Convert parsed address to new format
new_address = convert_to_new_address(address)
print(new_address.format())
# Output: 123 Nguyễn Huệ, Phường Ben Nghé, Thành phố Hồ Chí Minh

# Works with semicolon, pipe, and hyphen separators too
address_str = "456 Lê Lợi; Phường 2; Quận 1; Thành phố Hồ Chí Minh"
address = parse_address(address_str)
print(address.format())
# Output: 456 Lê Lợi, Phường 2, Quận 1, Thành phố Hồ Chí Minh

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vn_address_converter-0.1.2.tar.gz (104.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vn_address_converter-0.1.2-py3-none-any.whl (107.3 kB view details)

Uploaded Python 3

File details

Details for the file vn_address_converter-0.1.2.tar.gz.

File metadata

  • Download URL: vn_address_converter-0.1.2.tar.gz
  • Upload date:
  • Size: 104.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for vn_address_converter-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bcea5ff6a5632c5ddafcc1f5ab69d4d377116ac958694f5264a30416bdc2e217
MD5 ea65b4da2b69716a80ab3a335b112cec
BLAKE2b-256 93a24901b2ff1c9fcf681baefff0abf63df9a480aecdc180811065849c0c9687

See more details on using hashes here.

File details

Details for the file vn_address_converter-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for vn_address_converter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af2b7c2f1c39777329bdbdd0f30e8424d4b759933bd794ba001490c784617840
MD5 a1d4b47dd8572fced2070cc182adf66b
BLAKE2b-256 70d75e386b158639d732e4f3650c7a8fef2c143f78a1beac12adfcfaf324fd4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page