Skip to main content

WeTextProcessing, including TN & ITN

Project description

Text Normalization & Inverse Text Normalization

0. Brief Introduction

WeTextProcessing: Production First & Production Ready Text Processing Toolkit

0.1 Text Normalization

Cover

0.2 Inverse Text Normalization

Cover

1. How To Use

1.1 Quick Start:

# install
pip install WeTextProcessing
# tn usage
>>> from tn.chinese.normalizer import Normalizer
>>> normalizer = Normalizer()
>>> normalizer.normalize("2.5平方电线")
# itn usage
>>> from itn.chinese.inverse_normalizer import InverseNormalizer
>>> invnormalizer = InverseNormalizer()
>>> invnormalizer.normalize("二点五平方电线")

1.2 Advanced Usage:

DIY your own rules && Deploy WeTextProcessing with cpp runtime !!

For users who want modifications and adapt tn/itn rules to fix badcase, please try:

git clone https://github.com/wenet-e2e/WeTextProcessing.git
cd WeTextProcessing
# `overwrite_cache` will rebuild all rules according to
#   your modifications on tn/chinese/rules/xx.py (itn/chinese/rules/xx.py).
#   After rebuild, you can find new far files at `$PWD/tn` and `$PWD/itn`.
python normalize.py --text "2.5平方电线" --overwrite_cache
python inverse_normalize.py --text "二点五平方电线" --overwrite_cache

Once you successfully rebuild your rules, you can deploy them either with your installed pypi packages:

# tn usage
>>> from tn.chinese.normalizer import Normalizer
>>> normalizer = Normalizer(cache_dir="PATH_TO_GIT_CLONED_WETEXTPROCESSING/tn")
>>> normalizer.normalize("2.5平方电线")
# itn usage
>>> from itn.chinese.inverse_normalizer import InverseNormalizer
>>> invnormalizer = InverseNormalizer(cache_dir="PATH_TO_GIT_CLONED_WETEXTPROCESSING/itn")
>>> invnormalizer.normalize("二点五平方电线")

Or with cpp runtime:

cmake -B build -S runtime -DCMAKE_BUILD_TYPE=Release
cmake --build build
# tn usage
./build/bin/processor_main --far PATH_TO_GIT_CLONED_WETEXTPROCESSING/tn/zh_tn_normalizer.far --text "2.5平方电线"
# itn usage
./build/bin/processor_main --far PATH_TO_GIT_CLONED_WETEXTPROCESSING/itn/zh_itn_normalizer.far --text "二点五平方电线"

2. TN Pipeline

Please refer to TN.README

3. ITN Pipeline

Please refer to ITN.README

Discussion & Communication

For Chinese users, you can aslo scan the QR code on the left to follow our offical account of WeNet. We created a WeChat group for better discussion and quicker response. Please scan the personal QR code on the right, and the guy is responsible for inviting you to the chat group.

Or you can directly discuss on Github Issues.

Acknowledge

  1. Thank the authors of foundational libraries like OpenFst & Pynini.
  2. Thank NeMo team & NeMo open-source community.
  3. Thank Zhenxiang Ma, Jiayu Du, and SpeechColab organization.
  4. Referred Pynini for reading the FAR, and printing the shortest path of a lattice in the C++ runtime.
  5. Referred TN of NeMo for the data to build the tagger graph.
  6. Referred ITN of chinese_text_normalization for the data to build the tagger graph.

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

WeTextProcessing-0.1.0.tar.gz (708.9 kB view details)

Uploaded Source

Built Distribution

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

WeTextProcessing-0.1.0-py3-none-any.whl (756.6 kB view details)

Uploaded Python 3

File details

Details for the file WeTextProcessing-0.1.0.tar.gz.

File metadata

  • Download URL: WeTextProcessing-0.1.0.tar.gz
  • Upload date:
  • Size: 708.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for WeTextProcessing-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7b37af6dc90db553af5b46fd6e921a79b24c9cfa480a984d92dd767f5b74e81
MD5 21d67316b02e558658cae543d5d94c5d
BLAKE2b-256 e6c843ba55813fb76b90eb45d6f09249d9413c34c3159a9be45999e7047e6c2c

See more details on using hashes here.

File details

Details for the file WeTextProcessing-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for WeTextProcessing-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbdbc58bdaa177a59f86a691ebaf03d6578412b9ef07abec2cd920f041ac76d3
MD5 1eb9487b6635ae83afa378952c9a5d4e
BLAKE2b-256 972178197566a83acde5f65a4a49197122ab585cb8adbdb751e66d671ba90259

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