A simple text preprocessing package for CSL data
Project description
Text preprocessing python package
Installation
You can install this package using pip as follows
pip install preprocess_csl
Install form github
You can install this package from Github as follows:
pip install git+https://github.com/Jubayer07/preprocess_csl.git --upgrade --force-reinstall
Uninstall the package
To uninstall the package user the following commands
bash
pip uninstall preprocess_csl
Requirements
You need to install these python package
pip install spacy==3.8.13
python -m spacy download en_core_web_sm==3.8.0
pip install nltk==3.9.2
pip install beautifulsoup4==4.13.5
pip install textblob== 0.20.0
Download NLTK Data
You need to download NLTK data as follows:
import preprocess_csl as pcsl
pcsl.download_nltk_data()
How to Use the Package
1. Basic Text Preprocessing
Lowercasing Text
import preprocess_csl as pcsl
text = "HELLO WORLD!"
processed_text = pcsl.to_lower_case(text)
print(processed_text) # Output: hello world!
Expanding Contractions
import preprocess_csl as pcsl
text = "I'm learning Natural Languge Processing."
processed_text = pcsl.contraction_to_expansion(text)
print(processed_text) # Output: I am learning Natural Languge Processing.
Removing Emails
import preprocess_csl as pcsl
text = "Contact me at example@example.com"
processed_text = pcsl.remove_emails(text)
print(processed_text) # Output: Contact me at
Removing URLs
import preprocess_csl as pcsl
text = "Check out https://example.com"
processed_text = pcsl.remove_urls(text)
print(processed_text) # Output: Check out
Removing HTML Tags
import preprocess_csl as pcsl
text = "<p>Hello World!</p>"
processed_text = pcsl.remove_html_tags(text)
print(processed_text) # Output: Hello World!
Removing Special Characters
import preprocess_csl as pcsl
text = "Hello @World! #NLP"
processed_text = pcsl.remove_special_chars(text)
print(processed_text) # Output: Hello World NLP
2. Advanced Text Processing
Lemmatization
import preprocess_csl as pcsl
text = " ate eating eats"
processed_text = pcsl.lemmatize(text)
print(processed_text) # Output: eat
Sentiment Analysis
import preprocess_csl as pcsl
text = "I love programming!"
sentiment = pcsl.sentiment_analysis(text)
print(sentiment) # Output: Sentiment(polarity=0.5, subjectivity=0.6)
3. Feature Extraction
Word Count
import preprocess_csl as pcsl
text = "I Like Natural Language Processing."
count = pcsl.word_count(text)
print(count) # Output: 5
Character Count
import preprocess_csl as pcsl
text = "I Love Python programming! It's amazing. 123"
count = pcsl.char_count(text)
print(count) # Output: 38
N-Grams
import preprocess_csl as pcsl
text = "I love NLP"
ngrams = pcsl.n_grams(text, n=2)
print(ngrams) # Output: [('I', 'love'), ('love', 'NLP')]
4. Full Example: Cleaning Text
Here’s an example of how you might use several functions together to clean text data:
import preprocess_csl as pcsl
text = "I'm loving this NLP tutorial!"
cleaned_text = pcsl.clean_text(text)
print(cleaned_text)
# Output: i am loving this nlp tutorial
Feature Extraction
import preprocess_csl as pcsl
pcsl.extract_features("I love Natural Language Processing")
Project details
Release history Release notifications | RSS feed
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 preprocess_csl-0.1.0.tar.gz.
File metadata
- Download URL: preprocess_csl-0.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65decbadddde50935c39525afc3652cb9e746b66b20c06978559f1c34a18a4c3
|
|
| MD5 |
40adfec7c25354667126032e9ced506b
|
|
| BLAKE2b-256 |
171b3fa0e84ab056486a9a77fc8994cfdc8e08c9bb6dc2fe85271daa31cbbd23
|
File details
Details for the file preprocess_csl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: preprocess_csl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8b7bcd094c527369c38b30543b40cee3f434e5fe23f211901dcb7cf00783d59
|
|
| MD5 |
34ce71f6646ad277ab4b9bb3d4fde675
|
|
| BLAKE2b-256 |
eddd01b7793c8ce9baba2abe09aa021e48f539833240fc2c9e720a2150daa023
|