Japanese entity parser library for company/corporate name normalization and extraction.
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ja_entity_parser-1.0.3.tar.gz.
File metadata
- Download URL: ja_entity_parser-1.0.3.tar.gz
- Upload date:
- Size: 52.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70ece382ca717541e5a60b0110109462b8ce09b3bfe1268c7ae2724175b4727b
|
|
| MD5 |
d568ae8decfa9abe694e46fef65bb572
|
|
| BLAKE2b-256 |
146a3777d9fb6ff692e0ec506d865fb6731d05614af87bf9ed640da568352712
|
File details
Details for the file ja_entity_parser-1.0.3-py3-none-any.whl.
File metadata
- Download URL: ja_entity_parser-1.0.3-py3-none-any.whl
- Upload date:
- Size: 46.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98a57be76d41eb7d2c6109f9b0e21bd3dc64618bbbc57fd0af7d6c054b045f73
|
|
| MD5 |
7ec609b17e5bce77d5032d6c720be1f3
|
|
| BLAKE2b-256 |
16b3384af0360b120f0a3653bc343d12a168ea207a6add17f348b7bbb1f38313
|