Metadata-Version: 2.4
Name: hondana-ja
Version: 0.1.0
Summary: Fold Japanese/CJK book metadata for matching (簡繁・新旧字体・かな・全半角) and look up ISBNs with openBD → NDL → Google Books → Open Library fallback.
License: MIT
Project-URL: Homepage, https://github.com/Jasonin2099/hondana
Keywords: japanese,cjk,isbn,openbd,ndl,normalization,kyujitai,library,bibliography
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Natural Language :: Japanese
Classifier: Natural Language :: Chinese (Simplified)
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# hondana 本棚

[中文](README.md) · [日本語](README.ja.md)

Small, dependency-free Python helpers for matching Japanese / CJK book metadata.

If you've built book search you've seen it: the user types `图书馆`, the record says `圖書館`; someone types `ﾊﾘｰ ﾎﾟｯﾀｰ`, the title is `ハリー・ポッター`. hondana folds these into one comparison key. It also ships a tiny ISBN lookup that falls back openBD → NDL Search → Google Books → Open Library.

> Early skeleton: the character tables are a small starter set — enough to show the idea, not full coverage. Pairs welcome.

## Install

```bash
pip install git+https://github.com/Jasonin2099/hondana
```

## Use

```python
from hondana import fold, to_isbn13, hyphenate, lookup

fold("圖書館") == fold("图书馆") == fold("図書館")   # True
fold("ﾊﾘｰ・ﾎﾟｯﾀｰ") == fold("はりー ぽったー")         # True
to_isbn13("4-00-310101-4")                           # '9784003101018'
hyphenate("9784003101018")                           # '978-4-00-310101-8' (978-0/1, 978-4, 978-7, 978-957/986)

book = lookup("9784003101018")    # hits the network; None if nobody knows it
print(book.title, book.source)
```

CLI: `python -m hondana fold "ＡＢＣ　入門"` · `python -m hondana fold --explain "ﾊﾘｰ・ﾎﾟｯﾀｰ"` (every step) · `python -m hondana isbn 9784003101018`

## What `fold()` does

1. NFKC (full-width ASCII → half, half-width kana → full)
2. kyujitai / traditional / simplified → shinjitai (small table in `_tables.py`)
3. katakana → hiragana, drop the long-vowel mark `ー` (opt-in: `small_kana=True` also folds ぁ→あ, っ→つ; `iteration_marks="expand"`/`"drop"` handles 々 ゝ ゞ; `itaiji=True` folds variant kanji common in names, 髙→高, 﨑→崎; `dashes=True` unifies long-vowel marks, tildes and dash variants, コ─ヒ─→コーヒー)
4. casefold, drop spaces, punctuation and 「」『』 brackets

Every step can be switched off (`fold(s, kana=False)` etc.). Simplified characters that are a *different* everyday Japanese character (机 vs 機, 干, 后, 叶) are left out on purpose.

Why not just NFKC? See [docs/why-not-nfkc.md](docs/why-not-nfkc.md).

## ISBN lookup

Each source is tried independently, so one timeout doesn't skip the rest. Pass your own `fetch(url, params, timeout) -> (status, text)` to use another HTTP client, add caching, or stub the network in tests. `cached(fetch, ttl=3600)` wraps any fetch with an in-memory TTL cache: `lookup(isbn, fetch=cached())`.

## Tests

`pip install pytest && python -m pytest -q`

Roadmap: [ROADMAP.md](ROADMAP.md) · MIT License
