Skip to main content

TextPreprocessor

Overview

The TextPreprocessor is a Python class designed for comprehensive text preprocessing. It facilitates tasks like removing links, hashtags, special characters, emojis, numbers, and stopwords. Additionally, it provides functionality for converting text to lowercase.

Installation

Ensure you have NLTK installed. You can install NLTK via pip:

pip install nltk

Usage

### Import the TextPreprocessor class
from text_preprocessor import TextPreprocessor
# Initialize the preprocessor with default settings
preprocessor = TextPreprocessor()

# Customize the preprocessor by setting flags
preprocessor = TextPreprocessor(
    remove_links=True,
    remove_hashtags=True,
    remove_characters=True,
    convert_to_lowercase=True,
    remove_emojis=True,
    remove_numbers=True,
    remove_stopwords_flag=True
)



text = "Your text goes here..."


processed_text = preprocessor.preprocess_text(text)

Available Methods

  1. preprocess_text(text): Preprocesses the input text based on the initialized flags.
  2. Other methods in the class can be used individually for specific preprocessing steps (e.g., remove_links, remove_stopwords, etc.).

Examples

text = "Hello! This is an example text with #hashtags and links: https://example.com"



# Initialize preprocessor
preprocessor = TextPreprocessor(remove_links=True, remove_hashtags=True)

# Preprocess text
processed_text = preprocessor.preprocess_text(text)
print(processed_text)
Output: "Hello This is an example text with and links"

License

This project is licensed under the MIT License - see the LICENSE file for details.

Release files for tweetprocessor-1 1.0.0

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

Source distribution (sdist)

Source distribution for tweetprocessor-1 1.0.0
File Size Uploaded
tweetprocessor_1-1.0.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tweetprocessor-1 1.0.0
File Interpreter ABI Platform
tweetprocessor_1-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / tweetprocessor_1-1.0.0.tar.gz

Download URL tweetprocessor_1-1.0.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1eb9725d89f9663e2cf114c9bc8eaeb2077ae5cf8cf502cb9750501dc366f9b4
BLAKE2b-256 checksum
How to use checksums
71387153b3fbd89508d7e229b6a56b89f4acc62a0eb0e89fd18ce3ab79dc770e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release files / tweetprocessor_1-1.0.0-py3-none-any.whl

Download URL tweetprocessor_1-1.0.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a34bf903276a8eab7d4acd227402aac18d536ed5f63487be8f599d0c32868b49
BLAKE2b-256 checksum
How to use checksums
c36981e0e42ec9df28379d1d5e1e1425303a6835ea3f001ffa3e21a21664290e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

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