hondana 本棚
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.
The character tables cover many common titles and names, but they are not complete. Further pairs are welcome.
Install
pip install hondana-ja
# or: pip install git+https://github.com/Jasonin2099/hondana
Use
from hondana import fold, to_isbn13, hyphenate, registration_group, decode_ccode, ndc_class, lookup, lookup_many, search, dedupe, to_bibtex, to_ris, to_csl, loads
fold("圖書館") == fold("图书馆") == fold("図書館") # True
fold("ハリー・ポッター") == fold("はりー ぽったー") # True
to_isbn13("4-00-310101-4") # '9784003101018'
hyphenate("9784003101018") # '978-4-00-310101-8' (from the official ISBN range message, including 978-2/3/89 and 979-…; refresh with scripts/update_isbn_ranges.py)
registration_group("9784003101018") # ('978-4', 'Japan') (group name from the same range message)
decode_ccode("C0093") # CCode(code='0093', audience='一般', form='単行本', subject='文学', detail='日本文学、小説・物語')
ndc_class("913.6") # NdcClass(code='913.6', main='9', label='文学', label_en='Literature') (ten main classes only)
book = lookup("9784003101018") # hits the network; None if nobody knows it
book = lookup("9784003101018", merge=True) # fill missing fields from later sources
books = lookup_many(["978…", "978…"], rate=0.5) # batch; rate = min seconds between lookups
print(book.title, book.source, book.ccode, book.ndc) # C-code / NDC from openBD, empty if absent
print(book.ccode_info, book.ndc_info, book.cover) # decoded C-code (ccode_labels in to_dict()); NDC main class (ndc_class in to_dict()); cover URL from openBD etc., never downloaded
hits = search("吾輩は猫である") # no ISBN: NDL Search + Open Library, ranked with fold()
print(to_bibtex(book)) # or to_ris(book), to_csl(book); also book.to_bibtex()
books = loads(open("list.bib", encoding="utf-8").read()) # read back hondana's own BibTeX / RIS / CSL-JSON (format guessed; includes licence and credit line when present; not a general parser)
CLI: python -m hondana fold "ABC 入門" · fold --explain … · isbn 978… (validate/hyphenate, no network) · isbn "text with ISBN…" · isbn --group 978… (adds the registration-group name, tab-separated; --json has group / group_name) · ccode C0093 3055 (decode Japanese C-codes, no network) · ndc 913.6 007 (main class of an NDC mark, 0 総記 … 9 文学, no network) · lookup 978… · lookup --merge --format table 978… 978… · lookup --format bibtex 978… (also ris / csl) · isbn --find < paper.txt | lookup (ISBNs from stdin, 0.5 s between lookups by default, --rate to change) · search "吾輩は猫である" (title/author search; also --title / --author; --source jpsearch adds Japan Search, filtered per database, with credit lines under the table; lookup --source … too) · dedupe books.csv (duplicate groups by ISBN or folded title + author; --unique clean.csv writes the first spelling of each) · convert list.ris --to bibtex (reads back BibTeX / RIS / CSL-JSON that hondana wrote; JSON by default, --from to force the input format)
What fold() does
- NFKC (full-width ASCII → half, half-width kana → full)
- kyujitai / traditional / simplified → shinjitai (small table in
_tables.py) - katakana → hiragana, drop the long-vowel mark
ー(opt-in:small_kana=Truealso folds ぁ→あ, っ→つ;iteration_marks="expand"/"drop"handles 々 ゝ ゞ;itaiji=Truefolds variant kanji common in names, 髙→高, 﨑→崎;dashes=Trueunifies long-vowel marks, tildes and dash variants, コ─ヒ─→コーヒー) - 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.
Recipes (cleaning and de-duplicating a book list, searching a catalogue the way people type, checking the ISBNs in a reference list, filling in missing metadata, shell pipelines): docs/recipes.md. Every example there is run by the test suite.
ISBN lookup
Each source is tried independently, so one timeout doesn't skip the rest. merge=True queries every source in order and fills missing fields (first non-empty wins; source becomes e.g. openBD+NDL). When the first source (usually openBD) has no contributor roles, lookup() makes one extra request to NDL to fill them (so 角征典 of リーダブルコード is a translator, not an author); if NDL fails, the first source's record is kept. Omit "ndl" from order to skip this. lookup_many() looks up many ISBNs in order; rate sets the minimum seconds between lookups. 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()). When openBD includes classification, Book.ccode (Japanese C-code, without a leading C) and Book.ndc are filled in. decode_ccode() / Book.ccode_info turn the C-code into its audience / form / subject / detail labels, following the 分類記号一覧表 in the Japan ISBN Agency's 利用の手引き 2025 edition (p. 24); blank (reserved) cells decode with an empty detail. The C-code is the publisher's shelving hint, not a library classification. ndc_class() / Book.ndc_info label an NDC mark with its main class only — the ten first-digit classes (0 総記 General works … 9 文学 Literature, as the Japan Library Association lists them on its public NDC page); it accepts 913.6, full-width digits and prefixes such as NDC10:. The NDC schedules are copyrighted by the Japan Library Association, so nothing below the main classes is bundled. search() looks up a title or author with no ISBN, via NDL Search and Open Library, and ranks hits with fold().
Library authority-form names (夏目,漱石,1867-1916, several people in one string) are split into people with life dates dropped (parse_names()). When a source states roles, Book.contributors keeps (name, role) pairs and translators, editors, 監修 and illustrators are exported in their own fields, not as authors. Readings the sources send are kept on Book.title_reading / author_reading, and Book.sort_key() sorts in 五十音順 (no readings are guessed). Also series / volume / edition, issued to the month (2003-06), and JP番号, NDLBibID and NCID (jpno / ndl_bibid / ncid; JSON and table output only, since none of the three citation formats has a standard field for them).
Japan Search (ジャパンサーチ): hondana.jpsearch.JapanSearch searches the national aggregator and applies each database's own terms first — databases that disallow API use or reuse are skipped, partly restricted ones only on request and without their restricted fields, other licences and custom terms only when you opt in, and every record carries its licence and a credit line. Opt-in source for search(sources=(…, "jpsearch")) and lookup(isbn, order=(…, "jpsearch")) (exact ISBN match via the SPARQL endpoint); its books keep licence and attribution. Exports write those into the record (BibTeX copyright / note, RIS N1, CSL license / note); records without a credit line export exactly as before. See docs/japan-search.md.
Tests
pip install pytest && python -m pytest -q
Roadmap: ROADMAP.md · MIT License
Metadata
Release files for hondana-ja 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hondana_ja-0.5.0.tar.gz | 107.2 kB | With provenance | Details for hondana_ja-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hondana_ja-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for hondana_ja-0.5.0-py3-none-any.whl |
Total release size: 179.2 kB
Release files / hondana_ja-0.5.0.tar.gz
| Download URL | hondana_ja-0.5.0.tar.gz |
|---|---|
| Size | 107.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
594bd9f924386541e4a473ddbf541148dc4177aa2683a52383e53d2cc0b3e159
|
|
BLAKE2b-256 checksum How to use checksums |
30072c16f527a16ba67f03f18a4e4d4b8475142d359720db01f47f971aa6d233
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / hondana_ja-0.5.0-py3-none-any.whl
| Download URL | hondana_ja-0.5.0-py3-none-any.whl |
|---|---|
| Size | 72.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16d47f8fb870ab1e1f8b70f2cc4eed6d0e15d95357a68dc433be3b0d47df0377
|
|
BLAKE2b-256 checksum How to use checksums |
6f8a3befbe6b73e946757bdaf8e4526e5b67e21079db70bd3b10952c5ff7ed63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for hondana-ja 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hondana_ja-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.