Skip to main content

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

import nltk
nltk.download('punkt')  # Ensure tokenization is available
from nltk.tokenize import word_tokenize

text = "I don't think this is a very good idea, but it's not the worst."
tokens = word_tokenize(text)

filtered_tokens = [word for word in tokens if word.lower() not in get_revised_stopwords()]
print(filtered_tokens)  # Output retains sentiment words!

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:

  1. Fork this repository to your GitHub account.

  2. Clone your forked repo:

    git clone https://github.com/priyaa279/revised_stopwords.git
    
  3. Create a new branch for your changes:

    git checkout -b feature-branch-name
    
  4. Make your changes and commit them:

    git commit -m "Describe your change"
    
  5. 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

revised_stopwords-0.1.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

revised_stopwords-0.1.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file revised_stopwords-0.1.2.tar.gz.

File metadata

  • Download URL: revised_stopwords-0.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for revised_stopwords-0.1.2.tar.gz
Algorithm Hash digest
SHA256 146ec1cce08fa526d1a7b3a51405fc4cd6b20cca1369e467e3a023edf9311eea
MD5 8cf5857a54687979ff935edb4de1602c
BLAKE2b-256 8ca6334d534876664c534d36a98715f845b831727f214cf97a2e9f0269ed5a4d

See more details on using hashes here.

File details

Details for the file revised_stopwords-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for revised_stopwords-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ea8324d41c7583ec4bdf8d817898aecd6a330960ca5f24ed55827a55bb26581
MD5 7ab6bd28816f32d8ddf75bee8fe8b0ee
BLAKE2b-256 90783bc578a215b4bfd3575f859fd2986d1742368f628b4ac01766dd8a09de6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page