Library for CJK (chinese, japanese, korean) language data.
Project description
cihai - Python library for CJK (chinese, japanese, korean) data
This project is under active development. Follow our progress and check back for updates!
Usage
API / Library (this repository)
$ pip install --user cihai
from cihai.core import Cihai
c = Cihai()
if not c.unihan.is_bootstrapped: # download and install Unihan to db
c.unihan.bootstrap(unihan_options)
query = c.unihan.lookup_char('好')
glyph = query.first()
print("lookup for 好: %s" % glyph.kDefinition)
# lookup for 好: good, excellent, fine; well
query = c.unihan.reverse_char('good')
print('matches for "good": %s ' % ', '.join([glph.char for glph in query]))
# matches for "good": 㑘, 㑤, 㓛, 㘬, 㙉, 㚃, 㚒, 㚥, 㛦, 㜴, 㜺, 㝖, 㤛, 㦝, ...
CLI (cihai-cli)
$ pip install --user cihai[cli]
# character lookup
$ cihai info 好
char: 好
kCantonese: hou2 hou3
kDefinition: good, excellent, fine; well
kHangul: 호
kJapaneseOn: KOU
kKorean: HO
kMandarin: hǎo
kTang: '*xɑ̀u *xɑ̌u'
kTotalStrokes: '6'
kVietnamese: háo
ucn: U+597D
# reverse lookup
$ cihai reverse library
char: 圕
kCangjie: WLGA
kCantonese: syu1
kCihaiT: '308.302'
kDefinition: library
kMandarin: tú
kTotalStrokes: '13'
ucn: U+5715
--------
UNIHAN data
All datasets that cihai uses have stand-alone tools to export their data. No library required.
unihan-etl - UNIHAN data exports for csv, yaml and json.
Developing
poetry is a required package to develop.
git clone https://github.com/cihai/cihai.git
cd cihai
poetry install -E "docs test coverage lint format"
Makefile commands prefixed with watch_ will watch files and rerun.
Tests
poetry run py.test
Helpers: make test Rerun tests on file change: make watch_test (requires entr(1))
Documentation
Default preview server: http://localhost:8035
cd docs/ and make html to build. make serve to start http server.
Helpers: make build_docs, make serve_docs
Rebuild docs on file change: make watch_docs (requires entr(1))
Rebuild docs and run server via one terminal: make dev_docs (requires above, and a make(1) with -J support, e.g. GNU Make)
Formatting / Linting
The project uses black and isort (one after the other) and runs flake8 via CI. See the configuration in pyproject.toml and setup.cfg:
make black isort: Run black first, then isort to handle import nuances make flake8, to watch (requires entr(1)): make watch_flake8
Releasing
As of 0.10, poetry handles virtualenv creation, package requirements, versioning, building, and publishing. Therefore there is no setup.py or requirements files.
Update __version__ in __about__.py and pyproject.toml:
git commit -m 'build(cihai): Tag v0.1.1' git tag v0.1.1 git push git push --tags poetry build poetry deploy
Quick links
Python support: Python 2.7, >= 3.5, pypy
Source: https://github.com/cihai/cihai
Changelog: https://cihai.git-pull.com/history.html
Test coverage: https://codecov.io/gh/cihai/cihai
OpenHub: https://www.openhub.net/p/cihai
License: MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cihai-0.11.1.tar.gz
.
File metadata
- Download URL: cihai-0.11.1.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.7.9 Linux/4.19.128-microsoft-standard
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f46fb6c42c8cddba4822a8bb8cee9fc3a31d12208b3c76257fc3cd0fa9c2c381 |
|
MD5 | 5a28d18ba1794f923cffd3c11af8781b |
|
BLAKE2b-256 | b4cd033716d9d74e787e1a3515385b15826f4f83e87c0020d7abe926cfa7a049 |
Provenance
File details
Details for the file cihai-0.11.1-py3-none-any.whl
.
File metadata
- Download URL: cihai-0.11.1-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.7.9 Linux/4.19.128-microsoft-standard
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0717ab69f290ece82f4899aa8e04d442c050b71340ebb6c46a216aa5e95c1412 |
|
MD5 | 6cc8b0562102cdb5358ff39819caef91 |
|
BLAKE2b-256 | 0728f6947f3e4c0e6f2c8d88187aedfe22c1f9c1b705410bc64f0d4bf4ff064c |