Algorithm to determine how positive or negative a statement/text is

前端 未结 14 1453
北荒
北荒 2020-12-07 07:21

I need an algorithm to determine if a sentence, paragraph or article is negative or positive in tone... or better yet, how negative or positive.

For instance:

<
相关标签:
14条回答
  • 2020-12-07 07:54

    There are many machine learning approaches for this kind of Sentiment Analysis. I used most of the machine learning algorithms, which are already implemented. my case I have used

    weka classification algorithms

    • SVM
    • naive basian
    • J48

      Only you have to do this train the model to your context , add featured vector and rule based tune up. In my case I got some (61% accuracy). So We move into stanford core nlp ( they trained their model for movie reviews) and we used their training set and add our training set. we could achieved 80-90% accuracy.

    0 讨论(0)
  • 2020-12-07 07:56

    This is an old question, but I happened upon it looking for a tool that could analyze article tone and found Watson Tone Analyzer by IBM. It allows 1000 api calls monthly for free.

    0 讨论(0)
  • 2020-12-07 07:57

    You can do like this:

        Jason is the worst SO user I have ever witnessed (-10)
    

    worst (-), the rest is (+). so, that would be (-) + (+) = (-)

        Jason is an SO user (0)
    

    ( ) + ( ) = ( )

        Jason is the best SO user I have ever seen (+10)
    

    best (+) , the rest is ( ). so, that would be (+) + ( ) = (+)

        Jason is the best at sucking with SO (-10)
    

    best (+), sucking (-). so, (+) + (-) = (-)

        While, okay at SO, Jason is the worst at doing bad (+10)
    

    worst (-), doing bad (-). so, (-) + (-) = (+)

    0 讨论(0)
  • 2020-12-07 07:58

    Depending on your application you could do it via a Bayesian Filtering algorithm (which is often used in spam filters).

    One way to do it would be to have two filters. One for positive documents and another for negative documents. You would seed the positive filter with positive documents (whatever criteria you use) and the negative filter with negative documents. The trick would be to find these documents. Maybe your could set it up so your users effectively rate documents.

    The positive filter (once seeded) would look for positive words. Maybe it would end up with words like love, peace, etc. The negative filter would be seeded appropriately as well.

    Once your filters are setup, then you run the test text through them to come up with positive and negative scores. Based on these scores and some weighting, you could come up with your numeric score.

    Bayesian Filters, though simple, are surprisingly effective.

    0 讨论(0)
  • 2020-12-07 07:59

    Most of the sentiment analysis tools are lexicon based and none of them is perfect. Also, sentiment analysis can be described as a trinary sentiment classification or binary sentiment classification. Moreover, it is a domain specific task. Meaning that tools which work well on news dataset may not do a good job on informal and unstructured tweets.

    I would suggest using several tools and have an aggregation or vote based mechanism to decide the intensity of the sentiment. The best survey study on sentiment analysis tools that I have come across is SentiBench. You will find it helpful.

    0 讨论(0)
  • 2020-12-07 08:02

    In my company we have a product which does this and also performs well. I did most of the work on it. I can give a brief idea:

    You need to split the paragraph into sentences and then split each sentence into smaller sub sentences - splitting based on commas, hyphen, semi colon, colon, 'and', 'or', etc. Each sub sentence will be exhibiting a totally seperate sentiment in some cases.

    Some sentences even if it is split, will have to be joined together.

    Eg: The product is amazing, excellent and fantastic.

    We have developed a comprehensive set of rules on the type of sentences which need to be split and which shouldn't be (based on the POS tags of the words)

    On the first level, you can use a bag of words approach, meaning - have a list of positive and negative words/phrases and check in every sub sentence. While doing this, also look at the negation words like 'not', 'no', etc which will change the polarity of the sentence.

    Even then if you can't find the sentiment, you can go for a naive bayes approach. This approach is not very accurate (about 60%). But if you apply this to only sentence which fail to pass through the first set of rules - you can easily get to 80-85% accuracy.

    The important part is the positive/negative word list and the way you split things up. If you want, you can go even a level higher by implementing HMM (Hidden Markov Model) or CRF (Conditional Random Fields). But I am not a pro in NLP and someone else may fill you in that part.

    For the curious people, we implemented all of this is python with NLTK and the Reverend Bayes module.

    Pretty simple and handles most of the sentences. You may however face problems when trying to tag content from the web. Most people don't write proper sentences on the web. Also handling sarcasm is very hard.

    0 讨论(0)
提交回复
热议问题