🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

japanese-address-parser-py

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

japanese-address-parser-py

A library for processing addresses of Japan

pipPyPI
Version
0.3.1
Maintainers
1

japanese-address-parser-py

A Python toolkit for processing Japanese addresses

PyPI - Version PyPI - Downloads Unit test & Integration test

What is it?

japanese-address-parser-py is a Python package for parsing Japanese addresses. Any address can be parsed into structured data.

Installation from PyPI

pip install japanese-address-parser-py

Usage

Sequential execution

from japanese_address_parser_py import Parser

addresses = [
    "埼玉県さいたま市浦和区高砂3-15-1",
    "千葉県千葉市中央区市場町1-1",
    "東京都新宿区西新宿2-8-1",
    "神奈川県横浜市中区日本大通1",
]
parser = Parser()
for address in addresses:
    parse_result = parser.parse(address)
    print(parse_result.address)
{'prefecture': '埼玉県', 'town': '高砂三丁目', 'rest': '15-1', 'city': 'さいたま市浦和区'}
{'rest': '1-1', 'town': '市場町', 'prefecture': '千葉県', 'city': '千葉市中央区'}
{'prefecture': '東京都', 'rest': '8-1', 'town': '西新宿二丁目', 'city': '新宿区'}
{'town': '日本大通', 'city': '横浜市中区', 'prefecture': '神奈川県', 'rest': '1'}

Parallel execution

from concurrent.futures import ThreadPoolExecutor

from japanese_address_parser_py import Parser

addresses = [
    "徳島県徳島市万代町1-1",
    "香川県高松市番町4-1-10",
    "愛媛県松山市一番町4-4-2",
    "高知県高知市丸ノ内1-2-20",
]

parser = Parser()
with ThreadPoolExecutor(max_workers=4) as executor:
    results = executor.map(parser.parse, addresses)

for result in results:
    print(result.address)
{'prefecture': '徳島県', 'rest': '1', 'city': '徳島市', 'town': '万代町一丁目'}
{'prefecture': '香川県', 'city': '高松市', 'town': '番町四丁目', 'rest': '1-10'}
{'city': '松山市', 'rest': '4-2', 'town': '一番町四丁目', 'prefecture': '愛媛県'}
{'city': '高知市', 'town': '丸ノ内一丁目', 'rest': '2-20', 'prefecture': '高知県'}

Development

This library is written in Rust. You need to set up a Rust development environment to build this library. Also, you need to install maturin as this library uses it in order to generate Python bindings.

# Install maturin
cargo install --locked maturin
# Clone repository
git clone https://github.com/YuukiToriyama/japanese-address-parser.git
# Build python module
cd japanse-address-parser/python
maturin build --release --out dist --find-interpreter
# Install the built library
python3 -m venv .venv
pip3 install dist/japanese_address_parser_py-[version]-cp37-abi3-[arch].whl

Support

This software is maintained by YuukiToriyama. If you have any questions, please create a new issue.

Where to get source code

The source code is hosted on GitHub at: https://github.com/YuukiToriyama/japanese-address-parser

Acknowledgements

This software was inspired by @geolonia/normalize-japanese-addresses.
In addition, the parsing process uses Geolonia 住所データ which is provided by 株式会社Geolonia.

License

This library is distributed under the terms of the MIT license.

Keywords

converter

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts