Skip to main content

A simple and configurable text preprocessing library for NLP tasks.

Project description

NLP Text Cleaner

PyPI Version License Python Versions

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

Installation

From PyPI:

pip install nlp-text-clean
From TestPyPI (for testing):

🚀 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:

  1. Lightweight & Easy to Use → Just one class, minimal setup

  2. Highly Configurable → Toggle lemmatization, stemming, number handling, punctuation, etc.

  3. Production Ready → Clean and consistent outputs for ML pipelines

  4. Customizable → Extend with your own stopwords or language models

  5. 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

nlp_text_clean-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nlp_text_clean-0.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file nlp_text_clean-0.1.1.tar.gz.

File metadata

  • Download URL: nlp_text_clean-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for nlp_text_clean-0.1.1.tar.gz
Algorithm Hash digest
SHA256 78e210b319cd1497da6b6fca820232314192732aabd90911961b20b84a5b7e2b
MD5 98e2b8e9bded28e79e8419667e836e94
BLAKE2b-256 8724678ae7fa7500774202a297c958ef20eaa906f84624427bbcb0db222cd2bc

See more details on using hashes here.

File details

Details for the file nlp_text_clean-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nlp_text_clean-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for nlp_text_clean-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e69a3016e5e62bfb7a2276dbff2ee12f0638c84e668df2f88751bba6352dc1b
MD5 0ef388f96a0fe73e56b055b1ddc3238c
BLAKE2b-256 f377ba389328cb84e03c0283da3ca657cbee2441981923d251741bbc26d0f3bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page