Skip to main content

Convert numbers to Vietnamese words and Vietnamese words to numbers (with North/South variants)

Project description

vn-numberwords

Convert numbers to Vietnamese words and Vietnamese words to numbers (supports Northern and Southern variants).

Install (from source)

pip install -e .

Usage

from vn_numberwords import number_to_words, number_to_currency, words_to_number, currency_words_to_number, SouthDictionary

# Convert numbers to Vietnamese words
print(number_to_words(1234))                       # "một nghìn hai trăm linh bốn"
print(number_to_currency(1234, "đồng"))           # "một nghìn hai trăm linh bốn đồng"
print(number_to_words(21, SouthDictionary()))      # "hai mươi mốt"

# Convert Vietnamese words to numbers
print(words_to_number("một nghìn hai trăm linh bốn"))  # 1234
print(words_to_number("mười một"))                     # 11
print(words_to_number("một trăm ngàn tỷ"))             # 100000000000000
print(currency_words_to_number("một nghìn đồng"))      # 1000

Parse Vietnamese-formatted strings:

from vn_numberwords import vietnamese_string_to_words

print(vietnamese_string_to_words("1.234.56"))     # decimal example

Features

Number to Words

  • Convert numbers to Vietnamese words
  • Support for Northern and Southern Vietnamese variants
  • Currency formatting
  • Large number support (up to trillions)

Words to Number

  • Convert Vietnamese words back to numbers
  • Support for both accented and non-accented Vietnamese
  • Handle complex numbers with multiple magnitude keywords
  • Currency parsing

Supported Number Formats

  • Units: không, một, hai, ba, bốn, năm, sáu, bảy, tám, chín
  • Tens: mười, mươi, chục
  • Hundreds: trăm
  • Thousands: nghìn, ngàn, nghàn
  • Millions: triệu
  • Billions: tỷ, tỉ

CLI / Demo

Run the demo script:

python number2word.py

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_numberwords-0.2.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

vn_numberwords-0.2.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file vn_numberwords-0.2.0.tar.gz.

File metadata

  • Download URL: vn_numberwords-0.2.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vn_numberwords-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3d9e05d55f79c6fdd681a6a3a0345a8938df30fec2553231d71f0fb3c438ffdb
MD5 094eb91f42191eb0e2ee6ceebb6475b9
BLAKE2b-256 077df9692d8080a9539e0dde11587b78fdf7d7617e8d19e236cb1c75576be823

See more details on using hashes here.

Provenance

The following attestation bundles were made for vn_numberwords-0.2.0.tar.gz:

Publisher: publish.yml on rato-kaz/vn-numberwords

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vn_numberwords-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vn_numberwords-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vn_numberwords-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc72ccf8894ac937dfd7966c69010f5117a1ba82ad7a02267722b6f434697cf3
MD5 056c2767381f59537d68a56bbcb849b0
BLAKE2b-256 57e4a2a57d5efdc4dd646cb6d32500d8886aff83d3e8d0696bbebf565bf9033a

See more details on using hashes here.

Provenance

The following attestation bundles were made for vn_numberwords-0.2.0-py3-none-any.whl:

Publisher: publish.yml on rato-kaz/vn-numberwords

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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