Rewrite lxneng's xpinyin by cython
Project description
Rewrite lxneng’s xpinyin by cython since by commit 3599c101f659bb7cfbc7e5c5c5684206e4fab5f9 <https://github.com/lxneng/xpinyin/commit/3599c101f659bb7cfbc7e5c5c5684206e4fab5f9>.
The interfaces are completely consistent and can be seamlessly switched with xpinyin;
Install
pip install cpinyin
Usage
Replace xpinyin.Pinyin with cpinyin.Pinyin
>>> import cpinyin >>> cpinyin.install() >>> from xpinyin import Pinyin >>> p = Pinyin() >>> p.get_pinyin(u"上海") 'shang-hai'
Consistent with the xpinyin Api.
>>> from cpinyin import Pinyin >>> p = Pinyin() >>> # default splitter is `-` >>> p.get_pinyin(u"上海") 'shang-hai' >>> # show tone marks >>> p.get_pinyin(u"上海", tone_marks=u'marks') 'shàng-hǎi' >>> p.get_pinyin(u"上海", tone_marks=u'numbers') >>> 'shang4-hai3' >>> # remove splitter >>> p.get_pinyin(u"上海", u'') 'shanghai' >>> # set splitter as whitespace >>> p.get_pinyin(u"上海", u' ') 'shang hai' >>> p.get_initial(u"上") 'S' >>> p.get_initials(u"上海") 'S-H' >>> p.get_initials(u"上海", u'') 'SH' >>> p.get_initials(u"上海", u' ') 'S H'
Please enter Chinese characters encoding by utf8.
>>> wordvalue = '中国' >>> wordvalue= unicode(wordvalue, 'utf-8') >>> s = p.get_initials(wordvalue, u'').lower() 'zg'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cpinyin-0.1.2.tar.gz
(128.6 kB
view details)
File details
Details for the file cpinyin-0.1.2.tar.gz
.
File metadata
- Download URL: cpinyin-0.1.2.tar.gz
- Upload date:
- Size: 128.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 703bec7e9a65353ca158a100e3a456a08b6b47a30a36322e06f51931e7e10be9 |
|
MD5 | 847ebcf77eb93fc46ff019e51a4e449b |
|
BLAKE2b-256 | 104faad2bcc062bb94a69d60ea8385172bc157254dcb964a90084a6d9b0f0fa1 |