Skip to content

Analyze sentiment and emotional content of Reddit search terms, contributors and subreddits using IBM Watson's Natural Language Processing.

License

Notifications You must be signed in to change notification settings

bfreed76/Reddit-Sentiment-Analyzer

Repository files navigation


Emot/r

Analyze the sentiment and emotional content of Reddit content using machine learning!
Use Emot/r on Heroku

Table of Contents
  1. About Emot/r
  2. Getting Started
  3. Startup
  4. Background
  5. Contributing
  6. License
  7. Contact Me
  8. Acknowledgments

About Emot/r

screenshot3

Emot/r uses IBM Watson's Natural Language Understanding to extract emotional content and overall sentiment from Reddit content. Users can use any combination of search terms, Reddit usernames, or subreddits to narrow their search.

Use Emot/r to:

  • determine the emotional content (sadness, joy, fear, anger, disgust) of a Reddit user's posts or an entire subreddit.
  • explore general sentiment from all Reddit users on a particular topic.
  • track emotional content around specific social issues or interests.

Due to IBM Watson's monthly usage limits, I have capped the search results at the last 50 comments posted to Reddit. If you would like to see increased max count or have feature requests, such as inclusion of Reddit submmissions or an option to search by date, please email me with your request. Please write "Emot/r feature request" in the subject line.

Built Using

React ReactRouter PostgreSQL Heroku Ruby Rails IBMWatson SemanticUI

(back to top)

Getting Started

To get Emot/r up and running, please follow these steps.

Prerequisites

Linux Windows *Not tested on MacOS

  • Please ensure you are using Ruby version 2.7.4.

    ruby -v 
  • IBM Watson Natural Language Understanding (NLU) account: follow the link to set up your free account.

    • Once you have a cloud account, you can create a Natural Langauge Understanding project by selecting 'create resource' from your dashboard.
  • IBM Watson credentials

  • Emot/r uses the following additional gems (loads automatically from Gemfile)

    • bcrypt: user authentication/password hashing
    • postgresql: required database for deployment to Heroku
    • email validator: validate user email addresses
    • httparty: enable connection to Web-based APIs from the backend
    • ibmwatson: enables use of IBM Watson from the backend
    • dotenv-rails: seperates IBM Watson credentials from sourcecode
    • rufo: ruby file formatter

Installation

  1. Clone the repo
    git clone https://github.com/bfreed76/Reddit-Sentiment-Analyzer.git
  2. Install NPM packages
    npm install
  3. Install dependencies
    bundle install
  4. Create .env file in root directory
    touch .env
  5. Add IBM Watson NLU credentials to .env file
    # ./env
    NATURAL_LANGUAGE_UNDERSTANDING_APIKEY=[ your IBM Watson API key ]
    NATURAL_LANGUAGE_UNDERSTANDING_IAM_APIKEY=[ your IBM Watson API key ]
    NATURAL_LANGUAGE_UNDERSTANDING_URL=[ your IBM Watson credentails URL ]
    NATURAL_LANGUAGE_UNDERSTANDING_AUTH_TYPE=iam
  6. Ensure that your .gitignore file includes all .env files
    # ./gitignore
    *.env
    

Startup

  1. Start postgres server
    sudo service postgresql start
  2. Create and seed the database
    rails db:create 
    rails db:seed
  3. Install npm and start React server
    npm install --prefix client
    npm run --prefix client
  4. Start rails server
    rails s

(back to top)

Background

The idea for this app came from a conversation with a friend about natural language understanding. As a previous military crytolinguist, I've always had an interest in language, and how it frames our worldview and actions. Given all of the talk in the last few years about fake news and social media news, we thought pairing sentiment analysis with reddit posts would provide telling information about subreddits, Reddit users and Reddit content, as a whole.

screenshot

I collaborated with a Career Foundary UX grad and his mentor, a seasoned UX designer. They helped me refine my user cases and user stories, and provided wireframes.

usecases

They also conducted a small (n=5) study with Reddit users and found that nearly all subjects would prefer to use the app on a mobile device. Thus, I developed the app according to responsive design principles.

studyscreenshot

I set up the postgres database with the following data structure.

database

Due to the potentially large datasets involved and the required use of credentials, I decided to access Reddit data (via pushshift api) and apply IBM Watson NLU analysis from Rails, instead of from the frontend.

backend_code

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement." Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License.

(back to top)

Contact Me

Linkedin Badge Instagram Badge Medium Badge Gmail Badge

Project Link: Emot/r See more apps on my profile page »

(back to top)

Acknowledgments

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!

(back to top)

About

Analyze sentiment and emotional content of Reddit search terms, contributors and subreddits using IBM Watson's Natural Language Processing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published