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.1.tar.gz (102.1 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.1-py3-none-any.whl (104.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vn_address_converter-0.1.1.tar.gz
  • Upload date:
  • Size: 102.1 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.1.tar.gz
Algorithm Hash digest
SHA256 76ddf8cb00da951eafea1516f6cd51dfcf94bcc320e94e1ba517aab7b0d7bff3
MD5 473bed130542b909b49fd0ebc08d77b1
BLAKE2b-256 4dc5ddd730b47108d22fb186e6396edbc98bb732de8e939e79bb01fe5b09f3bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vn_address_converter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e034af00f5581f455075678d6e19fda92e833e552dad17472157c6bf22c2a4d
MD5 3f764674ac6eccd245528d14a074117a
BLAKE2b-256 0b1c9fc28ff463c9fabce0f4058967468ef1845547c37eb3ed4f10f040e43d5c

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