Skip to main content

Add your description here

Project description

jp-range

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

Installation

pip install jp-range
# or install from GitHub
pip install git+https://github.com/neka-nat/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 parse_series 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 parse_series

s = Series(["20~30", "50超", "未満100"])
result = parse_series(s)
# result is a Series of 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)

parse_jp_range raises ValueError 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.1.0.tar.gz (15.5 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.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for jp_range-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc2514421ddd8504c67ebdd6044c2beec1bfc311a32da7583345a55f12b50636
MD5 be3e982c36e09a1a56919ac06098578a
BLAKE2b-256 5b6cef1fda38edbea1e4043b421938daed83dcc92aed97ecf11c9c8000c663c2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for jp_range-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de88aa694ea16ca019213b75ab7a0b26394653404a5c9c85f4b3471261c6a177
MD5 680381dc979a4f617747e73d9d3296b7
BLAKE2b-256 3d648559985cd6da8eb22aa2540ad548919166c0d6ccd82f5e4bf41d60241f32

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