Twitter Sentiment Analysis

7 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.28
List Price:  €96.12
You save:  €28.84
£55.93
List Price:  £79.91
You save:  £23.97
CA$98.01
List Price:  CA$140.02
You save:  CA$42.01
A$107.87
List Price:  A$154.11
You save:  A$46.23
S$94.42
List Price:  S$134.90
You save:  S$40.47
HK$544.78
List Price:  HK$778.29
You save:  HK$233.51
CHF 62.22
List Price:  CHF 88.89
You save:  CHF 26.67
NOK kr779.46
List Price:  NOK kr1,113.56
You save:  NOK kr334.10
DKK kr501.79
List Price:  DKK kr716.88
You save:  DKK kr215.08
NZ$119.98
List Price:  NZ$171.41
You save:  NZ$51.43
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.18
৳8,402.58
List Price:  ৳12,004.20
You save:  ৳3,601.62
₹5,911.93
List Price:  ₹8,445.97
You save:  ₹2,534.04
RM312.68
List Price:  RM446.70
You save:  RM134.02
₦118,358.68
List Price:  ₦169,091.08
You save:  ₦50,732.40
₨19,451.98
List Price:  ₨27,789.74
You save:  ₨8,337.75
฿2,421.30
List Price:  ฿3,459.15
You save:  ฿1,037.85
₺2,419.75
List Price:  ₺3,456.94
You save:  ₺1,037.18
B$406.81
List Price:  B$581.19
You save:  B$174.37
R1,266.21
List Price:  R1,808.95
You save:  R542.74
Лв131.43
List Price:  Лв187.77
You save:  Лв56.33
₩98,455.31
List Price:  ₩140,656.47
You save:  ₩42,201.16
₪260.61
List Price:  ₪372.31
You save:  ₪111.70
₱4,125.84
List Price:  ₱5,894.31
You save:  ₱1,768.47
¥10,813.84
List Price:  ¥15,449
You save:  ¥4,635.16
MX$1,432.62
List Price:  MX$2,046.69
You save:  MX$614.07
QR256.35
List Price:  QR366.23
You save:  QR109.88
P959.91
List Price:  P1,371.36
You save:  P411.45
KSh9,063.70
List Price:  KSh12,948.70
You save:  KSh3,885
E£3,476.67
List Price:  E£4,966.88
You save:  E£1,490.21
ብር8,762.26
List Price:  ብር12,518.05
You save:  ብር3,755.79
Kz63,877.12
List Price:  Kz91,256.94
You save:  Kz27,379.82
CLP$68,152.06
List Price:  CLP$97,364.26
You save:  CLP$29,212.20
CN¥507.37
List Price:  CN¥724.85
You save:  CN¥217.47
RD$4,236.71
List Price:  RD$6,052.70
You save:  RD$1,815.99
DA9,355.50
List Price:  DA13,365.57
You save:  DA4,010.07
FJ$159.32
List Price:  FJ$227.62
You save:  FJ$68.29
Q542.77
List Price:  Q775.43
You save:  Q232.65
GY$14,710.67
List Price:  GY$21,016.15
You save:  GY$6,305.47
ISK kr9,775.50
List Price:  ISK kr13,965.60
You save:  ISK kr4,190.10
DH703.21
List Price:  DH1,004.63
You save:  DH301.41
L1,276.61
List Price:  L1,823.81
You save:  L547.19
ден4,112.73
List Price:  ден5,875.58
You save:  ден1,762.85
MOP$563.70
List Price:  MOP$805.33
You save:  MOP$241.62
N$1,272.29
List Price:  N$1,817.64
You save:  N$545.34
C$2,573.53
List Price:  C$3,676.63
You save:  C$1,103.10
रु9,461.06
List Price:  रु13,516.38
You save:  रु4,055.32
S/267.08
List Price:  S/381.56
You save:  S/114.48
K283.05
List Price:  K404.37
You save:  K121.32
SAR262.80
List Price:  SAR375.44
You save:  SAR112.64
ZK1,938.90
List Price:  ZK2,769.98
You save:  ZK831.07
L334.76
List Price:  L478.25
You save:  L143.49
Kč1,707.89
List Price:  Kč2,439.96
You save:  Kč732.06
Ft27,663.65
List Price:  Ft39,521.19
You save:  Ft11,857.54
SEK kr779.03
List Price:  SEK kr1,112.95
You save:  SEK kr333.92
ARS$70,272.32
List Price:  ARS$100,393.34
You save:  ARS$30,121.01
Bs485.83
List Price:  Bs694.07
You save:  Bs208.24
COP$310,661.31
List Price:  COP$443,820.90
You save:  COP$133,159.58
₡35,743.76
List Price:  ₡51,064.70
You save:  ₡15,320.94
L1,776.85
List Price:  L2,538.46
You save:  L761.61
₲551,865.53
List Price:  ₲788,413.13
You save:  ₲236,547.59
$U2,996.30
List Price:  $U4,280.61
You save:  $U1,284.31
zł292.33
List Price:  zł417.63
You save:  zł125.30
Already have an account? Log In

Transcript

Video 3.9 Twitter sentiment analysis. In this video, we'll learn how to analyze tweets. So let's start to analyze tweets, we need to first get them. And for that note, it has a special node called Twitter node. You can find that in your palette under the social category. There are two nodes, one to get tweets and one to post them.

Like I said before, we need to get tweets and to see what it outputs. Let's connect and debug node. To configure like, always, open its properties. You need to add your Twitter credentials to access tweets. Remember, all API's use some sort of authentication before allowing you to access their data like that. Here in Twitter API, you first have to create your own app and use the API keys and access tokens generated in the app in the Twitter node to get data.

Click create an app, after which you will have a set of configuration phases. It might take some time for you to get your app credentials once you submit a request, so I'm going to use the one I already have. Once everything is done, you can find your app under the app Step. Select the app, and you can find the API keys and tokens under the keys and token tab. copy these credentials into the Twitter node. You have different types of search options.

You can choose any one, I'm going to choose public tweets. Next, you have to enter the keywords which needs to be searched. Let's put node red. Give it a nice name and we are done. Now, deploy There is an error rate limit hit. Yes.

This happens, because the free developer API's we use to talk to Twitter have pulled more tweets than Twitter allows us to do for free. If you deploy the flows multiple times within a 15 minute window, you may exceed the limit. And we'll see errors from the note. These errors will clear when the current 15 minute window passes. The error can also go within 15 minutes at times. Now, I have to deploy many times to show you what happens at every step.

So it is okay if you don't follow me at every step. I have attached the final flow in the resources you can use it if you want to. Okay, for now, we have to create our own tweets. So let's tweet something about no dread. Now check if you've got it in the debug console. So, yeah, here it is.

Now let's analyze the tweet. for that. There is something called sentiment node. Under the analysis section in the pallet. sentiment node is a Node JS module that uses a fi nn 165 word list to perform sentiment analysis on a block of input text. Let's use it and see what we get inserted between the two nodes.

You don't have to configure anything here, because by default, it will analyze data in the message dot payload, which is having the tweet. Let's deploy and see what we get. So there is the tweet object we saw before. Then there is another newly added object called the sentiment under this the score What matters, mine is a positive statement. So it is three. If your comment has a lot of negative words, your score will be negative.

And if it has positive words the score will be positive, and if it is neutral, you will get zero. If you want to know more about this, check out the resources. Now I want to tweet something or the same thing whenever I encounter positive and neutral tweets and send a mail to another account whenever I encounter negative tweets. We can use a switch node for this. Zero is neutral. So greater than or equal to zero is what we want.

Next, add a Twitter output node for the greater than equal to zero and add an email node for the other branch can Figure your email node, you have to add the mail address from which you want to send an email, and the email ID to which you want the mail to be sent. You can leave the other options as it is. Note that you must turn on allow less secure apps from your mail account to allow notary to access your mail id and send a mail. Without doing that you will get an error. When we use a Twitter node for posting tweets, there are certain parameters which we can pass, you can check that in the link I've added in the resources. I'm also adding a function node to send a special tweet like this.

So I'm using the username of the tweet received to send a tweet. Now deploy and check if it works. Let's tweet and see Yes, I'm getting a mail. And I'm also able to see my tweet Could I have given a flow of function node with some dashboard nodes, I want you to import them and arrange them this way. Now what this does is the function node calculates the number of tweets you have done using the counter technique, which will be outputted as an audio or put when you click a button in the dashboard. The other text node helps you to show all the good and neutral tweets in the dashboard note.

Your number of retweets is 25. Cool, right? This is one of the many ways you can customize your flows. One other way is to create a web page which will list all your tweets. Use the Tone Analyzer node to check the tone of tweet and use it as a condition to go to some other page and display the tweets there. There are endless possibilities.

I want you to try everything till you are out of ideas. If you get stuck, you can do a Google search to find an answer. And if you're really stuck, then I'm always here to help you. In this video, we saw how to do sentiment analysis on tweets using the Twitter node. In the next section, we'll work on building a weather station

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.