Skip to main content

🧹 textcleaner-partha

PyPI version License

A lightweight and reusable text preprocessing package for NLP tasks. It cleans text by removing HTML tags and emojis, expanding contractions, correcting spelling, and performing lemmatization using spaCy.

✨ Features

•	✅ HTML tag and emoji removal
•	✅ Stopword removal
•	✅ Contraction expansion (e.g., “can’t” → “cannot”)
•	✅ Abbreviation expansion (e.g., “asap” → “as soon as possible”)
•	✅ Spelling correction with autocorrect
•	✅ Lemmatisation using spaCy (en_core_web_sm)
•	✅ Filters out stopwords, punctuation, numbers
•	✅ Retains only nouns, verbs, adjectives, and adverbs
•	✅ Returns tokens in a text

🚀 Installation

From PyPI:

pip install --upgrade textcleaner-partha

Install directly from GitHub:

pip install git+https://github.com/partha6369/textcleaner.git

🧠 Usage

from textcleaner_partha import preprocess

text = "I can't believe it's already raining! 😞 <p>Click here</p>"

# Default usage (all features enabled)
cleaned = preprocess(text)
print(cleaned)

# Custom usage with optional features disabled
cleaned_partial = preprocess(
    text,
    lemmatise=False,            # Skip spaCy processing (lemmatisation, POS filtering)
    correct_spelling=False,     # Skip spelling correction
    expand_contraction=False    # Skip contraction expansion
)
print(cleaned_partial)
from textcleaner_partha import get_tokens

text = "I can't believe it's already raining! 😞 <p>Click here</p>"

# Default usage (all features enabled)
tokens = get_tokens(text)
print(tokens)

# Custom usage with optional features disabled
tokens_partial = get_tokens(
    text,
    lemmatise=False,            # Skip spaCy processing (lemmatisation, POS filtering)
    correct_spelling=False,     # Skip spelling correction
    expand_contraction=False    # Skip contraction expansion
)
print(tokens_partial)

🔧 Parameters

The preprocess() and get_tokens() functions offer flexible control over each text cleaning step. You can selectively enable or disable operations using the parameters below:

def preprocess(
    text,
    lowercase=True,
    remove_html=True,
    remove_emoji=True,
    remove_whitespace=True,
    remove_punct=False,
    expand_contraction=True,
    expand_abbrev=True,
    correct_spelling=True,
    lemmatise=True,
)
def get_tokens(
    text,
    lowercase=True,
    remove_html=True,
    remove_emoji=True,
    remove_whitespace=True,
    remove_punct=False,
    expand_contraction=True,
    expand_abbrev=True,
    correct_spelling=True,
    lemmatise=True,
)

📦 Dependencies

•	spacy
•	autocorrect
•	contractions

You can install them manually or via the included requirements.txt:

pip install -r requirements.txt

And download the required spaCy model:

python -m spacy download en_core_web_sm

📄 License

MIT License © Dr. Partha Majumdar

Metadata

Release files for textcleaner-partha 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for textcleaner-partha 1.1.2
File Size Uploaded
textcleaner_partha-1.1.2.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textcleaner-partha 1.1.2
File Interpreter ABI Platform
textcleaner_partha-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 29.6 kB

Release files / textcleaner_partha-1.1.2.tar.gz

Download URL textcleaner_partha-1.1.2.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
31eb247de29b98172660181fa0475b298c2f8cf0d45ff56b4707bcf12d5630c8
BLAKE2b-256 checksum
How to use checksums
b43e6a4955a41a667b3c15fca7f5775437b466d57a9d1c075ce343839f62dc46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / textcleaner_partha-1.1.2-py3-none-any.whl

Download URL textcleaner_partha-1.1.2-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70e1188ba178ae368cd06f8fb0160dd883878ae01cff5272eb9b03a65fc37368
BLAKE2b-256 checksum
How to use checksums
454f3c87bae058127227b71bf67efb61c42e7ad217a64c985d4b45ec32f1162f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page