segments
Segmentation with orthography profiles
What it is and what it does
Segments is a Unicode tokenization library that splits text into meaningful units—graphemes, words, or custom segments—based on orthography profiles. It implements the linear algorithm from the Unicode Cookbook's orthography profile specification, allowing you to define how text should be segmented through a profile file that maps grapheme sequences to canonical forms or other output columns.
The package works both as a command-line tool and a Python API. You can build a profile from sample text, edit it to define custom segmentation rules, and then apply it to tokenize new text. It depends on regex for pattern matching and csvw for profile file handling, making it suitable for linguistic analysis, text preprocessing, and language-specific tokenization tasks where Unicode grapheme clusters or custom orthographic rules matter.
Use it for:
- Tokenize text in languages with complex orthographies or diacritics where standard whitespace splitting is insufficient.
- Build and apply custom orthography profiles to normalize or map grapheme sequences in linguistic research or NLP pipelines.
- Preprocess text for phonetic or morphological analysis by defining segment boundaries according to linguistic conventions.
- Extract and analyze grapheme frequency and distribution from text samples via the command-line profile tool.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Segments provides Unicode-aware tokenization and orthography-based text segmentation, using orthography profiles to define how text should be split into meaningful units.
Yes. Segments is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively. Install it if you need Unicode-aware tokenization with orthography profile support for linguistic or text-processing work; skip it if you only need basic whitespace or regex tokenization.
Install
segments on PyPI
pip
pip install segmentsuv
uv add segmentspoetry
poetry add segmentsInstalling segments
Before you install
Low install friction with a pure-Python wheel distribution. Actively maintained with recent commits and stable production status across Python 3.9–3.14.
License in practice
Apache 2.0 is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install segments
from segments import Tokenizer
t = Tokenizer()
print(t('abcd')) # 'a b c d'
Requires Python 3.9 or later.
Verify before relying
- Whether the regex and csvw dependencies introduce any notable security or maintenance concerns beyond what the fact sheet shows.
- Real-world performance characteristics when tokenizing large texts or with complex orthography profiles.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — regex, csvw |
| Maintenance | actively maintained — 160 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,377,896/month — #3,984 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: segments-2.4.0-py2.py3-none-any.whl
Keywords: linguistics, tokenizer
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
unisegDetermines Unicode text segmentation…
permissive · top 15,000 on PyPI
tokenizerTokenizes Icelandic text into words,…
permissive · top 15,000 on PyPI
unicode-segmentation-rsProvides Unicode text segmentation (graphemes,…
unclear · top 15,000 on PyPI
sentencepieceSentencePiece is an unsupervised text tokenizer…
permissive · top 1,000 on PyPI
segtokSplits Indo-European text into sentences and…
permissive · top 15,000 on PyPI
jieba3kPerforms Chinese word segmentation, breaking…
unclear · top 15,000 on PyPI
razdelSplits Russian text into sentences and tokens…
permissive · top 15,000 on PyPI
sacremosesSacremoses provides tokenization,…
permissive · top 5,000 on PyPI
wordsegmentSplits unsegmented English text into individual…
permissive · top 15,000 on PyPI
jiebaJieba segments Chinese text into words using…
permissive · top 5,000 on PyPI