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

Uploaded Source

Built Distribution

pypinyin_dict-0.5.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.5.0.tar.gz.

File metadata

  • Download URL: pypinyin-dict-0.5.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.5.0.tar.gz
Algorithm Hash digest
SHA256 5e426e21f3c6ee9f1545601b3f5e620370c4fb53aa8fda0a691b261aade36f59
MD5 8354595d5f0f606cf5c9f0eb7cc45a3b
BLAKE2b-256 335d5a7e8f264150fff65546e820dfc7344f04eb4711f4551353f275cf06b0f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypinyin_dict-0.5.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.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 46d98c9d459e7aa7b66e57a14e905eec7a0adb646ca54a28d0c048a029b9310e
MD5 31714e7dfcaac2565e07632550c067a5
BLAKE2b-256 114129c5ef30af40dcb8174c2cdbae4ff1f829d7caca9bb715aacedc48a5a615

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