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

前端 未结 14 1507
北荒
北荒 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: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.

提交回复
热议问题