ja-entity-parser
Overview
ja-entity-parser is a Python library for normalization and extraction of Japanese entities: corporate names, personal names, and addresses.
It combines SudachiPy morphological analysis with custom normalization rules (old/new kanji conversion, kanji numeral conversion, bracket/punctuation/control character unification, NFKC, and user dictionary replacements) to accurately parse Japanese text into structured components.
Features
- Japanese text normalization: Old/new kanji conversion, kanji numeral → Arabic, bracket/punctuation/control character unification, NFKC, corporate abbreviation expansion (
(株)→株式会社, etc.) - Corporate name parsing: Legal form extraction and brand name/kana via SudachiPy
- Personal name parsing: Family/given name split using SudachiPy POS, whitespace, or surname dictionary
- Address parsing: State (prefecture) → city → suburb (town) → house_number (block) using Address Base Registry data; block numbers are normalized to canonical form (halfwidth digits and hyphens). Field names follow libpostal label conventions
- User dictionary support: Extendable for industry-specific terms
- Testing: 66 pytest-based unit and integration tests
Installation
pip install ja-entity-parser
Usage
1. Parse corporate name
from ja_entityparser import parse_corporate
result = parse_corporate("トヨタ自動車株式会社")
print(result)
# {
# 'input': 'トヨタ自動車株式会社',
# 'normalized': 'トヨタ自動車株式会社',
# 'legal_form': '株式会社',
# 'brand_name': 'トヨタ自動車',
# 'brand_kana': 'トヨタジドウシャ'
# }
# Abbreviations are automatically expanded:
result = parse_corporate("(株)ソフトバンク")
# normalized: '株式会社ソフトバンク'
2. Parse person name
from ja_entityparser import parse_person
result = parse_person("田中 太郎")
print(result)
# {
# 'input': '田中 太郎',
# 'normalized': '田中 太郎',
# 'family_name': '田中',
# 'given_name': '太郎',
# 'family_name_kana': 'タナカ',
# 'given_name_kana': 'タロウ'
# }
3. Parse address
The parser splits an address into state, city, suburb, and house_number using the Japanese government's Address Base Registry. Field names follow libpostal label conventions for cross-language address matching. Block numbers are normalized to a canonical halfwidth-digit-and-hyphen form regardless of the input style (fullwidth digits, 丁目/番/号, 番地の, etc.). The original block string is preserved in house_number_raw for auditing.
from ja_entityparser import parse_address
# Example 1: fullwidth digits and hyphens → normalized to halfwidth
result = parse_address("北海道札幌市中央区大通西3丁目1番5号")
print(result)
# {
# 'input': '北海道札幌市中央区大通西3丁目1番5号',
# 'normalized': '北海道札幌市中央区大通西3丁目1番5号',
# 'state': '北海道',
# 'city': '札幌市中央区',
# 'suburb': '大通西',
# 'house_number': '3-1-5',
# 'house_number_raw': '3丁目1番5号'
# }
# Example 2: 番地の format
result = parse_address("愛知県江南市大字小折628番地の1")
print(result)
# {
# 'input': '愛知県江南市大字小折628番地の1',
# 'normalized': '愛知県江南市大字小折628番地の1',
# 'state': '愛知県',
# 'city': '江南市',
# 'suburb': '大字小折',
# 'house_number': '628-1',
# 'house_number_raw': '628番地の1'
# }
Address data is sourced from the Japanese government's アドレス・ベース・レジストリ (Address Base Registry).
4. Normalization only
from ja_entityparser.normalizer import normalize
text = "〔トヨタ〕(株)テスト 三百二十一号"
print(normalize(text))
# (トヨタ)株式会社テスト 321号
API Reference
| Function | Description | Returns |
|---|---|---|
parse_corporate(text) |
Parse Japanese corporate name | input, normalized, legal_form?, brand_name, brand_kana |
parse_person(text) |
Parse Japanese person name | input, normalized, family_name?, given_name?, *_kana? |
parse_address(text) |
Parse Japanese address | input, normalized, state?, city?, suburb?, house_number?, house_number_raw? |
normalize(text) |
Normalize Japanese text | str |
License
Apache License 2.0
Metadata
Release files for ja-entity-parser 1.0.3
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 | |
|---|---|---|---|---|
| ja_entity_parser-1.0.3.tar.gz | 52.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ja_entity_parser-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.3 kB
Release files / ja_entity_parser-1.0.3.tar.gz
| Download URL | ja_entity_parser-1.0.3.tar.gz |
|---|---|
| Size | 52.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70ece382ca717541e5a60b0110109462b8ce09b3bfe1268c7ae2724175b4727b
|
|
BLAKE2b-256 checksum How to use checksums |
146a3777d9fb6ff692e0ec506d865fb6731d05614af87bf9ed640da568352712
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / ja_entity_parser-1.0.3-py3-none-any.whl
| Download URL | ja_entity_parser-1.0.3-py3-none-any.whl |
|---|---|
| Size | 46.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98a57be76d41eb7d2c6109f9b0e21bd3dc64618bbbc57fd0af7d6c054b045f73
|
|
BLAKE2b-256 checksum How to use checksums |
16b3384af0360b120f0a3653bc343d12a168ea207a6add17f348b7bbb1f38313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for ja-entity-parser 1.0.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.