frankier / cihai

Python library for CJK (Chinese, Japanese, and Korean) language data

Home Page:https://cihai.git-pull.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Python Package Documentation Status Build Status Code Coverage License

This project is under active development. Follow our progress and check back for updates!

Usage

Python library only

$ pip install --user cihai
from cihai.core import Cihai
from cihai.bootstrap import bootstrap_unihan

c = Cihai()
if not c.is_bootstrapped:  # download and install Unihan to db
    bootstrap_unihan(c.metadata)
    c.reflect_db()         # automap new table created during bootstrap

query = c.lookup_char('好')
glyph = query.first()
print("lookup for 好: %s" % glyph.kDefinition)
# lookup for 好: good, excellent, fine; well

query = c.reverse_char('good')
print('matches for "good": %s ' % ', '.join([glph.char for glph in query]))
# matches for "good": 㑘, 㑤, 㓛, 㘬, 㙉, 㚃, 㚒, 㚥, 㛦, 㜴, 㜺, 㝖, 㤛, 㦝, ...

See API documentation and /examples.

CLI front-end (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
--------

No library, just data

All datasets that cihai uses have stand-alone tools to export their data. No library required.

Quick links

Python support Python 2.7, >= 3.5, pypy
Source https://github.com/cihai/cihai
Docs https://cihai.git-pull.com
Changelog https://cihai.git-pull.com/en/latest/history.html
API https://cihai.git-pull.com/en/latest/api.html
Issues https://github.com/cihai/cihai/issues
Travis https://travis-ci.org/cihai/cihai
Test coverage https://codecov.io/gh/cihai/cihai
pypi https://pypi.python.org/pypi/cihai
OpenHub https://www.openhub.net/p/cihai
License MIT
git repo
$ git clone https://github.com/cihai/cihai.git
install stable
$ pip install cihai
install dev
$ git clone https://github.com/cihai/cihai.git cihai
$ cd ./cihai
$ virtualenv .env
$ source .env/bin/activate
$ pip install -e .
tests
$ python setup.py test

About

Python library for CJK (Chinese, Japanese, and Korean) language data

https://cihai.git-pull.com

License:MIT License


Languages

Language:Python 97.6%Language:Makefile 2.4%