Skip to main content

sentence-struct

Analyze text into a learner-friendly structure:

document → sentences[] → { tokens[], chunks[] }

Chunks are siblings of tokens and reference them via tokenIndices (not nested).

Japanese (ja) is implemented first via GiNza / Sudachi. More languages later.

Install

pip install sentence-struct
# or
uv add sentence-struct

Optional larger Sudachi dictionary:

pip install "sentence-struct[ja-full]"

Requires Python ≥ 3.11. First install pulls spaCy / GiNza / Sudachi (hundreds of MB).

Usage

from sentence_struct import analyze

doc = analyze("秋が近づくにつれ、朝晩の涼しさが心地よい。", language="ja")
print(doc["sentence_count"], doc["token_count"], doc["chunk_count"])
print(doc["sentences"][0]["tokens"][0])
print(doc["sentences"][0]["chunks"][0])

CLI:

sentence-struct "秋が近づく。"
sentence-struct -f essay.txt -o out.json

Schema (abbreviated)

{
  "language": "ja",
  "text": "...",
  "sentences": [
    {
      "index": 1,
      "text": "...",
      "tokens": [
        {"text": "秋", "pos": "名詞", "posGroup": "名詞", "lemma": "秋", "reading": "アキ"}
      ],
      "chunks": [
        {"type": "NP", "typeGroup": "NP", "tokenIndices": [0, 1], "text": "秋が", "role": "nsubj"}
      ]
    }
  ]
}

Develop (uv)

uv sync
uv run pytest -m "not integration"
uv run pytest -m integration
uv run sentence-struct "今日は良い天気です。"

Release

See RELEASING.md. Tag vX.Y.Z → GitHub Actions builds with uv and publishes to PyPI via Trusted Publishing.

License

MIT

Metadata

Release files for sentence-struct 0.1.0

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

Source distribution (sdist)

Source distribution for sentence-struct 0.1.0
File Size Uploaded
sentence_struct-0.1.0.tar.gz 122.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sentence-struct 0.1.0
File Interpreter ABI Platform
sentence_struct-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 135.6 kB

Release files / sentence_struct-0.1.0.tar.gz

Download URL sentence_struct-0.1.0.tar.gz
Size 122.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8278622765934b6fe93e0dfc9cc2b862f6dbf4ada053468ee11ab48a73dba7ba
BLAKE2b-256 checksum
How to use checksums
141b1bcb153e304f94af05c7d031c2323d596f5cac97f93d02bb4e5850a4027e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sentence_struct-0.1.0-py3-none-any.whl

Download URL sentence_struct-0.1.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48c91933dd7ef742a892fac7fb0315a8fb9f51b8240e58e65d754aecf02f5ed8
BLAKE2b-256 checksum
How to use checksums
9f4831e59809ae98426c137bce2fcf724d838a7a41ed946016349913ab11e5a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

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