Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

ian-nai/Simple-Sentiment-Analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Sentiment Analysis

Simple scripts for performing sentiment analysis in Python. This repository is intended as a basic introduction to sentiment analysis using Python, and may be used as a launching point for more in-depth sentiment analysis work. The actual sentiment analysis work is done using Vader, the Natural Language Toolkit (NLTK) and TextBlob. Additional documentation on using NLTK for sentiment analysis can be found here.

Getting Started

Install the code's dependencies: pip install -r requirements.txt

Scrape a Website

Input urls you'd like to scrape in the urls.txt file, then run scrape.py: python scrape.py The script will save the text it scrapes as .txt files in the project's directory. The script searches for <p> tags by default, but what it looks for can easily be edited in the .py file. Just change the line paragraphs = soup.find_all('p') to search for things other than "p".

Perform Sentiment Analysis

Open python, import sentiment.py, and perform sentiment analysis on your texts using Vader, NLTK's Naive Bayes classifier, or TextBlob. The training sentences for the Naive Bayes classifier can easily be swapped out for your own.

>>> python
>>> from sentiment import Sentiment
>>> Sentiment.vader('your_filename.txt')
>>> [sentiment analysis of your text]

for the Naive Bayes classifier:

>>> python
>>> from sentiment import Sentiment
>>> Sentiment.naive('your_filename.txt')
>>> [sentiment analysis of your text]

or for TextBlob:

>>> python
>>> from sentiment import Sentiment
>>> Sentiment.blob('your_filename.txt')
>>> [sentiment analysis of your text]

About

Simple scripts for performing sentiment analysis in Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages