ICU-tokenizer is a python package used to perform universal language normalization and tokenization using the International Components for Unicode.
Install
See ./INSTALL.md
Usage (Python)
Sentence splitter
# To split a paragraph into multiple sentences
>>> from icu_tokenizer import SentSplitter
>>> splitter = SentSplitter('zh')
>>> paragraph = """
美国最高法院(英语:Supreme Court of the United States),一般是指美国联邦最高法院,是美国最高级别的联邦法院,为美国三权继总统、国会后最为重要的一环。根据1789年《美国宪法第三条》的规定,最高法院对所有联邦法院、州法院和涉及联邦法律问题的诉讼案件具有最终(并且在很大程度上是有斟酌决定权的)上诉管辖权,以及对小范围案件的具有初审管辖权。在美国的法律制度中,最高法院通常是包括《美国宪法》在内的联邦法律的最终解释者,但仅在具有管辖权的案件范围内。法院不享有判定政治问题的权力;政治问题的执法机关是行政机关,而不是政府的司法部门。
"""
>>> splitter.split(paragraph)
[
'美国最高法院(英语:Supreme Court of the United States),一般是指美国联邦最高法院,是美国最高级别的联邦法院,为美国三权继总统、国会后最为重要的一环。',
'根据1789年《美国宪法第三条》的规定,最高法院对所有联邦法院、州法院和涉及联邦法律问题的诉讼案件具有最终(并且在很大程度上是有斟酌决定权的)上诉管辖权,以及对小范围案件的具有初审管辖权。',
'在美国的法律制度中,最高法院通常是包括《美国宪法》在内的联邦法律的最终解释者,但仅在具有管辖权的案件范围内。',
'法院不享有判定政治问题的权力;政治问题的执法机关是行政机关,而不是政府的司法部门。'
]
Normalizer
# To normalize text
>>> from icu_tokenizer import Normalizer
>>> normalizer = Normalizer(lang='en', norm_puncts=True)
>>> text = "𝑻𝒉𝒆 𝒑𝒓𝒐𝒅𝒖𝒄𝒕𝒔 𝒚𝒐𝒖 𝒐𝒓𝒅𝒆𝒓𝒆𝒅 𝒘𝒊𝒍𝒍 𝒃𝒆 𝒔𝒉𝒊𝒑𝒑𝒆𝒅 𝒅𝒊𝒓𝒆𝒄𝒕𝒍𝒚 𝒇𝒓𝒐𝒎 𝑲𝒐𝒓𝒆𝒂."
>>> normalizer.normalize(text)
"The products you ordered will be shipped directly from Korea."
>>> text = "【】()"
>>> normalizer.normalize(text)
"[]()"
Tokenizer
>>> from icu_tokenizer import Tokenizer
>>> tokenizer = Tokenizer(lang='th')
>>> text = "ภาษาไทยเป็นภาษาที่มีระดับเสียงของคำแน่นอนหรือวรรณยุกต์เช่นเดียวกับภาษาจีน และออกเสียงแยกคำต่อคำ"
>>> tokenizer.tokenize(text)
['ภาษา', 'ไทย', 'เป็น', 'ภาษา', 'ที่', 'มี', 'ระดับ', 'เสียง', 'ของ', 'คำ', 'แน่นอน', 'หรือ', 'วรรณยุกต์', 'เช่น', 'เดียว', 'กับ', 'ภาษา', 'จีน', 'และ', 'ออก', 'เสียง', 'แยก', 'คำ', 'ต่อ', 'คำ']
Metadata
Release files for icu-tokenizer 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| icu_tokenizer-0.0.1.tar.gz | 11.2 kB | Without provenance | Details |
Release files / icu_tokenizer-0.0.1.tar.gz
| Download URL | icu_tokenizer-0.0.1.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0430f5191697904168769938fe3533ddd12e8afd5d84d43e852e9aee4a8b2447
|
|
BLAKE2b-256 checksum How to use checksums |
2636d4fdf94a2b58135d4df4b9c12c9602e18a6e1f0267e60802c3bf455e530d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
|
Security for icu-tokenizer 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.