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) via GiNza / Sudachi (furigana + POS coloring).
Other languages tokenize with transparent posGroup/typeGroup "_" (one
chunk per token). Some also fill reading:
| Lang | Tokenizer | reading |
|---|---|---|
en |
spaCy en_core_web_sm |
IPA (/…/; POS only for homographs) |
ko |
Kiwi | Revised Romanization (koroman) |
th |
PyThaiNLP newmm |
romanize |
zh |
jieba | pinyin (tone marks) |
de fr it es tr ru ar |
spaCy blank |
— (tokenize only) |
Install
pip install sentence-struct
# or
uv add sentence-struct
English IPA needs the spaCy small model:
python -m spacy download en_core_web_sm
(Local uv: uv sync --group en-model.)
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])
en = analyze("I refuse the refuse.", language="en")
ko = analyze("안녕하세요", language="ko")
th = analyze("สวัสดีครับ", language="th")
zh = analyze("你好,世界。", language="zh")
CLI:
sentence-struct "秋が近づく。"
sentence-struct -f essay.txt -o out.json
Schema (abbreviated)
{
"language": "ja",
"text": "...",
"sentences": [
{
"index": 1,
"text": "...",
"tokens": [
{
"text": "散歩する",
"posGroup": "動詞",
"reading": "さんぽする",
"segments": [
{"text": "散歩", "reading": "さんぽ"},
{"text": "する"}
]
}
],
"chunks": [
{"type": "NP", "typeGroup": "PHRASE", "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.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sentence_struct-0.7.1.tar.gz | 3.5 MB | Without provenance | Details for sentence_struct-0.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sentence_struct-0.7.1-py3-none-any.whl | Python 3 | none | any | Details for sentence_struct-0.7.1-py3-none-any.whl |
Total release size: 3.5 MB
Release files / sentence_struct-0.7.1.tar.gz
| Download URL | sentence_struct-0.7.1.tar.gz |
|---|---|
| Size | 3.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d75ba463263deebde799921e2d3bd053e8d8d67d8f021b405c00acc7e5cc9b6
|
|
BLAKE2b-256 checksum How to use checksums |
6cc4bcbdb794aaf514d9fe205731c15877287820b4744c023515d4ba6fbd3e66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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.7.1-py3-none-any.whl
| Download URL | sentence_struct-0.7.1-py3-none-any.whl |
|---|---|
| Size | 32.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d98015328f0c9389bf8a25144cdf618f395aecf5d98f1e7e30b7aa0f53d48e39
|
|
BLAKE2b-256 checksum How to use checksums |
49befa3357cffcfdda8774495f8b4b8ed4874517585e6b57dc035ecb7ccf1933
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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}
|
Security for sentence-struct 0.7.1
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.