“Without knowing the force of words, it is impossible to know more.” –Confucius “My dispatches are merely dry matter of fact and detail.” –Lawrence Gobright, Washington AP Chief (1856) @rabbigreenberg

What’s Love Got To Do With It? Ruby and Sentiment Analysis Ben Greenberg @rabbigreenberg

Who is talking right now? 🤔 (i.e. Hi! “) • I 💙 Ruby • Co-editor of Torah && Tech • Former rabbi & community organizer • 🌎 San Diego ↝ NYC ↝ Boston ↝ Denver ↝ NYC ↝ Tel Aviv 🌍 • Developer Advocate @ Nexmo @rabbigreenberg

Our Roadmap A. Why does this matter? B. What is sentiment analysis? C. What can I build with it? D. Let’s build it! E. Test Run @rabbigreenberg

Why does this matter? @rabbigreenberg

Language is not only a passive vehicle for information @rabbigreenberg

“Last night I had dinner with… someone, it was delicious“ ‫’’אתמול בערב‬ ‫אכלתי ארוחת ערב‬ …‫עם‬ ‫ היא‬, ‫מישהי‬ ’’‫טעיימה‬ @rabbigreenberg

Language is a conduit constructor @rabbigreenberg

What is sentiment analysis? @rabbigreenberg

“ I believe that at the end of the century the use of words and general educated opinion will have altered so much that one will be able to speak of machines thinking without expecting to be contradicted. “ - Alan Turing, 1950 @rabbigreenberg

“Last night I had dinner with someone, it was delicious“ “sentiment”=>{“document”=>{“score”=>0.970908, “label”=>”positive”}} “semantic_roles”=>[{“subject”=>{“text”=>”I”}, “sentence”=>”Last night I had dinner with someone, and it was delicious.”, “object”=>{“text”=>”dinner”}, “action”=>{“verb”=>{“text”=>”have”, “tense”=>”past”}, “text”=>”had”, “normalized”=>”have”}}], “keywords”=>[{“text”=>”Last night”, “relevance”=>0.998604, “count”=>1}, {“text”=>”dinner”, “relevance”=>0.672861, “count”=>1}], “emotion”=>{“sadness”=>0.049938, “joy”=>0.857958, “fear”=>0.041413, “disgust”=>0.034346, “anger”=>0.025449}}}, “categories”=>[{“score”=>0.658246, “label”=>”/food and drink/food”, “explanation”=>{“relevant_text”=>[{“text”=>”dinner”}]}}, {“score”=>0.65732, “label”=>”/ food and drink/desserts and baking” @rabbigreenberg

Natural Language Processing • Formal Grammar • Inflectional Endings • Part-of-speech (POS) tagging • Parsing sentences • Sentence boundaries • Root form of words • Segment continuous text into separate words (prevalent in many languages) • Relationships of named entities to each other (who to whom, what to what, etc.) • Topic segmentation • Word meaning probability @rabbigreenberg

What’s my polarity? “I love my mobile “I’d really truly but would not “I dislike love going out in recommend it to any broken cars.” this weather!” of my colleagues.” *examples from Wikipedia @rabbigreenberg

What can I make with it? @rabbigreenberg

@rabbigreenberg

Sometimes you just need to get to the… @rabbigreenberg

@rabbigreenberg

…and just tell me What’s the mood of the news? @rabbigreenberg

WHAT ARE WE BUILDING (1) “topic” (2) (3) @rabbigreenberg

Let’s build it! @rabbigreenberg

What APIs will will be using? IBM WATSON Natural Language Analyzer API Generous free access tier Ruby SDK Documentation www.ibm.com/watson/developer NEWS API “Search worldwide news with code” Generous free access tier Ruby SDK Documentation www.newsapi.org NEXMO Messages API Generous free access tier Ruby SDK Documentation developer.nexmo.com @rabbigreenberg

Gemfile

@rabbigreenberg

Routes

@rabbigreenberg

Environment Variables

@rabbigreenberg

Controller

Defining Methods @rabbigreenberg

#inbound @rabbigreenberg

#analyze_headlines @rabbigreenberg

#get_news_headlines @rabbigreenberg

#send_whatsapp_msg @rabbigreenberg

#send_whatsapp_msg @rabbigreenberg

#send_whatsapp_msg @rabbigreenberg

#generate_jwt_token @rabbigreenberg

Giving It A Go!

@rabbigreenberg

Thank you! @rabbigreenberg https://github.com/Nexmo/mood-of-the-news