Skip to main content

cihai - Python library for CJK (chinese, japanese, korean) data

Python Package Docs Build Status Code Coverage License

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": 㑘, 㑤, 㓛, 㘬, 㙉, 㚃, 㚒, 㚥, 㛦, 㜴, 㜺, 㝖, 㤛, 㦝, ...

See API documentation and /examples.

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.

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

Metadata

Release files for cihai 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cihai 0.12.0
File Size Uploaded
cihai-0.12.0.tar.gz 21.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cihai 0.12.0
File Interpreter ABI Platform
cihai-0.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.6 kB

Release files / cihai-0.12.0.tar.gz

Download URL cihai-0.12.0.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
48df072d02a0f7121ea7ad3d4e039e89d0f1102579f32f3ef9db78bb4358a3ef
BLAKE2b-256 checksum
How to use checksums
18b7166201d5945e9851757da0d5ad7299d24d2abf7a4af9dd42c900235a5a10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.7.9 Linux/4.19.128-microsoft-standard

Release files / cihai-0.12.0-py3-none-any.whl

Download URL cihai-0.12.0-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e748a98da8fab173d15d159ffa484c677f5f6b94c96ca4beb4f1b84cbcf4a27
BLAKE2b-256 checksum
How to use checksums
a47f3fcfe9bf8d7353a270ce11ebbfc1bd4275b6cc783864bf126fd41a04bed5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.7.9 Linux/4.19.128-microsoft-standard

Release history Release notifications | RSS feed

0.38.0

2 release files

0.37.0

2 release files

0.36.1

2 release files

0.35.0

2 release files

0.34.0

2 release files

0.29.0

2 release files

0.28.0

2 release files

0.27.0

2 release files

0.25.0

2 release files

0.23.0

2 release files

0.22.1

2 release files

0.22.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.18.3

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.1

2 release files

0.14.0

2 release files

0.13.0

2 release files

This release

0.12.0 This release

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.9.0

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.4

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page