开发者

How can I analyze pieces of text for positive or negative words?

I'm looking for some sort of module (preferably for python) that would allow me to give that module a string about 200 characters long. The module should then return how many positive or negative words that string had. (e.g. love, like, enjoy vs. hate, dislike, bad)

I'd really like to avoid having to reinvent the wheel in natural language processing, so if there is anything you guys know of that would allow me t开发者_运维问答o do what I described above, it'd be a huge time-saver if you could share.

Thanks for the help!


I think you're looking for sentiment analysis. Here's a Twitter sentiment app.

Here's a question about sentiment analysis using Python.


Before you analyse pieces of text you need to preprocess given text by striping punctuation, repair language, split spaces,lower the whole text and store the words in an iterable data structure.

For some basic sentiment analysis, following techniques can be used:

Bag of words

In bag of words technique we basically go through a bag(file) of words and check if the iterable made by us contains these. If it does then we assign some value to each word's presence in order to weigh the total sentiment of the text. This link should help you understand more about this https://en.wikipedia.org/wiki/Bag-of-words_model

Keyword Extraction and Tagging

Keywords and important information can be extracted from the input text by tagging the elements and then removing unwanted data. For example: My name is John. Here John, name are the information and "is" isn't really needed. Similarly verbs and other unimportant things can be removed in order to retain only the main information. Chunking and Chinking helps. This link must be of help. http://nltk.org/book/ch07.html


You can tokenize your text and get the sentiment using existing sentiment analysis tools. The most comprehensive sentiment analysis tool that I know is SentiBench. This is basically a survey study of all sentiment analysis tools. As well as the code and examples on how to use the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜