search for chinese pinyin and wrap it with HTML.
colorize pinyin
search for chinese pinyin and wrap it with HTML.
module provides some useful functions for working with Chinese pinyin, “phonetic system for transcribing the Mandarin pronunciations of Chinese characters into the Latin alphabet” (c) wikipedia .
usage sample
>>> colorized_HTML_string_from_string('nǐ hǎo') '<span class="pinYinWrapper"><span class="t3">nǐ</span> <span class="t3">hǎo</span></span>'>>> ranges_of_pinyin_in_string('nǐ hǎo') [Range(location=0, length=2), Range(location=3, length=3)] # == [(0, 2), (3, 3)]
requirements
lxml is only required if you want to work with DOM. but it does not listed in requirements because if you want to use them, surely you already have lxml on the board; for other cases we don’t need additional third-party libs.
functions that designed to work with lxml marked with [*].
functions
modify given DOM by replacing children text nodes containing pinyin with wrapper element:
colorize_DOM [*]
undo colorize:
uncolorize_DOM [*]
detect and wrap pinyin with HTML in plain text string:
colorized_HTML_string_from_string
do the same, but returns a wrapper – DOM element:
colorized_HTML_element_from_string [*]
searching for pinyin in string of text:
ranges_of_pinyin_in_string
finding out what tone has some pinyin word:
determine_tone
remove tones (diacritics) from pinyin string:
lowercase_string_by_removing_pinyin_tones
constants
PINYIN_LIST – specially sorted list of all possible pinyin words.
PINYIN_LIST_BY_LEN – same as PINYIN_LIST but grouped by len descending.
PINYIN_WRAPPER_CLASS – default class used by [un]colorize_DOM.
classes
Range – 2-named-tuple with [0] location and [1] length.
Metadata
Release files for colorize-pinyin 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distributions (sdists)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| colorize_pinyin-2.1.1.tar.gz | 7.9 kB | Without provenance | Details | |
| colorize_pinyin-2.1.1.macosx-10.8-x86_64.tar.gz | 11.5 kB | Without provenance | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| colorize_pinyin-2.1.1-py3-none-any.whl | Python 3 | none | any | Details |
| colorize_pinyin-2.1.1-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 41.9 kB
Release files / colorize_pinyin-2.1.1.tar.gz
| Download URL | colorize_pinyin-2.1.1.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2aa9adae50ea9a2d59042710ee830b5020a17c05ae5c455786c30e284be8fb9
|
|
BLAKE2b-256 checksum How to use checksums |
7579c0661c7a41bc7ffe7d1c3583a1e2b3e4887b127fe1e056d5e9e4a3ccabb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / colorize_pinyin-2.1.1.macosx-10.8-x86_64.tar.gz
| Download URL | colorize_pinyin-2.1.1.macosx-10.8-x86_64.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac78d75f9b17e9ac1674f0dca6472fd063f1de865cebc0ac5f46fcc7638d3f32
|
|
BLAKE2b-256 checksum How to use checksums |
8ccf1b359e73db3ba5f4034f7237c3c6679e7c11c5611c2536628cbf2ea66693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / colorize_pinyin-2.1.1-py3-none-any.whl
| Download URL | colorize_pinyin-2.1.1-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
927fc1e18e9ae072d03e9573e25765a7f79feda00b1c5b2b03c4adf7f76a4293
|
|
BLAKE2b-256 checksum How to use checksums |
763e9874fd764e982fec90d40dbf06cebdf449d62cc53fbdd6987f374a850066
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / colorize_pinyin-2.1.1-py2-none-any.whl
| Download URL | colorize_pinyin-2.1.1-py2-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
c617e0483c5f2924637d5f565f54eb6431308543b511a26dd33308b870f606b1
|
|
BLAKE2b-256 checksum How to use checksums |
c01a3bb27caeefd021d1b03c714a25f2443c5892df9eec875b3a52330934c1b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for colorize-pinyin 2.1.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.