Registry / ai-ml / clean-text

clean-text

JSON →
library0.7.1pypypiunverified

Clean-Text (pypi: clean-text) provides functions to preprocess and normalize text, making it suitable for various NLP tasks. It offers features like lowercasing, removing emojis, URLs, digits, punctuation, and normalizing whitespace. It is currently at version 0.7.1 and has an active but infrequent release cadence.

pip install clean-text
INSTALL
IMPORT
SIG · CLEAN-TEXT
C
clean-text
ai-mlpythonv0.7.1
Install
1.9s avg
Import
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 29.6MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.9s · import 0.000s · 30MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

clean
from clean_text import clean

Demonstrates the basic usage of the `clean` function. By default, it aggressively preprocesses text by lowercasing, removing emojis, URLs, digits, and punctuation. The example also shows how to customize cleaning behavior by disabling some default transformations.

from clean_text import clean text = " Hello World! 👋 Check out my site: https://example.com This is a test. 123 😊 " cleaned_text = clean(text) print(f"Original: '{text}'") print(f"Cleaned: '{cleaned_text}'") # To customize cleaning, for example, keep emojis and punctuation: text_custom = " Hello World! 👋 This is a test. :) " cleaned_custom = clean(text_custom, no_emoji=False, no_punct=False) print(f"Custom Cleaned: '{cleaned_custom}'")
Debug
Known issues
gotchaThe default behavior of the `clean` function is highly aggressive, performing lowercasing, removing emojis, URLs, digits, and punctuation. This might lead to unexpected data loss if not explicitly configured.
fix
Carefully review the `clean` function's parameters (e.g., `lower=False`, `no_emoji=False`, `no_digits=False`, `no_punct=False`) and set them according to your specific text cleaning needs.
affects: >=0.1.0
gotchaFunctions like `clean_text.remove_emoji` or direct usage of `clean_text.normalize` (for diacritics) require optional dependencies `emoji` and `unidecode` respectively. Calling these directly without installing their corresponding extras will result in an `ImportError`.
fix
Install the necessary optional dependencies using `pip install clean-text[emoji]` for emoji features, `pip install clean-text[normalize]` for diacritic normalization, or `pip install clean-text[all]` for both.
affects: >=0.1.0
gotchaThe `clean` function's `lang` parameter defaults to 'en', which primarily affects stop word removal (if enabled). Using this with non-English text can lead to incorrect behavior if stop words are to be removed.
fix
Specify `lang='your_language_code'` (e.g., `lang='pt'` for Portuguese) when calling `clean` if your text is not English and you plan to use language-dependent features like `remove_stop_words=True`.
affects: >=0.6.0
Upgrade
Version history
0.7.1latest on PyPI · released Jan 28, 2026
Audit
Dependencies
emojioptionalRequired for emoji-related cleaning features (e.g., remove_emoji). Install with `pip install clean-text[emoji]`.
unidecodeoptionalRequired for diacritic removal and advanced text normalization. Install with `pip install clean-text[normalize]` or `pip install clean-text[all]`.
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
clean-text — pip install clean-text · libregistry