Skip to main content

Convert Vietnamese numbers to words

Project description

vnnum2word

Convert numbers to words, with a focus on the Vietnamese language.

This project is inspired by num2words.

The original num2words library formats numbers into floats with two decimal places. For example:

from num2words import num2words
num2words(12.5, lang='vi')
# mười hai phẩy năm mươi
num2words(12.556, lang='vi')
# mười hai phẩy năm mươi sáu

However, in Vietnamese, these results are often inaccurate or unnatural. This package fixes those issues and provides more accurate and natural outputs for Vietnamese numbers.

Installation

pip install vnnum2word

Usage

from vnnum2word import convert_number, convert_string
convert_number(12.5)
# mười hai phẩy năm
convert_string("giải thưởng là 1000000 đồng")
# giải thưởng là một triệu đồng
convert_string("mã abc123def")
# mã abc một hai ba def

Unittest

python -m unittest tests/number.py
python -m unittest tests/string.py

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

vnnum2word-0.3.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

vnnum2word-0.3.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file vnnum2word-0.3.0.tar.gz.

File metadata

  • Download URL: vnnum2word-0.3.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for vnnum2word-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7956969846f494d6bf6aed2d4ae4ab4ed26800f3aa4f0749b96010ad2058b935
MD5 c4e87bed4fa37ac45c8b91b817869dea
BLAKE2b-256 c42b745b9b32c7fd7f5db69e677a5132f91f90467802e7e8f96d4bda62819c38

See more details on using hashes here.

File details

Details for the file vnnum2word-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: vnnum2word-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for vnnum2word-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f285b9b0c933c51077a34d0149211c1edc9a14bdbf5b9008d4307c75d6258556
MD5 962452498ea9a0a790b906525f2fb2c7
BLAKE2b-256 f1bfdeda12310dc0092890a96f4c9d7e00ad3b7ac4c242454d1ed59d275ead9d

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