Metadata-Version: 2.1
Name: cihai
Version: 0.13.0a1
Summary: Library for CJK (chinese, japanese, korean) language data.
Home-page: https://cihai.git-pull.com
License: MIT
Keywords: unihan,sqlalchemy,library,cjk,unicode,dictionary,dataset,encyclopedia,chinese,japanese,korean,languages,study
Author: Tony Narlock
Author-email: tony@git-pull.com
Requires-Python: >=3.7,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Internationalization
Classifier: Topic :: Software Development :: Localization
Classifier: Topic :: Utilities
Provides-Extra: cli
Provides-Extra: coverage
Provides-Extra: docs
Provides-Extra: format
Provides-Extra: lint
Provides-Extra: test
Requires-Dist: appdirs
Requires-Dist: cihai-cli (>=0.9.0a0,<0.10.0); extra == "cli"
Requires-Dist: kaptan
Requires-Dist: sqlalchemy (<1.4)
Requires-Dist: unihan-etl (>=0.14.0a0,<0.15.0)
Project-URL: Bug Tracker, https://github.com/cihai/cihai/issues
Project-URL: Documentation, https://cihai.git-pull.com
Project-URL: Q & A, https://github.com/cihai/cihai/discussions
Project-URL: Repository, https://github.com/cihai/cihai
Project-URL: Release notes, https://github.com/cihai/cihai/blob/master/CHANGES
Description-Content-Type: text/markdown

# cihai

Python library for [CJK](https://cihai.git-pull.com/glossary.html#term-cjk) (chinese, japanese,
korean) data

[![Python Package](https://img.shields.io/pypi/v/cihai.svg)](https://pypi.org/project/cihai/)
[![Docs](https://github.com/cihai/cihai/workflows/docs/badge.svg)](https://cihai.git-pull.com/)
[![Build Status](https://github.com/cihai/cihai/workflows/tests/badge.svg)](https://github.com/cihai/cihai/actions?query=workflow%3A%22tests%22)
[![Code Coverage](https://codecov.io/gh/cihai/cihai/branch/master/graph/badge.svg)](https://codecov.io/gh/cihai/cihai)
[![License](https://img.shields.io/github/license/cihai/cihai.svg)](https://github.com/cihai/cihai/blob/master/LICENSE)

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

## Quickstart

### API / Library (this repository)

```console
$ pip install --user cihai
```

```python
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](https://cihai.git-pull.com/api.html) documentation and
[/examples](https://github.com/cihai/cihai/tree/master/examples).

### CLI ([cihai-cli](https://cihai-cli.git-pull.com))

```console
$ pip install --user cihai[cli]
```

```console
# 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](https://unihan-etl.git-pull.com) - [UNIHAN](http://unicode.org/charts/unihan.html)
  data exports for csv, yaml and json.

## Developing

[poetry](https://python-poetry.org/) 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)](http://eradman.com/entrproject/))

### 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)](http://eradman.com/entrproject/))

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](https://github.com/psf/black) and [isort](https://pypi.org/project/isort/)
(one after the other) and runs [flake8](https://flake8.pycqa.org/) via CI. See the configuration in
<span class="title-ref">pyproject.toml</span> 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](https://python-poetry.org/) handles virtualenv creation, package requirements,
versioning, building, and publishing. Therefore there is no setup.py or requirements files.

Update <span class="title-ref">\_\_version\_\_</span> in <span
class="title-ref">\_\_about\_\_.py</span> 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

- [Quickstart](https://cihai.git-pull.com/quickstart.html)
- [Datasets](https://cihai.git-pull.com/datasets.html) a full list of current and future data sets
- Python [API](https://cihai.git-pull.com/api.html)
- [Roadmap](https://cihai.git-pull.com/design-and-planning/)
- Python support: >= 3.6, pypy
- Source: <https://github.com/cihai/cihai>
- Docs: <https://cihai.git-pull.com>
- Changelog: <https://cihai.git-pull.com/history.html>
- API: <https://cihai.git-pull.com/api.html>
- Issues: <https://github.com/cihai/cihai/issues>
- Test coverage: <https://codecov.io/gh/cihai/cihai>
- pypi: <https://pypi.python.org/pypi/cihai>
- OpenHub: <https://www.openhub.net/p/cihai>
- License: MIT

