wordsegment
English word segmentation.
What it is and what it does
WordSegment is a pure-Python library that reconstructs word boundaries in English text where spaces have been removed or are ambiguous. It uses unigram and bigram frequency data derived from the Google Web Trillion Word Corpus to score candidate segmentations and select the most likely split. The package includes 333,000 unigrams and 250,000 bigrams, all lowercased with punctuation removed, and provides both a programmatic API and a command-line interface for batch processing.
The library works by loading corpus frequency tables into memory and then using dynamic programming to find the segmentation that maximizes the product of word frequencies. It handles the canonical form of input (lowercasing, punctuation removal) automatically via a clean() function. Maximum word length is 24 characters, matching the corpus data. The package has no external dependencies and runs on both Python 2 and 3, though it has not been updated since 2018.
Use it for:
- Recover readable words from concatenated text like 'thequickbrownfox' in OCR or data-cleaning pipelines.
- Process hashtags or domain names where word boundaries are unclear, splitting '#pythonrocks' into candidate words.
- Batch-segment large files of unsegmented English text via the command-line interface.
- Analyze corpus frequency data directly (UNIGRAMS and BIGRAMS dictionaries) for linguistic research or spelling preference studies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Splits unsegmented English text into individual words using a corpus-based statistical approach, handling cases where spaces have been removed or are ambiguous.
Yes, if you need English word segmentation and can tolerate an unmaintained package. The library is stable, has no dependencies, and works reliably for its narrow use case. However, the 2960-day gap since the last release means no updates for modern Python versions, security patches, or corpus improvements. Install only if the 2018-era corpus data and Python 3.6 compatibility are sufficient for your task.
Install
wordsegment on PyPI
pip
pip install wordsegmentuv
uv add wordsegmentpoetry
poetry add wordsegmentInstalling wordsegment
Before you install
Installation is straightforward with no runtime dependencies. However, the package has been abandoned since 2018 (2960 days without release) and is no longer maintained, so expect no bug fixes or updates.
License in practice
Licensed under Apache 2.0 (permissive), allowing commercial and private use with minimal restrictions—you may use, modify, and distribute freely provided you include the license notice.
Quickstart
pip install wordsegment
from wordsegment import load, segment
load()
result = segment('thisisatest')
print(result) # ['this', 'is', 'a', 'test']
The load() function must be called once to read corpus data from disk before segmenting; this is a one-time setup cost per process.
Verify before relying
- Whether the corpus data (333,000 unigrams, 250,000 bigrams) remains adequate for modern English or specialized domains.
- Performance characteristics on very long texts or high-volume batch processing.
- Compatibility with Python versions beyond 3.6, given the package's age and lack of maintenance.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,960 days since the last release |
| First released | |
| Downloads | 123,744/month — #11,901 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: wordsegment-1.3.1-py2.py3-none-any.whl
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
segtokSplits Indo-European text into sentences and…
permissive · top 15,000 on PyPI
jieba3kPerforms Chinese word segmentation, breaking…
unclear · top 15,000 on PyPI
curated-tokenizersProvides BPE, Byte BPE, Unigram, and Wordpiece…
permissive · top 5,000 on PyPI
jiebaJieba segments Chinese text into words using…
permissive · top 5,000 on PyPI
english-wordsProvides curated sets of English words from…
permissive · top 15,000 on PyPI
segmentsSegments provides Unicode-aware tokenization…
permissive · top 5,000 on PyPI
wordninjaSplits concatenated words into their…
unclear · top 5,000 on PyPI
unisegDetermines Unicode text segmentation…
permissive · top 15,000 on PyPI
unicode-segmentation-rsProvides Unicode text segmentation (graphemes,…
unclear · top 15,000 on PyPI