前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Analyze tweets in under 30 minutes using Node-RED

Analyze tweets in under 30 minutes using Node-RED

作者头像
首席架构师智库
发布2018-04-09 11:38:35
7240
发布2018-04-09 11:38:35
举报
文章被收录于专栏:超级架构师超级架构师

I created a Node-RED app in Bluemix which searches for a specified keyword, username, or hashtag phrase in the public Twitter universe whenever a new tweet is posted. This application can be created in less then 30 minutes by anyone and requires no coding experience. When a tweet is posted that matches the provided search criteria, the tweet is passed through the sentiment analysis node which returns a sentiment value.

If that sentiment value has a value less than -5 (which is a very negative tweet) then the app sends me an email with the word “tweets/” and the username who wrote the tweet in the subject header and the actual tweet in the body. This allows me to catch any very negative tweets about the search terms within a couple of seconds.

Below is an example email alert:

Quick introduction to creating Node-RED applications

A Node-RED app is created by dragging and dropping nodes—pre-written pieces of code that perform desired actions—on the left hand side of the Node-RED editor into the middle work space. The nodes are then connected by clicking the output point of one node and dragging it to the input point of another node (the little grey squares on either side of a node):

Lastly and most importantly, each node has to be given the proper parameters by double clicking on it and filling in the form that pops up:

Once those steps are completed, you click the Deploy button on the top right corner of the editor and your application will be running. Simply stated, Node-RED applications are just programmable nodes that you wire together.

My Node-RED tweet sentiment app

As shown earlier, my entire Node-RED application consists of just five nodes. The first node will search Twitter for the desired keywords entered into the form after double clicking on the node. You will need to authenticate to your Twitter username, which will allow the application to search all public tweets. To specify the search keywords fill in the “for” parameter with a word, username, or hashtag keyword that you want to retrieve all tweets containing that term (I used #testnegative as my keyword for testing purposes).

Next I added the sentiment analysis node and connected its input to the output of the Twitter node. This node will analyze all tweets that match the search term and assign them a sentiment value (this node does not need any parameters unless you want to change the name of the node itself). Average sentiment values will range from -5 to 5 with -5 being a very negative tweet, 0 being a neutral tweet and 5 being a very positive tweet. Anything outside of those ranges are extreme values and the tweets I want to capture. I then added a debug node called “debug sentiment value” to print out the sentiment value to the Node-RED debug log on the right side of the editor (this node is not required but helps to see sentiment values).

Below are some example sentiment values based on the given tweet:

  • Sentiment value of 4: #testnegative Jim’s fries is awesome!
  • Sentiment value of -3: #testnegative Jim’s fries is the worst restaurant ever!
  • Sentiment value of -4: #testnegative Jim’s fries is the worst restaurant ever! I could not pay with a debit card!
  • Sentiment value of -5: #testnegative Jim’s fries is the worst restaurant ever! I could not pay with a debit card! No one should ever go here!
  • Sentiment value of -8: #testnegative Jim’s fries is the worst restaurant ever! I could not pay with a debit card! No one should ever go here! Horrible service!

The sentiment value is then passed to a “switch” node which looks for tweets with a sentiment value that is less than or equal to -5. In the diagram above, noted that I renamed my switch node to “Analyze how negative”. If the sentiment value falls into this category, then an email is sent from my Gmail account to my work email:

Conclusion

That is the entire application; as you can see, there is absolutely no coding necessary. The only requirements are to drag and drop nodes, fill them out, and connect them. This app idea can be transformed in many ways. The app can be used to find very positive tweets, the app can send specified tweets containing multiple keywords to a Slack chat, the Twilio node can be integrated to have tweets be sent to your cell phone as a text, and many more implementations to analyze any tweet by anyone within a couple of seconds of it being posted. To try out Node-RED on Bluemix, go to the Bluemix Node-RED Pageafter you have signed up for your free 30 day Bluemix trial.

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2015-11-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 首席架构师智库 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Quick introduction to creating Node-RED applications
  • My Node-RED tweet sentiment app
  • Conclusion
相关产品与服务
大数据
全栈大数据产品,面向海量数据场景,帮助您 “智理无数,心中有数”!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档