Analysing World Leader Tweet Sentiment With Azure AI


Posted on September 17, 2020

As you may or may not know using Azure Cognitive Services is super easy and is a great first step into experimenting with AI having done some famous Poker Player poker face analysis using the emotion API myself previously and plan to create an emotion camera app 📱 at some point in the future. 📅

This time I wanted to use Azure to do some data collation as well as AI analysis on text. Specifically on tweets and specifically on the tweets of world leaders*.

Why not start at the top right? 👑

I also have a domain buying problem, so I went and bought WorldLeaderTweets.com. 💰🤦‍♂️

The idea is to collate the tweets of world leaders, analyse them and present them in a central place all in Azure. To what end? A bit of fun really, curiosity in the technology and the identification of any interesting patterns. I've not really given it much more thought than that. So you're up to speed on my motivations. 🔍

Process

have however given some thought to the implementation..

  1. Retrieve the Tweets using the Twitter API of X number of world leaders. Possibly using an Azure Function on a timer (serverless yey!) or possibly using Twitters streaming API and Azures Stream Analytics for realtime processing. But that may be overkill.
  2. Store the tweets in Azure Storage. With another Azure Function that watches the storage for inserts. When triggered communicates with the Azure Cognitive Services.
  3. Analyse the tweets using Azure Cognitive Services and Text Sentiment Analysis then store the results back into Azure Storage.
  4. Retrieve and present the Tweets and analysis results on a website or Power BI.
No alt text provided for this image

Forgive the rushed diagram, it was created using Microsoft Expression Design, which is awesome BTW.

Analysis

As well as the sentiment, there are a number of things I could look at. Including the leaders age, sex, geography, tweet frequency etc etc and see how they correlate with sentiment if at all.

Presentation

Probably via simple web app or perhaps I may stretch my Power BI muscles.

Other possibilities

You could analyse the tweets from Global CEOs, or other peer networks. Sports people? ⚽

Summary

It will be interesting to analyse the tweets of world leaders.

I'm not sure when i'll have time to put this experiment together, it may be in stages starting with collation. I've got a few other priorities at the moment and I need to hit my publishers November deadline with my Augmented Reality for .NET developers book.

Take care and watch out for updates.

-- Lee

 

*For the record, I am not a very politically motivated person. I vote (like everybody should) and make sure I understand the political agenda, manifesto and repercussions of whom I vote for (like everybody should). I'm just not very vocal about my political opinions and this post and experiment is not intended to promote or demote any particularity political party or personality.

** Whilst looking at the approach for this, I noticed a few other people doing the same thing so please don't this is completely original.

https://towardsdatascience.com/understanding-political-twitter-ce3476a38377

https://docs.microsoft.com/en-us/azure/stream-analytics/stream-analytics-twitter-sentiment-analysis-trends

https://codewithsarath.com/real-time-twitter-sentiment-analysis-with-azure-stream-analytics-and-cosmos-db/