Skip to main content

使用 pinyin-data 和 phrase-pinyin-data 中的拼音数据文件覆盖 pypinyin 中的自带拼音数据,实现只使用某个或某些拼音数据文件中的拼音数据的需求

Project description

pypinyin-dict

使用 pinyin-dataphrase-pinyin-data 中的拼音数据文件覆盖 pypinyin 中的内置拼音数据, 实现只使用某个或某些拼音数据文件中的拼音数据的需求。

安装

$ pip install pypinyin-dict

使用示例

>>> from pypinyin import pinyin
>>> pinyin('枯萎')
[['kū'], ['wēi']]

# 使用 phrase-pinyin-data 项目中 cc_cedict.txt 文件中的拼音数据优化结果
>>> from pypinyin_dict.phrase_pinyin_data import cc_cedict
>>> cc_cedict.load()

>>> pinyin('枯萎')
[['kū'], ['wěi']]


>>> pinyin('扔', heteronym=True)
[['rēng', 'rèng']]

# 使用 pinyin-data 项目中 kXHC1983.txt 文件中的拼音数据优化结果
>>> from pypinyin_dict.pinyin_data import kxhc1983
>>> kxhc1983.load()

>>> pinyin('扔', heteronym=True)
[['rēng']]

模块介绍

各个模块与数据文件关系如下(所有模块中都有一个 load() 函数用于导入对应的拼音数据,使用方法详见上方【使用示例】):

# pinyin-data/kTGHZ2013.txt
>> from pypinyin_dict.pinyin_data import ktghz2013

# pinyin-data/kHanyuPinyin.txt
>> from pypinyin_dict.pinyin_data import khanyupinyin

# pinyin-data/kXHC1983.txt
>> from pypinyin_dict.pinyin_data import kxhc1983

# pinyin-data/kHanyuPinlu.txt
>> from pypinyin_dict.pinyin_data import khanyupinlu

# pinyin-data/kMandarin_8105.txt
>> from pypinyin_dict.pinyin_data import kmandarin_8105

# pinyin-data/pinyin.txt
>> from pypinyin_dict.pinyin_data import pinyin

# pinyin-data/zdic.txt
>> from pypinyin_dict.pinyin_data import zdic

# pinyin-data/cc_cedict.txt
>> from pypinyin_dict.pinyin_data import cc_cedict


# phrase-pinyin-data/pinyin.txt
>> from pypinyin_dict.phrase_pinyin_data import pinyin

# phrase-pinyin-data/zdic_cibs.txt
>> from pypinyin_dict.phrase_pinyin_data import zdic_cibs

# phrase-pinyin-data/zdic_cybs.txt
>> from pypinyin_dict.phrase_pinyin_data import zdic_cybs

# phrase-pinyin-data/cc_cedict.txt
>> from pypinyin_dict.phrase_pinyin_data import cc_cedict

# phrase-pinyin-data/di.txt
>> from pypinyin_dict.phrase_pinyin_data import di

# phrase-pinyin-data/large_pinyin.txt
>> from pypinyin_dict.phrase_pinyin_data import large_pinyin

生成文件

依赖 Python 3 环境。

clone 子模块:

git submodule init
git submodule update

生成 py 文件:

make generate

编辑数据文件然后生成 py 文件(可选):

  1. 进入 tools 目录
  2. 编辑 pinyin-data 或 phrase-pinyin-data 里的 txt 文件(tools 目录中 Makefile 里涉及的 txt 文件)
  3. 执行 make generate 生成最新的 py 文件
  4. 可以通过 git diff 查看变更内容

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypinyin-dict-0.8.0.tar.gz (9.3 MB view details)

Uploaded Source

Built Distribution

pypinyin_dict-0.8.0-py2.py3-none-any.whl (9.5 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file pypinyin-dict-0.8.0.tar.gz.

File metadata

  • Download URL: pypinyin-dict-0.8.0.tar.gz
  • Upload date:
  • Size: 9.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.2

File hashes

Hashes for pypinyin-dict-0.8.0.tar.gz
Algorithm Hash digest
SHA256 d3799bfdc551b7c7c04d36022c8b4ac00fa5ecb92a2acf5906363317c303c5a3
MD5 e8e5ee1492457330a40e263c84b7ebfd
BLAKE2b-256 8f1d1825aa9bf96796ea3adf3e5bc61253d77d69f978e7bba1da1842be6cd0f6

See more details on using hashes here.

File details

Details for the file pypinyin_dict-0.8.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pypinyin_dict-0.8.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.5 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.2

File hashes

Hashes for pypinyin_dict-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2c9210412e14167487a728843fe02e4c1920796ec0df5c8113be9e0363c8afa1
MD5 be01fc6c3550ce17ead4ce434bbde296
BLAKE2b-256 8a3a968e7ce00a570074d4cefaa33531355137c5acc707815cf73de2eb7e9b67

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page