A simple and configurable text preprocessing library for NLP tasks.
Project description
NLP Text Cleaner
A lightweight, configurable Python library for text preprocessing in NLP tasks.
It helps you clean raw text by lowercasing, removing noise, lemmatizing, and more — ready for machine learning or deep learning models.
✨ Features
- Convert text to lowercase
- Remove special characters
- Remove punctuation (optional)
- Remove numbers or replace them with
<NUM>token - Remove extra spaces
- Lemmatization (default) or stemming (optional)
- Stopword removal (customizable)
- Multi-language support (via NLTK / spaCy)
- Add your own custom stopwords
- Remove Html Tags
- Remove URLs
Installation
From PyPI:
pip install nlp-text-clean
Usage
python
from nlp_text_clean.cleaner import TextCleaner
# Initialize with custom options
cleaner = TextCleaner(
remove_numbers=True,
remove_punctuation=True,
remove_special_chars=True,
use_stemming=False,
use_lemmatization=True,
language="english",
custom_stopwords=None,
preserve_num_token=False,
remove_html_tags=False,
remove_urls=False
)
text = "He scored 100 marks!!! Running better than others."
cleaned = cleaner.clean_text(text)
print(cleaned)
# Output: "score <NUM> mark run well"
Parameters
| Parameter Name | Type | Default | Description |
|---|---|---|---|
| remove_numbers | bool | False | Remove numbers from text |
| preserve_num_token | bool | False | Replace numbers with <NUM> token |
| remove_punctuation | bool | True | Remove punctuation marks |
| remove_special_chars | bool | True | Remove non-alphanumeric characters |
| use_lemmatization | bool | True | Apply lemmatization |
| use_stemming | bool | False | Apply stemming instead of lemmatization |
| stopwords_language | str | "english" | Language for stopwords |
| custom_stopwords | list[str] | None | Add your own stopwords |
| remove_html_tags | bool | False | Remove HTML tags |
| remove_urls | bool | False | Remove Urls |
- Running Tests
pytest
Why use this package?
There are other preprocessing tools (like NLTK or clean-text), but nlp-cleaner is designed to be:
-
Lightweight & Easy to Use → Just one class, minimal setup
-
Highly Configurable → Toggle lemmatization, stemming, number handling, punctuation, etc.
-
Production Ready → Clean and consistent outputs for ML pipelines
-
Customizable → Extend with your own stopwords or language models
-
Multi-language → Works beyond English when supported by spaCy/NLTK
If you want a plug-and-play solution to clean messy text quickly, this is the right tool.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nlp_text_clean-0.1.4.tar.gz.
File metadata
- Download URL: nlp_text_clean-0.1.4.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef13b775dded921e1fd5ba4aa6a14bf8d44fdf4fbdfb145fe577b502f3b22583
|
|
| MD5 |
c0af1a3ead455d9e00fa59554e2b21f3
|
|
| BLAKE2b-256 |
ac51ca1da961d77f4e0e471216139774a8d7ca58047060021224dcb8918d059c
|
File details
Details for the file nlp_text_clean-0.1.4-py3-none-any.whl.
File metadata
- Download URL: nlp_text_clean-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ad1c0c194aca19631d444515935e35335cd0aeaa652a896b48df58cde722f26
|
|
| MD5 |
f59f76f28b8c10df76a015a45a7eb663
|
|
| BLAKE2b-256 |
2e394d3ab3bae4efc3790cc38eca6c0336e75698fc0bdeb41ca3f518cbf3e464
|