You are using an older browser that might negatively affect how this site is displayed. Please update to a modern browser to have a better experience. Sorry for the inconvenience!

SENTIMENT ANALYSIS


OVERVIEW: 

Sentiment analysis is a major research area in the field of data analytics and computational linguistics. It’s also called as Opinion mining that reflects the emotions, opinions and sentiments of the people expressed over something. i.e. It represents the voice of the customers. Sentiment analysis process is done to derive an output in terms of positive, negative or neutral values. It’s carried out at different levels like Sentence-level, Document-level and Feature-level. In this article, we deal with the sentiment analysis at sentence level.

Sentiment analysis plays a vital role in social networking. Reviews, ratings and online opinions have changed the business process as they help in revealing customer views about the product and provide details regarding competing brands of a product.

WHY SENTIMENT ANALYSIS? 

Sentiment analysis plays a vital role in our life. It’s useful for all levels of people as listed below,

Individuals: To know the product reviews and take wise decision before getting a product. Helps to know the public opinion about a leader, eminent personality etc.

Organizations: To know the customer needs and opinions about a product.

Research: To predict box-office collections and exit polls results.

SENTIMENT ANALYSIS IMPLEMENTATION: 

Step 1: Define arrays or array lists such as goodwords [], neutral [] and badwords [].

Step 2: Import or extract the reviews or user comments.

Step 3: For each word in review compare with goodwords [], neutral [] and badwords [].

  • If the words are present in goodwords [] then increment positive sentiment and total sentiment.
  • If the words are present in badwords [] then increment negative sentiment and total sentiment.
  • If the words are present in neutral [] then increment moderate Opinion and total sentiment.

Step 4:  Calculate the polarity using the following formulae,

Polarity= Positive SentimentTotal Sentiment

Step 5: Display the summary of positive comments, negative comments, neutral comments and the polarity.

Sentiment analysis is widely implemented using Java, C++ or Python. In this article its achieved through Java code.

JAVA SCRIPT: 

//Imports all java io classes like buffer reader, file reader, IOException// 

import java.io. *; 
public class FileExtraction { 
//Extracting file that contains opinions or comments// 
private static final String filename="opinions.txt"; 
public static void main (String [] args) { 
//Initializing buffer reader and file reader// 
BufferedReader br = null; 
FileReader fr = null; 
 //Assigning the file to buffer reader and file reader//  
try { 
fr = new FileReader(filename); 
br = new BufferedReader(fr); 
String sLine; 
 //Defining a list of good words, bad words and neutral words// 
   String goodWords [] = {"good", "excellent", "fabulous", "awesome", "nice"}; 
   String badWords [] = {"bad", "worse", "terrific", "horrible", "disgusting"}; 
   String neutral [] = {"okay", "acceptable", "moderate", "sensible", "unbiased"}; 
   int moderateOpinion=0; 
   int positiveSentiment=0; 
   int negativeSentiment=0; 
   int totalSentiments=0; 
   float polarity; 
      //BufferedReader is used to extract data line by line//    
br = new BufferedReader (new FileReader(filename)); 
while ((sLine = br. readLine ())! = null) { 
For (int i=0; i<5; i++) { 
     //Checks for good words in each comment and increments Positive and total sentiments // 
        if(sLine.contains(goodWords[i])) 
        {positiveSentiment++; 
            totalSentiments++;} 
    //Checks for bad words in each comment and increments Negative and total sentiments // 
        else if(sLine.contains(badWords[i])) 
        {negativeSentiment++; 
           totalSentiments++;} 
   //Checks for neutral words in each comment and increments ModerateOpinion and totalSentiments // 
        else if(sLine.contains(neutral[i])) 
        {moderateOpinion++; 
            totalSentiments++;} 
    }  } 
    //Formulae to determine the polarity// 
    Polarity = ((positiveSentiment / totalSentiments); 
    System.out.println("-------Summary-------"); 
    System.out.println("Positive Reviews : "+positiveSentiment); 
    System.out.println("Negative Reviews : "+negativeSentiment); 
    System.out.println("Neutral Reviews  : "+moderateOpinion); 
    System.out.println("Total Reviews    : "+totalSentiments); 
    System.out.println("Polarity         : "+polarity); 
} 
catch (IOException e) 
{e. printStackTrace ();} 
Finally { 
 Try { 
                                         if (br! = null) 
                    br. close (); 
           if (fr! = null) 
                      fr. close (); 
              } 
catch (IOException e) 
{e. printStackTrace ();} 
}}

SAMPLE INPUT: 

RESULT: 

APPLICATIONS: 

Sentiment analysis is useful in different fields such as,

Fashion: Information about Accessories, Apparels, Designers, Brands etc.

Automobiles: Details regarding Automobile products, Brands, Features, Dealerships etc.

Entertainment: Ratings and information regarding Movies, Concerts, Multiplexes, Shows etc.

Electronics: Provides information about Electronic gadgets, Brands, Showrooms, Dealerships etc.

Books: Details regarding Upcoming releases, Authors, Sale, Libraries, Shops etc.

Online Services: Online store, Gaming services, Search engines, Maps, Social Networking tools etc.

REAL TIME APPLICATIONS 

  1. Most widely used for filtering twitter comments. The pie chart depicted below shows the categorized twitter comments on Trump’s rule.

  • Never Romney [Symbol] Slogan used to oppose the appointment of Mitt Romney as Secretary of State.
  • Mnuchin [Symbol] Person appointed as treasurer by Trump.
  1. Expresses people’s opinion over devices, applications etc. Customer views on Apple iPhone 7 is depicted below,

CHALLENGES: 

Sentiment Analysis can’t detect in-depth sentiments or emotions. Even humans face difficulties if the reviews or comments fall under the following categories.

Sarcasm: Remark that seems to be praising but it will be taunting. e.g. Please keep talking, I always yawn when I am interested.

Inappropriate Comments: Abbreviations, poor spelling, poor punctuation, poor grammar and lack of capitals.

Anaphora Resolution: The problem of resolving what a pronoun, or a noun phrase refers to.  e.g. “We watched the movie and went to dinner; it was awful.” What does “It” refer to?

Named Entity Recognition: Refers to what the person is talking about. e.g.  Is 300 Spartans a group of Greeks or a movie?

CONCLUSION: 

Due to the massive increase in the volume of online users and social networking site users day by day, Sentiment Analysis has a great scope in future. Research is being carried out to overcome the challenges faced by many businesses.

REFERENCE LINKS: 

https://www.slideshare.net/jaganadhg/introduction-to-sentiment-analysis

http://www.clarabridge.com/sentiment-analysis/

https://medium.com/ibm-watson-data-lab/real-time-sentiment-analysis-of-twitter-hashtags-with-spark-7ee6ca5c1585

https://www.crimsonhexagon.com/blog/social-listening-beyond-sentiment-what-unfolded-after-the-iphone-7-release/