New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add normalization option to Chinese characters (using OpenCC) and separate symbols from merging #473
Closed
+17,079
−273
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # bindings/node/lib/bindings/normalizers.js # bindings/node/native/src/normalizers.rs
# Conflicts: # docs/source/_static/js/custom.js # docs/source/api/python.inc # docs/source/components.rst # docs/source/conf.py # docs/source/index.rst # docs/source/quicktour.rst
# Conflicts: # bindings/python/Cargo.lock # bindings/python/py_src/tokenizers/normalizers/__init__.pyi
# Conflicts: # bindings/python/src/normalizers.rs # bindings/python/tests/bindings/test_normalizers.py # tokenizers/src/normalizers/bert.rs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was working on two things and wish to add this to this library in case somebody needs this:
Features implemented:
Add a normalization option to
normalizers::BertNormalizer
-norm_options
SEPARATE_INTEGERS
e.g.
100
→1 0 0
SEPARATE_SYMBOLS
e.g.
Mr. Stark
→Mr . Stark
SIMPL_TO_TRAD
e.g.
头
→頭
TRAD_TO_SIMPL
e.g.
頭
→头
ZH_NORM_MAPPING
e.g.
【
→[
Check whether OpenCC is installed and can be used -
normalizers::opencc_enabled
Test cases
Expose the above features to Python
How to install OpenCC:
I used the following script to install OpenCC.
Usage
Limitations
lazy_static
to load OpenCC, to avoid unnecessary loading of OpenCC when not enabling it.If the first tokenizer created does not have OpenCC enabled, all other tokenizers created afterwards will not be able to use OpenCC.
Awaiting better solutions 🤒
Updates (2020/10/19)
I see the checks failed from the dependency of
rust-opencc
which requires OpenCC library to be installed.I have made the opencc a feature instead.
Install using: