Analyze the sentiment and emotional content of Reddit content using machine learning!
Use Emot/r on Heroku
Table of Contents
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.
To get Emot/r up and running, please follow these steps.
-
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.
-
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
- Clone the repo
git clone https://github.com/bfreed76/Reddit-Sentiment-Analyzer.git
- Install NPM packages
npm install
- Install dependencies
bundle install
- Create .env file in root directory
touch .env
- 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
- Ensure that your .gitignore file includes all .env files
# ./gitignore *.env
- Start postgres server
sudo service postgresql start
- Create and seed the database
rails db:create rails db:seed
- Install npm and start React server
npm install --prefix client npm run --prefix client
- Start rails server
rails s
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.
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.
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.
I set up the postgres database with the following data structure.
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.
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License.
Project Link: Emot/r See more apps on my profile page »
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!