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.3.tar.gz (112.2 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.3-py3-none-any.whl (115.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vn_address_converter-0.1.3.tar.gz
  • Upload date:
  • Size: 112.2 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.3.tar.gz
Algorithm Hash digest
SHA256 538bd7af14411c2f1d8579e6424b0ab92076937552677cda3971603fa61553f7
MD5 aa6b9e9931c1a80b493b85805f086f62
BLAKE2b-256 2e918091b2d76a7f188038cf7a5f241fffe3333fa5395c1ca242ae7b3f18cd5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vn_address_converter-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ea03a68ae2665957d8318a4e9cc6d5f4a05cf0c87727dafd2985942f38fff2e5
MD5 03a95cb7040cb6d27076b4ea868fc6a2
BLAKE2b-256 debee02ca57d0a3d2dfaf52606f10c572210cfe4f1a5a3729d975f7825d0cd64

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