An optimized stopwords list for sentiment analysis that retains key negations like 'not', 'won't', and 'wouldn't', along with intensity modifiers like 'very' and 'most' to preserve sentiment accuracy.
Project description
Revised Stopwords for NLP
Overview
This package provides an optimized stopwords list for sentiment analysis by preserving sentiment-related words that NLTK’s default list would typically remove. By retaining key negations and intensity modifiers, this package ensures that sentiment expressions remain intact, leading to more accurate sentiment classification.
Features
- Retains crucial negations (
not,won't,wouldn't,shouldn't, etc.) - Keeps intensity modifiers (
very,most,more, etc.) for better sentiment retention - Removes only words that do not impact sentiment analysis
Installation
Install via pip
pip install revised-stopwords
Import and Use in Your NLP Pipeline
from revised_stopwords import get_revised_stopwords
# Get the optimized stopwords list
stopwords_list = get_revised_stopwords()
print(stopwords_list) # Output: A set of refined stopwords
Example: Removing Stopwords from Text
from revised_stopwords import get_revised_stopwords
text = "I don't think this is a very good idea"
tokens = text.lower().split() # Basic word split
filtered_tokens = [word for word in tokens if word not in get_revised_stopwords()]
print(filtered_tokens)
# Output: ["don't", 'think', 'very', 'good', 'idea']
Troubleshooting
LookupError: Resource stopwords not found?
Please use the NLTK Downloader to obtain the resource. Run this command once to manually download stopwords
import nltk
nltk.download('stopwords')
ModuleNotFoundError: No module named 'nltk'?
This error means that the nltk library is not installed in your environment.
Ensure NLTK is installed:
pip install nltk
Contributing
Want to improve this package? Feel free to fork the repo, submit PRs, or suggest enhancements!
How to Contribute:
-
Fork this repository to your GitHub account.
-
Clone your forked repo:
git clone https://github.com/priyaa279/revised_stopwords.git
-
Create a new branch for your changes:
git checkout -b feature-branch-name
-
Make your changes and commit them:
git commit -m "Describe your change"
-
Push your branch to GitHub:
git push origin feature-branch-name
Submit a Pull Request (PR) for review. For major changes, please open an issue first to discuss what you'd like to modify.
License
This project is open-source and licensed under the MIT License.
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
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 revised-stopwords-0.1.3.tar.gz.
File metadata
- Download URL: revised-stopwords-0.1.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fbac67a84cb4a2c1d249d5304d6dc488b118aaba17e697a05d26e2f2a5cc19f
|
|
| MD5 |
e88ce1fb1f8cb8fd35340efd983c25f7
|
|
| BLAKE2b-256 |
e08599c9aba143acaa646733d28ba3e9b652af11914aeda5a103f7127cb791b9
|
File details
Details for the file revised_stopwords-0.1.3-py3-none-any.whl.
File metadata
- Download URL: revised_stopwords-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6868f787d3fa82fa8b64eefed2a90b653a98c2b9ae1b5df9a6494150de7b3c5d
|
|
| MD5 |
83f6ef6c3fbbc938ec64977dce2f6b33
|
|
| BLAKE2b-256 |
4a890ddd0aa5dbb5822874261e912a0adc0c2d57a2a97a58e714e33dd8a2979a
|