sacremoses
SacreMoses
What it is and what it does
Sacremoses is a Python implementation of the Moses statistical machine translation toolkit's text processing utilities. It provides language-aware tokenization (splitting text into words and punctuation), detokenization (reconstructing text from tokens), truecasing (restoring proper capitalization from all-caps or all-lowercase text), and punctuation normalization. The package wraps the core Moses algorithms and exposes them through both a Python API and command-line interface.
The library is designed for NLP and machine translation preprocessing pipelines. It supports multiple languages through language-specific rules, offers parallel processing via joblib, and can be used programmatically or as a CLI tool with pipeline chaining. Its four main runtime dependencies—regex, click, joblib, and tqdm—handle pattern matching, command-line interfaces, parallel execution, and progress reporting respectively.
Use it for:
- Tokenize raw text for machine translation or NLP model training pipelines.
- Restore proper capitalization in all-caps or ASR output using trained truecasing models.
- Normalize punctuation and control characters in multilingual text datasets.
- Build preprocessing pipelines via CLI with language-specific rules and parallel processing.
- Detokenize model output back into readable text for evaluation or display.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Sacremoses provides tokenization, detokenization, truecasing, and punctuation normalization for text processing, primarily for machine translation and NLP pipelines.
Yes, with conditions. Sacremoses is a stable, permissively licensed tool for standard text preprocessing in NLP workflows. Install it if you need Moses-style tokenization or truecasing for machine translation or similar tasks. However, the aging maintenance status means you should verify compatibility with your current Python and dependency versions before relying on it for production work.
Install
sacremoses on PyPI
pip
pip install sacremosesuv
uv add sacremosespoetry
poetry add sacremosesInstalling sacremoses
Before you install
Low friction installation with a pure Python wheel. Maintenance is aging—last release was 2023-10-30—but the repository remains active with recent commits and no archived status.
License in practice
MIT License permits commercial and private use with minimal restrictions, making it safe for most projects.
Quickstart
from sacremoses import MosesTokenizer, MosesDetokenizer
mt = MosesTokenizer(lang='en')
tokenized = mt.tokenize('This is a test.', return_str=True)
md = MosesDetokenizer(lang='en')
detokenized = md.detokenize(tokenized.split())
Requires Python 3.8 or later; sacremoses>=0.0.41 dropped Python 2 support.
Verify before relying
- Whether the aging maintenance status affects stability or compatibility with current NLP workflows.
- Performance characteristics when processing large text corpora with joblib parallelization.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — regex, click, joblib, tqdm |
| Maintenance | aging — 1,019 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,913,037/month — #2,825 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sacremoses-0.1.1-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
tokenizerTokenizes Icelandic text into words,…
permissive · top 15,000 on PyPI
untokenizeConverts Python tokens back into source code…
permissive · top 15,000 on PyPI
normalityNormality removes diacritics, punctuation, 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
segmentsSegments provides Unicode-aware tokenization…
permissive · top 5,000 on PyPI
indic-nlp-libraryIndic NLP Library provides text processing and…
permissive · top 15,000 on PyPI
semantic-text-splitterSplits long text into semantically meaningful…
permissive · top 15,000 on PyPI
matchMaps tokenized words and phrases back to their…
permissive · top 5,000 on PyPI
curated-tokenizersProvides BPE, Byte BPE, Unigram, and Wordpiece…
permissive · top 5,000 on PyPI