cnchar
一个中文成语搜索工具包,提供基于模式匹配和新华字典风格的成语查询功能。
特性
- 🔍 多种搜索模式: 支持模式搜索和新华字典风格搜索
- 📝 详细信息: 提供成语的拼音、解释、例句和出处
- 💻 命令行工具: 提供便捷的命令行界面
- 🐍 Python API: 提供完整的 Python 编程接口
- 💾 结果导出: 支持将结果保存为文本文件或 JSON 格式
安装
pip install cnchar
快速开始
命令行使用
# 模式搜索(第一位是"一",第三位是"二")
cnchar-idiom "一,,二,"
# 新华字典风格搜索
cnchar-idiom --xinhuadict "一:0" "二:2" --limit 5
# 交互模式
cnchar-idiom --interactive
Python API
from cnchar import IdiomSearcher
# 创建搜索器(自动加载包内成语数据)
searcher = IdiomSearcher()
# 模式搜索
results = searcher.search_by_pattern(["字", "", "母", ""])
for idiom in results:
print(f"{idiom['word']} - {idiom['pinyin']}")
# 新华字典风格搜索
results = searcher.get_idiom_by_xinhuadict_detailed(["字", "母"], [0, 2], limit=5)
更多示例
参见 examples/ 目录。
项目结构
cnchar/
└── cnidiom/ # 成语搜索模块
├── core.py # 核心搜索逻辑
├── cli.py # 命令行界面
├── utils.py # 工具函数
└── idiom.json # 成语数据
数据来源
本工具使用新华字典成语数据,数据文件随包分发。
许可证
MIT License
Metadata
Release files for cnchar 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cnchar-0.1.0.tar.gz | 3.6 MB | Without provenance | Details for cnchar-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cnchar-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cnchar-0.1.0-py3-none-any.whl |
Total release size: 7.3 MB
Release files / cnchar-0.1.0.tar.gz
| Download URL | cnchar-0.1.0.tar.gz |
|---|---|
| Size | 3.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
376d550c4ad985ef7ce61a22f468f06c2063ca055d3b54e9292246dcacb50cd9
|
|
BLAKE2b-256 checksum How to use checksums |
a5bec9ecd02b5adcecbe694968a9f060dbd95437a580e7fa3b073d04dc0d4cb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / cnchar-0.1.0-py3-none-any.whl
| Download URL | cnchar-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5df4e7dcc426e398b034bd5d7c75900b292ae84ba47551d09e2df57308417135
|
|
BLAKE2b-256 checksum How to use checksums |
8fcef0a52bfb03f8fa87c4c2006d3759a5be8b3e672947686f819b434fde080c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for cnchar 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.