Skip to main content

Library for CJK (chinese, japanese, korean) language data.

Project description

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!

Quickstart

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

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

cihai-0.13.0a1.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

cihai-0.13.0a1-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file cihai-0.13.0a1.tar.gz.

File metadata

  • Download URL: cihai-0.13.0a1.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cihai-0.13.0a1.tar.gz
Algorithm Hash digest
SHA256 dfd36402c601bbbebda003747dd671e4dbc2e888aae08bcf7549f548b324fe3f
MD5 e2151504f3c93e2267811540fc2b6e73
BLAKE2b-256 2a4e733082cf0310d7505218ecdc334cb40535b0e4b51877320866130173e4dc

See more details on using hashes here.

Provenance

File details

Details for the file cihai-0.13.0a1-py3-none-any.whl.

File metadata

  • Download URL: cihai-0.13.0a1-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cihai-0.13.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 81a5abe1ad6e0bab71633625b017e54ad198b07dd0a3ecc0b25ee02ea7e82f59
MD5 67f3199a1724b5ebb43754891285d571
BLAKE2b-256 6bd6766cf55c121c5f3cfef1a3a0f7dd8f4100d8205c11d1c7eae78a6ec93e07

See more details on using hashes here.

Provenance

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