I am using NodeJs
to create my application with the help of sentiment lib
The problem is that it is giving wrong results when a negative word is used in a positive manner.
var sentiment = require('sentiment');
var result = sentiment('I am dying to eat a kitkat!');
console.dir(result);
{ score: -3, comparative: -0.42857142857142855, tokens: [ 'i', 'am', 'dying', 'to', 'eat', 'a', 'kitkat' ], words: [ 'dying' ],
positive: [], negative: [ 'dying' ] }
///or
result = sentiment('your internet is not bad', knowladgeBase);
console.dir(result);
{ score: -3, comparative: -0.6, tokens: [ 'your', 'internet', 'is', 'not', 'bad' ], words: [ 'bad' ], positive: [], negative: [ 'bad' ] }
if you don't want to implement a sentiment analysis system by yourself than try using another library. But if you are interested in implementing one, here is a solution. In a basic manner, sentiment analysis systems use two approaches to solve the problem. - Lexicon-based approaches - corpus-based approaches
The library you are using, uses a simple lexicon-based algorithm. If you want to have a more advanced system use a sentiment lexicon such as SentiWordNet or SenticNet together with Part-Of-Speech (POS) tagging. You can find negative and positive words. Then use some simple rules. - If a negative word has came with a negative verb, the statement is positive. - If a negative word has came with a positive verb, the statement is negative. - If a positive word has came with a positive verb, the statement is positive. - If a positive word has came with a negative verb, the statement is negative.