Sentiment score of a complete message using Python NLTK

3.4k Views Asked by At

I have tried a lot from other relevant stack overflow discussions, but could not find what I am looking for.

What I want is this: for a given message (i.e., paragraph with one or more sentences), I want to have a sentiment score in the range -5 to +5.

The Valder module with the nltk.sentiment package provides three different scores: pos, neu, and neg. But this is not what I want.

Is there any way to do it using nltk sentiwordnet?

2

There are 2 best solutions below

1
On

You will have to train your data set from a corpora or a pre defined data set which has separate positive and negative training sets and then compare your data with that.

The algorithm is how you compare your training data set with the test data set to get a numeric value of how similar the data set is.

Keep in mind that the training data set should be similar to the test data set.

Then you can use various algorithms like Naive Bayes or MultiBinomial etc.

1
On

this link may be somewhat useful to find the opinion of a sentence as positive or negative

do changes for scores as needed