Compact, read-only search dictionaries for Japanese corporate names and corporate numbers.
hojin provides exact normalized-name lookup, address-aware ranking, corporate-number lookup, and prefix suggestions. Native indexes are memory-mapped, while variable-size records use independently compressed zstd frames. The same compact suggestion bundle can be searched from WebAssembly in browsers and Node.js.
- standalone Rust crate with no application-framework dependency
- Unicode, legal-form, legacy-character, and Japanese-address normalization
- exact corporate-name lookup with address-aware ranking
- direct 13-digit corporate-number lookup
- alternate name, English name, and furigana indexes
- mmap-backed FST, compact fixed-width indexes, and delta-varint postings
- block-addressable zstd record storage
- compact prefix-suggestion bundle for WASM/npm
- optional adapter for NTA headerless Unicode CSV files
[dependencies]
hojin = "0.1"use hojin::CorporateDictionary;
let dictionary = CorporateDictionary::open("/opt/dictionaries/corporations-2026-06")?;
let candidates = dictionary.resolve_exact(
"(株)ABC",
Some("東京都千代田区丸の内1-1-1"),
)?;
let corporation = dictionary.get_by_corporate_number(7_000_012_050_002)?;
# Ok::<(), anyhow::Error>(())Registered addresses are never overwritten by query text. Exact name-and-address matches rank first, followed by compatible address containment and name-only matches. Active corporations win ties.
Download and extract the Unicode CSV files from the NTA full-data download page, then run:
cargo run --release --features cli --bin build-hojin-dictionary -- \
--output /tmp/corporations-2026-06 \
/path/to/00_zenkoku_all_*.csvSee DATA-LICENSE.md before redistributing NTA-derived artifacts. Source data and generated nationwide dictionaries are deliberately excluded from the Rust crate, npm package, and repository.
Build a browser package:
wasm-pack build crates/hojin-wasm \
--release --target web --scope bokuweb --out-dir pkg-webBuild a Node.js package:
wasm-pack build crates/hojin-wasm \
--release --target nodejs --scope bokuweb --out-dir pkg-nodeimport init, { CorporateSuggester } from "@bokuweb/hojin-wasm";
await init();
const response = await fetch("/dictionary/2026-06/suggestions.bin");
const suggester = new CorporateSuggester(
new Uint8Array(await response.arrayBuffer()),
);
const candidates = suggester.suggest("鳥取簡易", {
limit: 10,
includeClosed: false,
});Corporate numbers are returned to JavaScript as 13-digit strings. The npm package contains code only; versioned dictionary bundles should be served separately, preferably with Content-Encoding: br and optional prefecture or leading-character shards.
| File | Purpose | Access |
|---|---|---|
manifest.json |
schema, source/terms/files, processor version, counts, SHA-256 | startup read |
names.fst |
normalized name to posting offset | mmap |
numbers.idx |
48-bit corporate number to record ID | mmap + binary search |
postings.bin |
delta-varint record IDs | mmap |
records.idx |
compact record-to-block location | mmap |
blocks.idx |
zstd frame offsets and lengths | mmap |
records.zst |
independently compressed record blocks | mmap + selective decode |
suggestions.bin |
lookup FST, postings, front-coded display/address tables | WASM memory or native bytes |
Do not overwrite dictionary files while readers have them mapped. Build a new versioned directory and atomically switch a symlink or configuration pointer.
Measured with the NTA Tottori Unicode snapshot used during development: 20,153 corporations and 29,422 suggestion entries.
| Artifact | Size |
|---|---|
| complete dictionary directory | 3,007,399 bytes |
suggestions.bin |
1,355,591 bytes |
suggestions.bin with Brotli level 11 |
586,915 bytes |
| release WASM | 126,763 bytes |
| npm tarball, without dictionary data | 61,650 bytes |
These measurements are reference points, not guarantees for other source snapshots.
Source code is licensed under the MIT License. NTA source data and artifacts derived from it are not relicensed under MIT; see DATA-LICENSE.md.