4.1. Sentiment analysis on Twitter
4.1.1. Overview of workflow
This use case will show you how sentiment analysis could be carried out on data acquired from the Twitter API using a search term. While the example showcased here makes use of a franchise title ("Star Wars"), put some thought into how the method could be used for more practical purposes by using a different search term. Some examples could be using a restaurant name and looking for Tweets discussing the experience of dining there or perhaps using the title of a recently released film to see how public opinion about it is expressed on Twitter.
If you cannot access the Twitter API, you can easily find an already compiled dataset of tweets on sites like Kaggle. These pre-compiled collections are often thematic in nature and focus on a specific event, brand, or person. Since we will be looking at sentiment in this case study, picking a thematic collection that is likely to contain evaluative speech is likely to be the most rewarding option. A good example would be datasets like the collection of tweets about the eighth season of "Game of Thrones" found here. You will need to sign in to Kaggle in order to access the datasets. If you are using a pre-compiled dataset, replace the first two nodes with an import node appropriate for your dataset's file type.
The workflow is going to make use of quite a lot of metanodes from the NodeHub, so remember that you can expand them in order to have a look at what exactly is going on inside. A tricky aspect of this workflow is that, since we are connecting to the Twitter API, you will need to acquire access to the API by applying for access via Twitter's developer function. In order to connect to the API, elevated access is needed. While this is still free, you will need to submit an application which outlines your intended usage.
The workflow makes use of lexicon-based sentiment analysis, as discussed in lesson 3.2, so it might be a good idea to have a quick re-read of the lesson if you start feeling like you need more support. While the workflow might look a bit complicated at first glance, it is actually a fairly simple process that just happens to contain a lot of small steps. The full workflow is shown below, but we will discuss each section in order.
