开发者

Bucketing sentences by mood

Let's start with a simple problem. Let's say that I have a 350 char sentence and would like to bucket the sentence into either a "Good mood" bucket or a "Bad mood" bucket.

What would be the best way t开发者_高级运维o design an algorithm to bucket the sentence?


Hand-classify a bunch of sentences by mood. Then feed these into a naive Bayes classifier. Use something like SpamBayes as a starting point.


A simple/naive suggestion would be to either first split each sentence down into individual words, or use a regex and scan for specific words from both a "positive" list (e.g. "like", "happy", "can", "do", etc) and a "negative" list ("dislike", "sad", "can't", "don't"), work out which is more prevalent in each sentence, and bucket it accordingly.

Depending on your requirements and data-set this may be adequate, or you might want to investigate more advanced techniques like Bayesian filtering.


Depending on the domain of the sentences and on the required accuracy, this might be an extremely hard problem. There are many academic papers around sentiment analysis; a good start might be here - a short and classic paper.

The steps I'd suggest to take, would gradually lead to a better and better classifier:

  1. Hand classify some documents, and use them to train a ready made algorithm. I'd suggest using SVM (e.g. using LibSVM in WEKA, or SVMLight), but Naive bayes or decision trees, as suggested above, might work too.

  2. Hand classify some more documents, and move from a unigram-based model to a more sophisticated one, e.g. bigram or parts-of-speech based. This can be done quite easily with TagHelper tools, which will take your texts and transform them to WEKA-ready files using these techniques. This will add some context to the mood of each term (eg "not" and "bad" vs. "not bad").

  3. Finally, you can add custom made rules and dictionaries, which would add domain-specific knowledge to your algorithm. They might be represented as additional features for the same classification engine, or as an additional classification step.


This is called Sentiment Analysis, and the Wikipedia article has a good description of available techniques. One easy way out would be to use the Google Prediction API, and train it with a set of positive, negative, and neutral sentiment sentences.


You can play around with the Weka tool to train some classifier that will work well in your case. I would recommend trying the J48 algorithm which I believe is an implementation of the C4.5 algorithm for training decision trees.


Try machine learning from a bunch of such sentences. Use some features, for example smilies as indicators of mood. Observe the quality and add / modify your feature set.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜