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

Uploaded Source

Built Distribution

pypinyin_dict-0.7.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.7.0.tar.gz.

File metadata

  • Download URL: pypinyin-dict-0.7.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.7.0.tar.gz
Algorithm Hash digest
SHA256 4c218fa47eed5a79cfba75fc3741c106b64ad8f4c3461b60055545f404bc9b56
MD5 390bf8c6e113a25fa7b4c826af6af511
BLAKE2b-256 0b056185c5c6c122dd6b382a9d33bd3a3bec9c5153c23c303881f18faa0b966d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypinyin_dict-0.7.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.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9e8d8694f867343527cc2a3cd73263a48720814871179ab029673d66383251a6
MD5 837b02fd3af6dbd84ae2569831b5be99
BLAKE2b-256 f989fb717797fd8e64f75e774dc02207a445b3538c0781e4e4ad6f21e94498f9

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