A little while ago, I stumbled across a ~9 year old github repo someone made that is a really cool idea for creating a simple twitter sentiment analyzer with ruby.
I thought it was pretty neat, and thought it could be fun to take the general concept and use it to build out a tiny, general purpose, sentiment analysis program.
I took the original text library being used from that project and converted it to json, which can be found here (loading the text version would probably be faster, but starting with a json version allows us to avoid writing additional code to convert it within our script).
From there, the general idea is pretty simple for the script - basically we're just trying to break apart user input and search for matches against our word bank.
Once I got a that working, I thought it would be interesting to look at ways we could potentially further optimize this script- for example, trying to clean the user input to avoid edge cases. Then, getting a little more advanced, I started looking at ways you could make this script a little bit smarter, for example by trying to also analyze n-grams.
There's no fancy deep-learning, but I think it's a pretty cool albeit simple idea.
All of this is included below in a short ~30 minute video I put together. It only takes about 15 minutes to get the initial sentiment script functioning, then the rest is some of the optimization stuff. Check it out!
Video: Sentiment Analysis with Ruby (in 32 Minutes)
Want to try it out? I built a public facing version of this script you can test here: senty.xyz
If you enjoyed this, be sure to check out the original project this was inspired by.