WeTextProcessing is an active Python library providing production-ready Text Normalization (TN) and Inverse Text Normalization (ITN) capabilities. It primarily supports Chinese, English, and Japanese languages, leveraging Finite State Transducers (FSTs) for efficient processing. The library has a consistent release cadence, with multiple minor updates released throughout 2024 to introduce new features, improvements, and bug fixes.
pip install WeTextProcessingVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to perform Chinese Text Normalization (TN), Chinese Inverse Text Normalization (ITN), and English Text Normalization using the `WeTextProcessing` library. It showcases specific imports for each language and the use of `overwrite_cache=True` when modifying normalizer parameters, ensuring rules are rebuilt.
Review English TN usage with version 1.0.0 or later. Test thoroughly to ensure desired normalization behavior. If migrating from older versions, be aware of potential changes in output for English text.
For Windows users, it is highly recommended to use Windows Subsystem for Linux (WSL) or a Linux virtual machine for development and deployment. Alternatively, ensure you have a compatible `pynini` wheel for your specific Python version and platform before installing `WeTextProcessing`.
Always pass `overwrite_cache=True` in the constructor of `Normalizer` or `InverseNormalizer` if you are changing its parameters from the default, especially during initial setup or rule modification. For subsequent uses with the same parameters, `overwrite_cache=False` (the default) can be used to load compiled rules faster.
If your application requires specific logging behavior from WeTextProcessing, configure logging explicitly in your application code rather than relying on the library's default global setup.
Use explicit, language-specific imports. For example, `from tn.chinese.normalizer import Normalizer` for Chinese Text Normalization, or `from tn.english.normalizer import Normalizer as EnNormalizer` for English Text Normalization.
Install WeTextProcessing within a Linux environment (e.g., WSL on Windows) or ensure a pre-compiled `pynini` wheel compatible with your system and Python version is available and installed before installing WeTextProcessing. `conda install -c conda-forge pynini` is often recommended for Conda users.
Ensure you are using the correct language-specific Normalizer. For `remove_erhua`, you must use `from tn.chinese.normalizer import Normalizer`. For English, there are different or fewer configurable options. Consult the documentation for available parameters for each language's normalizer.