なんだか悪い予感がする — スターウォーズ
Star Wars Day tweets with feeling
May the Fourth Be with You
Some variation of the famous line, “I’ve got a bad feeling about this,” is used six different times by five different characters in the Star Wars Series. The words “bad feeling about this” are mentioned in A New Hope, The Empire Strikes Back, & Return of the Jedi, plus a special clip of Luke saying the line from the 1977 The Making of Star Wars: as told by C-3PO and R2D2.
Unfortunately, unless you are a real, actual Jedi, “having a bad feeling” is not going to cut it for most decision making processes. That’s where Natural language Processing (NLP) technology that can detect sentiment in text can come in handy.
Sentiment Analysis in the NLP world is a statistical, or machine learner method to extract, identify, or otherwise characterize the sentiment content of a text unit (this is also sometimes referred to as opinion mining).
Example use cases for sentiment analysis:
- Identifying if customers are satisfied or dissatisfied from their emails, feedback forms or surveys.
- Monitoring social media to analyze and identify how people are responding an ad campaign/product release/news item.
In our case we wanted to get a quick glimpse of the sentiment based around a twitter hash tag, and #MayTheFouthBeWithYou kindly obliged.
Basis Technology has a product called Rosette®, which offers a wide array of tools for text analysis, including high-quality, document-level sentiment analysis for English. Given some text, Rosette Sentiment Analysis identifies each entity (person, product, place etc.) in the document and returns:
- sentiment (positive, negative, neutral)
- a confidence score
- optionally: “explainers”—the top few features/words that most contributed to the score.
What we did
At an internal hackathon we split into teams and competed to develop some innovative ways to put the Rosette API to work. One team applied the Rosette Sentiment Analysis API to Facebook and Twitter posts via a Chrome extension to be able to see at-a-glance and in real time, what the sentiment might be.
This sample Google Chrome extension colors each post as being positive (green) or negative (red). The stronger the sentiment expressed, the darker the color – simple but effective.
You won’t find this extension in the Chrome store just yet, but it is available as a simple proof of concept that you candownload as an unpacked extension and play with.
This is a fairly simplistic example, but who doesn’t love time-saving Chrome extensions, and the adorable BB-8? And any “disturbance in the force” is never a good thing.
Get the extension
Visit the Rosette API Community Github to download the full extension:
Clone the repo and try it for yourself!
Next – get a free API key
Head over to https://developer.rosette.com and sign up for a free 30 day trial. There’s no credit card required and you’ll immediately get access to your API Key to make the Chrome extension work.
Finally – load the extension
Extensions that you download from the Chrome Web Store are packaged up as .crx files, which is great for distribution, but not so great for development. Recognizing this, Chrome gives you a quick way of loading up your working directory for testing. Let’s do that now.
- Visit chrome://extensions in your browser (or open up the Chrome menu by clicking the icon to the far right of the Omnibox: and select Extensions under the Tools menu to get to the same place).
- Ensure that the Developer mode checkbox in the top right-hand corner is checked.
- Click Load unpacked extension… to pop up a file-selection dialog.
- Navigate to the directory in which your extension files now live, and select the folder/directory the files sit in.
Alternatively, you can drag and drop the directory where your extension files live onto chrome://extensions in your browser to load it. If the extension is valid, it’ll be loaded up and active right away! If it’s invalid, an error message will be displayed at the top of the page. Correct the error, and try again.
As Ahsoka Tano said – “This is a new day, a new beginning.”