Every system needs continuous improvement. Feedback, positive or negative, plays an important role in that improvement. Humans are fairly instinctive in interpreting the tone of the feedback. But, to teach a machine to understand the same, is highly complex. Various algorithms and tools are available today to automatically identify and categorize opinions of any textual feedback.

The application of sentiment analysis is wide and useful. It gives us a wide overview of opinion regarding various topics. Sentiment analysis provides the ability to quickly understand the impact of any product or system and react accordingly.

In one of my works, I applied sentiment analysis to predict the opinion of students regarding various academic dimensions of an institute. It is published at Springer. I used R for the purpose and was playing around with various packages already existing at CRAN but none of them was working according to my need. So, I conceptualized a tool, which applies text mining techniques to elicit insights from textual data and  published it as an open source package (RSentiment) to CRAN.

The algorithm uses Parts of Speech tagging to tag each word in the sentence. I designed various cases on sequence of occurrence of various parts of speech. I checked if there is any adverb or adjective bearing positive score following any negative quantifier  “not” , “no” and accordingly assigned score to it. The package categorizes sentences into 5 categories like:

Very Negative
Very Positive

There are currently 3 methods in the package:

calculate_score: calculates score of a sentence or a collection of sentences as 

calculate_sentiment: classifies a sentence or a text into a sentiment category.

calculate_total_presence_sentiment: calculates total number of sentences 
in each sentiment category.

I am working on it for further improvements. Any feedback will be highly appreciated. My package might be able to benefit from it. 😉





23 thoughts on “RSentiment

  1. Pingback: RSentiment – Mubashir Qasim

  2. I just tried playing around with the package out of curiosity, I’ve not done much with sentiment analysis before.

    > calculate_sentiment(“The concert wan’t bad at all”)
    text sentiment
    1 The concert wan’t bad at all Negative
    > calculate_sentiment(“The concert was not bad at all”)
    text sentiment
    1 The concert was not bad at all Positive

    Liked by 1 person

  3. Out of interest is there much work being done on the semantic analysis of texts? For example the following two would obviously be difficult to categorize;

    > calculate_sentiment(“I’ve been to much better concerts”)
    text sentiment
    1 I’ve been to much better concerts Positive
    > calculate_sentiment(“The worst thing was that the show finally had to end”)
    text sentiment
    1 The worst thing was that the show finally had to end Negative

    But I imagine it is the type of thing that in a few years could be achieved through deep learning type of models.

    Liked by 1 person

  4. Hi,
    my major project is to do sentiment analysis for Telugu language I want to give you example “vamshi killed venkat” is a negative sentence with no adjective or adverb so I think you should even take verbs into consideration.


    • Yes, you are right. But what if the sentence is “Vamshi killed the demon”. What sense I shall consider then.. positive or negative? Need to think about this.


  5. I am looking forward on utilizing this package. Feedback: negation handling still needs work. See this page for negation words.

    Example code highlighting the problem.

    > calculate_sentiment(c(“This helps”, “This does not help”, “This doesn’t help”,”This never helps”))

    text sentiment
    1 This helps Positive
    2 This does not help Neutral
    3 This doesn’t help Positive
    4 This never helps Positive


  6. Pingback: Distilled News | Data Analytics & R

  7. HI Rimi,

    Thank you for the package! I wonder, what lexicon is this based on?

    Also, I’m finding that when I run:

    calculate_sentiment(“My day was good”), I get Positive

    and when I run:

    calculate_sentiment(“My day was good”), I get Negative

    But when I run:

    calculate_sentiment(“My day was not good”) or (“My day was not bad”),

    I get an error message: “Unable to find any JVMs matching version “(null)”.
    No Java runtime present, try –request to install.”

    Any idea why?


  8. Hi Rimi
    I have tried one of the functions in your package. According to the help the expected result should be result 1, but I get 3.
    calculate_custom_sentiment(c(“x x z z x ”), c(“x”),c(“z”))
    It seems like the negative words vector doesn’t work. Just check the simple case:
    calculate_custom_sentiment(c(“z”), c(“x”),c(“z”))
    I get 0.
    Hope to hear from you soon 😊


  9. Hi Rimi

    can u pls explain detail (what is Sentiment Analysis)
    how to analysis Indian dogmatic languages
    pls help……………………………


    • Every word when expressed in particular context has different meanings. To figure out the meaning in given context is known as sentiment analysis. My package is used to analyse sentiment in given context. Kindly provide me an example of such language so that I can give further explanations.


  10. New to R. I originally tried to use the “sentiment” package. When running naiveBayes it uses the following: class_pol = classify_polarity(results[,1], algorithm=”bayes”) . In the RSentiment package, what would be the equivalent?

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s