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
- preprocess_text(text): Preprocesses the input text based on the initialized flags.
- 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)
| File | Size | Uploaded | |
|---|---|---|---|
| tweetprocessor_1-1.0.0.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|