cloud-language-tools-wenlin
Wenlin Chinese-English dictionary data and parser, packaged for Cloud Language Tools.
The dictionary database (202,256 entries, 235,594 definitions) is bundled inside the wheel. There is no download step at install time and no external data directory to provision.
pip install cloud-language-tools-wenlin
The import name is clt_wenlin.
Usage
Look up a word by its simplified or traditional form:
import json
import clt_wenlin
connection = clt_wenlin.open_connection()
for (entry,) in connection.execute(
'SELECT entry FROM words WHERE simplified=?', ('你好',)):
print(json.loads(entry))
connection.close()
{'simplified': '你好',
'traditional': '你好',
'pinyin': 'nị̌',
'parts_of_speech': [{'part_of_speech': 'intj.',
'definitions': [{'definition': 'How are you?; Hello.'}]}]}
Search the English definitions, which are indexed with sqlite FTS5:
connection.execute(
"SELECT definition, entry_id FROM definitions WHERE definitions MATCH 'confirmation'")
If you would rather manage the connection yourself, clt_wenlin.get_wenlin_db_path()
returns the filesystem path of the bundled database.
Database schema
| table | columns | notes |
|---|---|---|
words |
simplified, traditional, entry, entry_id |
entry is the entry serialized as JSON; indexed on simplified, traditional and entry_id |
definitions |
definition, entry_id |
FTS5 virtual table over every English definition |
Each entry document looks like:
{
'simplified': str,
'traditional': str,
'pinyin': str,
'parts_of_speech': [{
'part_of_speech': str | None,
'definitions': [{
'definition': str,
'example_pinyin': str, # optional
'example_chinese': str, # optional
'example_translation': str, # optional
'measure_word': str, # optional
}],
}],
}
Parsing a cidian.u8 file
The parser that produced the database is part of the package:
import clt_wenlin
entries = clt_wenlin.read_dictionary_file('cidian.u8')
clt_wenlin.create_sqlite_file('cidian.u8', 'wenlin.db')
Only the English side of the dictionary is kept; French definitions are dropped.
Development
The project uses uv:
uv sync
uv run pytest
The database is committed to the repository xz-compressed as
data/wenlin_revA.db.xz (16MB). The build hook in hatch_build.py decompresses
it into src/clt_wenlin/data/ so that it lands, uncompressed and ready to query,
in the wheel. To rebuild it from a Wenlin source file:
uv run python tools/build_db.py /path/to/cidian.u8
Bump WENLIN_DB_REV in src/clt_wenlin/database.py when the data changes.
Releasing
./package.sh 2.0.1
License
GPL-3.0-or-later. The Wenlin dictionary data is the property of Wenlin Institute.
Release files for cloud-language-tools-wenlin 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cloud_language_tools_wenlin-2.0.1.tar.gz | 16.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cloud_language_tools_wenlin-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.7 MB
Release files / cloud_language_tools_wenlin-2.0.1.tar.gz
| Download URL | cloud_language_tools_wenlin-2.0.1.tar.gz |
|---|---|
| Size | 16.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a09d709b3945a7945bad29ad273ead8670cc54d9aa72d192cdea22c3d22cff5f
|
|
BLAKE2b-256 checksum How to use checksums |
33046dcc02480e2f2d7745ba580d4f3dfa43e2bc8c026e05615f28d3c912ce9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / cloud_language_tools_wenlin-2.0.1-py3-none-any.whl
| Download URL | cloud_language_tools_wenlin-2.0.1-py3-none-any.whl |
|---|---|
| Size | 27.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66d8f1f9960f6fe4d58bf5b598530b58489bad9a6adf03ac7395b95bc3ee558f
|
|
BLAKE2b-256 checksum How to use checksums |
b7f71a3a7d52a4a7d20f5ea9de61f7d42aeadd7d8f1fac8b62f759bf5ddcc165
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|