Discovering Emotional Content of Reddit with Emot/r

Brinton Foy Reed
4 min readSep 23, 2021

In it’s early days, reddit.com attracted investors such as Peter Thiel, Snoop Dogg and Jared Leto and is now valued at over $10 B. Currently, reddit.com is the 7th most-visited site in the US and the 19th most-visited site in the world (Wikipedia , 2021). Reddit is a place where people can talk about anything, from military trivia to financial investments to marine fish husbandry. With the advent of natural language processing and sentiment analysis, I thought it’d be a great source of emotional data to analyze using IBM Watson Tone Analyzer service.

Using psycholinguistics and machine learning, IBM Watson can infer the emotional tone of the written word, and determine sentimentality on a scale of -1 (negative) to 1 (positive).

Emotional tone is derived from IBM’s work on emotion analysis, which is an ensemble framework that infers emotions from a text. To derive emotion scores from text, IBM uses a stacked generalization-based ensemble framework; stacked generalization uses a high-level model to combine lower-level models to achieve greater predictive accuracy. Features such as n-grams (unigrams, bigrams, and trigrams), punctuation, emoticons, curse words, greetings (such as “hello,” “hi,” and “thanks”), and sentiment polarity are fed into machine-learning algorithms to classify emotion categories (https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-ssbts).

For my final project in Flatiron School’s Software Engineering program, I decided to bring these two technologies together in a simple-to-use app. My app, called Emot/r, enables users to search Reddit comments by Reddit user, subreddit or search terms, or any combination thereof.

After researching several sentiment analysis tools (VaderSentiment-js, Sentimentalizer, AWS Comprehend, etc.), I chose IBM Watson for it’s ability to parse emotional content from text and it’s relative affordability. Next, I developed user stories and developed UX research goals with a friend that had just finished Career Foundry's UX boot camp. While I transitioned user stories into diagrams and models, my friend developed wireframes and talked with users about how they use reddit and how they might use sentiment and emotional analysis.

I used Ruby on Rails on the backend to fetch data from reddit.com and pass it on to Watson for analysis. Once back from Watson, the data is saved to the database and sent to the frontend via a custom JSON object.

For the frontend, I used React to create the HTML and CSS, keeping it a Ruby mono-repo. In order to avoid route confusion between my backend and client-side routing post deployment, I used namespacing on all routes.

The UX study findings, which included input from real reddit users, suggested that most users were likely to access the app using mobile devices. Thus, I was careful to ensure sound responsive design and regularly checked interface using my browser’s console. Using wireframes generated from the UX study, I built the interface with Semantic UI and was fairly impressed with its simplicity.

I used React’s useContext hook to manage global state, which was profoundly convenient, especially when checking user credentials and making the results from Watson’s analysis available to multiple components.

After a good bit of research, I elected to use Recharts to render the emotional responses from Watson. While it was easy to use in general, it’s Responsive.Container component caused React to throw a hooks error, due to it registering another instance of React when rendering. Thus, I had to work around it with .css.

Overall, I had a blast with the project. Next steps include adding a few functionalities that I didn’t have time to implement:

1. Make actual user comments available for perusal from recent searches.

2. Allow users to type in or cut/paste text and receive emotional analysis.

3. Convert the app into a progressive app.

While most everyone can ascertain general sentiment or emotional content by reading Reddit comments themselves, this app does it in a fraction of the time. It also gives users an idea of how specific issues are trending on Reddit overall, and can indicate a user or subreddit’s general tone.

--

--

Brinton Foy Reed

Born in Tulsa, OK, I’ve lived in several states and worked in several countries. Right now, I live in Eugene, OR and am a student at Flatiron School