Skip to main content

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:
# 0     [20.0, 30.0]
# 1      (50.0, inf)
# 2    (-inf, 100.0)
# dtype: object

# Expand columns into numeric min/max
df = apply_parse(s.to_frame(name="range"), split_numeric=True)
# df:
#    range_max  range_min
# 0       30.0       20.0
# 1        NaN       50.0
# 2      100.0        NaN

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.

Metadata

Release files for jp-range 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jp-range 0.4.2
File Size Uploaded Provenance Actions
jp_range-0.4.2.tar.gz 21.7 kB Without provenance Details for jp_range-0.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jp-range 0.4.2
File Interpreter ABI Platform Actions
jp_range-0.4.2-py3-none-any.whl Python 3 none any Details for jp_range-0.4.2-py3-none-any.whl

Total release size: 29.4 kB

Release files / jp_range-0.4.2.tar.gz

Download URL jp_range-0.4.2.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
71c7c81918873bd2c5302a3c2fe20319cd7eaacd58ffd303ea029b5551f88de8
BLAKE2b-256 checksum
How to use checksums
4af4ae7bddbb2950671424fc66fd41626f7ecf2f4196133fd19c46cb8b2481cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.13

Release files / jp_range-0.4.2-py3-none-any.whl

Download URL jp_range-0.4.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed1d5a42cd4e88d3691eeb89fb283ba11ac25be86815562cb1836f9a819e00e2
BLAKE2b-256 checksum
How to use checksums
23cba988797bf06580f202447cb983dbb6e2992a17f584e7d7f62888254cda7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.13

Security for jp-range 0.4.2

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page