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.4.0.tar.gz (9.3 MB view details)

Uploaded Source

Built Distribution

pypinyin_dict-0.4.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.4.0.tar.gz.

File metadata

  • Download URL: pypinyin-dict-0.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 e8499c82640fe78bf21ee4edfdcb407a5b9247513fba867fdba81d4f10f2bea1
MD5 f31d022fcaf7793f7e6efedea40a6400
BLAKE2b-256 02cffc91d523112550da9f957bb775beb00dc0f1da4cd2af0cce0a387603b620

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypinyin_dict-0.4.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.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c98dd112c232115ff737fbe084c4002a90f09b07065582c570848a352aa20fcb
MD5 2290f06aa84a94f08c50744ffefe1ab4
BLAKE2b-256 3669df6c9caa312136b3897d743da2615a45bf9a2a3075a3a059866bbe5f5923

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