Skip to main content

An utility library for processing Vietnamese texts

Project description

chiecthuyenngoaixa

GitHub issues GitHub license Documentation Status PyPI PyPI - Downloads

Tiếng Việt

chiecthuyenngoaixa is a Python library which provides functions and classes for various tasks in processing Vietnamese texts, such as removing diacritics, converting numbers to words, sorting strings, validations and more.

This library is written on pure Python with no dependencies. Python 3.8 and above is supported.

Installation

Chiecthuyenngoaixa is available on PyPI. Open a terminal or Command Prompt (on Windows) and run the following command:

pip install chiecthuyenngoaixa

If you are using Poetry, use this instead:

poetry add chiecthuyenngoaixa

Basic usage

The library will now be available as ctnx module (abbreviation of chiecthuyenngoaixa).

Some commonly used functions and classes can be imported directly. For example:

  • To convert Vietnamese text to ASCII-only text:
>>> from ctnx import remove_diacritics
>>> remove_diacritics("Đàn ong thấy cái lon thì bu vào.")
'Dan ong thay cai lon thi bu vao.'
  • To convert a number to Vietnamese text:
>>> from ctnx import num_to_words
>>> num_to_words(123456789021003.45)
'một trăm hai mươi ba nghìn bốn trăm năm mươi sáu tỉ bảy trăm tám mươi chín triệu không trăm hai mươi mốt nghìn không trăm linh ba phẩy bốn mươi lăm'
  • To sort Vietnamese texts:
>>> from ctnx import ViSortKey
>>> lines = ['Hà Nam', 'Hải Dương', 'Hà Nội', 'Hà Tĩnh', 'Hải Phòng', 'Hậu Giang', 'Hoà Bình', 'Hưng Yên', 'Hạ Long', 'Hà Giang', 'Điện Biên'\]
>>> sorted(lines, key=ViSortKey)
['Điện Biên', 'Hà Giang', 'Hà Nam', 'Hà Nội', 'Hà Tĩnh', 'Hải Dương', 'Hải Phòng', 'Hạ Long', 'Hậu Giang', 'Hoà Bình', 'Hưng Yên']

For further usages, see the documentation, which is hosted on chiecthuyenngoaixa.readthedocs.io.

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

chiecthuyenngoaixa-0.2.0.tar.gz (20.4 kB view hashes)

Uploaded Source

Built Distribution

chiecthuyenngoaixa-0.2.0-py3-none-any.whl (21.7 kB view hashes)

Uploaded Python 3

Supported by

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