Skip to main content

Utilities for parsing Japanese numeric ranges.

Project description

jp-range

jp-range is a small library for parsing Japanese numeric range expressions. It returns an Interval object implemented with Pydantic or None when parsing fails.

Installation

pip install jp-range
# or install from GitHub
pip install git+https://github.com/first-automation/jp-range.git

Python 3.12 or later is required.

Features

  • Normalizes full width numbers and common punctuation
  • Supports inclusive and exclusive bounds (以上, 未満, etc.)
  • Parses connectors such as , - and から
  • Handles single-sided bounds, approximate expressions (90前後) and A±d notation
  • Integrates with pandas via apply_parse for Series and DataFrame

Usage

Basic parsing

from jp_range import parse

interval = parse("40以上50未満")
print(interval)               # [40, 50)
print(interval.contains(45))  # True

Pandas integration

from pandas import Series
from jp_range import apply_parse

# Convert Series of textual ranges to pandas.Interval
s = Series(["20~30", "50超", "未満100"])
result = apply_parse(s)
# result is a Series of pandas.Interval objects

Supported expressions

  • "20から30" – inclusive 20 to 30
  • "20〜30" – inclusive 20 to 30 using a tilde connector
  • "30以上40以下" – inclusive 30 to 40
  • "40以上50未満" – 40 to under 50
  • "70超90以下" – greater than 70 and up to 90
  • "50より上" – greater than 50
  • "60より下" – less than 60
  • "90前後" – roughly around 90 (5% margin)
  • "(2,3]" – standard interval notation

parse_jp_range returns None if the expression cannot be parsed.

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

jp_range-0.2.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jp_range-0.2.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file jp_range-0.2.0.tar.gz.

File metadata

  • Download URL: jp_range-0.2.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for jp_range-0.2.0.tar.gz
Algorithm Hash digest
SHA256 69d3b94a246ee7b8255c99a62b20da845f1e0ffbb7ef0b16ea6bdc4281dc2720
MD5 e966c6e8a685d56779329c19e1c0badb
BLAKE2b-256 4446ebbf5dd1d784fbee3bf708db4c39353551a745ec12840b238a1fc5a5dd8f

See more details on using hashes here.

File details

Details for the file jp_range-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: jp_range-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for jp_range-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7e4b4f9811c3ee994891abd751e4e0ab528c44bec741bac7c3ac15d7d215539
MD5 dbe67945305f2599afd16f2c195b71fd
BLAKE2b-256 883f35ed738373006b5611e6240c15003914cd72c45ae9d19f90ae0044a4aa17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page