Ok, yes, that title probably has a little phishing characteristics to it but it was the only thing I could compare on Twitter without getting into trouble and also something I knew would yield some kind of results very quickly given what is going on in the news.
So what I am researching is how brand sentiment could potentially affect campaigns either negatively or positively. So, if you take for instance a campaign that is tagged “#trump” or “#clinton” you can compare over time the sentiment of that campaign. The term being searched for should be fairly unique, once again, that is why I chose “trump” and “clinton”, otherwise you will be bound to get completely irrelevant results. The biggest problem I noticed in the result set was that when Trump and Clinton were mentioned in the same tweet they both scored either negative or positive sentiment. To fix that there would need to be additional logic to understand the structure of the sentence and place the blame on the correct person – unfortunately I won’t be going into that in this post so it is what it is as they say.
I used IBM BlueMix to create a Node-RED application from the Node-RED boilerplate and was able to assemble this application in minutes. If you have not checked out BlueMix you can get a free trial here.
From the Node flow below you can see I have two flows executing simultaneously. Passing each tweet through the Sentiment Analysis node, tagging the result with the name passed in and storing just the sentiment score in the Cloudant database.
The sentiment function uses the AFINN word list to figure out sentiment, once again, not the greatest solution in the end. It then passes it to my custom function where I append the search term to the msg.sentiment object as the query property. I then assign the total sentiment to the msg.payload object because that is what is stored in the database. We might want to add date in the future.
msg.sentiment.query = "clinton";
msg.payload = msg.sentiment;
The result stored in the database is a single record for each tweet analyzed, and as you can see this particular post is exactly what I explained above where the tweet is about Trump calling Clinton a world class liar, so in this case they both received a -3 score. We could minimize what is stored in the future, for instance we may not be interested in the tokens.
However, in general, you might want to compare your brand to another brand and most likely they would not be mentioned in the same tweet like in politics. So, given all of its flaws, here is the average sentiment for “clinton” and “trump” for over 7000 tweets that spanned about 20 minutes.
As you can see, they both are pretty negative sentiments but Clinton is almost twice as bad as Trump. Oh boy.
Now, storing these daily would actually give you average sentiment over time. Meaning you could then compare the campaign or brand sentiment with your other marketing factors, like social engagement, sales, inventory, promotions, campaigns, etc. to understand if social media in fact helps or hinders sales or campaigns.
Like I said, this is barely scientific but I do think overall it averages out over time. I would really appreciate your thoughts on this concept in general ignoring some of the fallbacks my quick little application has on its own.