Sentiment Analysis

Rate this page:

Sentiment Analysis, or opinion mining, is the process of determining whether language reflects positive, negative, or neutral sentiment. Using sentiment algorithms, developers and brand managers can gain insights into customer opinions about a topic.

Why is sentiment important to measure?

Customer opinion can make or break a brand’s success, and the decision to monitor it can mean the difference between a well-timed course correction or a missed opportunity. Sentiment can also inform marketing and product strategy by revealing chances to reframe the customer experience.

sentiment analysis algorithms derive opinion and feelings from unstructured text

Automated sentiment analysis is a powerful tool for gauging customer opinion at scale. Rather than relying on humans to read and evaluate large volumes of text, an algorithm can process and score sentiment rapidly and efficiently.

How does sentiment analysis work?

You can do simple sentiment analysis by setting up a dictionary-based model. First, create a set of predetermined words with positive and negative values (or find a pre-made dictionary). Then, write a function that parses text, checks for the presence of those words, and uses the preset sentiment values to calculate the overall sentiment of the text. You can layer on additional functionality by including regular expressions and additional code to check for patterns that resemble simple sentence structures. This rule-based approach can be quick to implement but may require significant work to derive a nuanced analysis.

Machine learning (ML) algorithms such as the Naive Bayes Classifier can be used for a more data-driven approach to opinion mining. These models are fed sample datasets and trained to recognize positive, negative, and neutral opinions when they encounter a new piece of text.

Most comprehensive sentiment algorithms will cover:

  • Simple statements -- recognizing the positive word in “I enjoy this program”
  • Negation -- noting the difference between “this product is great” and “this product is not great”
  • Modifiers -- being aware of the emphasis in “I really love this brand”

Advanced approaches can discern the subject and object of opinions, parse complex statements (“I used to prefer shopping in-person, but now I love buying online”), and account for slang (“that move was really sick!”).

How Twilio Can Help Analyze Customer Opinion

Twilio has partnered with IBM Watson to feature the Message Sentiment add-on for Programmable SMS. When activated, this add-on can be used to track opinion across incoming SMS and can be used in support of customer surveys or other feedback-gathering tools.

   "code": null,
   "message": null,
   "results": {
       "ibm_watson_sentiment": {
           "code": null,
           "message": null,
           "request_sid": "XRc1479687aadf64c62e6ab2b6e0077a1a",
           "result": {
                "status": "OK",   
                "usage": "By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use:",    
                "totalTransactions": "1",   
                "language": "english",   
                "docSentiment": {     
                 "mixed": "1",     
                "score": "-0.24582",     
                "type": "negative"   
           "status": "successful"
   "status": "successful"

Sample JSON output from the Twilio Message Sentiment Add-On

Message Sentiment is an easy-to-use tool for mining insights from unstructured message data. IBM Watson’s Natural Language Understanding service is capable of advanced text analysis. The sophisticated algorithm reads text from inbound customer messages, looks for words and phrases indicating sentiment, and scores each message as positive, negative, or mixed. It’s smart enough to understand negation and modifiers and speaks seven languages (with more in development).

Rate this page:

Thank you for your feedback!

Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!