This is the basis of an area of natural language processing called sentiment analysis. Although your question is general, it’s certainly not stupid – this sort of research is done by Amazon on the text in product reviews for example.
If you are serious about this, then a simple version could be achieved by –
-
Acquire a corpus of positive/negative sentiment. If this was a professional project you may take some time and manually annotate a corpus yourself, but if you were in a hurry or just wanted to experiment this at first then I’d suggest looking at the sentiment polarity corpus from Bo Pang and Lillian Lee’s research. The issue with using that corpus is it is not tailored to your domain (specifically, the corpus uses movie reviews), but it should still be applicable.
-
Split your dataset into sentences either Positive or Negative. For the sentiment polarity corpus you could split each review into it’s composite sentences and then apply the overall sentiment polarity tag (positive or negative) to all of those sentences. Split this corpus into two parts – 90% should be for training, 10% should be for test. If you’re using Weka then it can handle the splitting of the corpus for you.
-
Apply a machine learning algorithm (such as SVM, Naive Bayes, Maximum Entropy) to the training corpus at a word level. This model is called a bag of words model, which is just representing the sentence as the words that it’s composed of. This is the same model which many spam filters run on. For a nice introduction to machine learning algorithms there is an application called Weka that implements a range of these algorithms and gives you a GUI to play with them. You can then test the performance of the machine learned model from the errors made when attempting to classify your test corpus with this model.
-
Apply this machine learning algorithm to your user posts. For each user post, separate the post into sentences and then classify them using your machine learned model.
So yes, if you are serious about this then it is achievable – even without past experience in computational linguistics. It would be a fair amount of work, but even with word based models good results can be achieved.
If you need more help feel free to contact me – I’m always happy to help others interested in NLP =]
Small Notes –
- Merely splitting a segment of text into sentences is a field of NLP – called sentence boundary detection. There are a number of tools, OSS or free, available to do this, but for your task a simple split on whitespaces and punctuation should be fine.
- SVMlight is also another machine learner to consider, and in fact their inductive SVM does a similar task to what we’re looking at – trying to classify which Reuter articles are about “corporate acquisitions” with 1000 positive and 1000 negative examples.
- Turning the sentences into features to classify over may take some work. In this model each word is a feature – this requires tokenizing the sentence, which means separating words and punctuation from each other. Another tip is to lowercase all the separate word tokens so that “I HATE you” and “I hate YOU” both end up being considered the same. With more data you could try and also include whether capitalization helps in classifying whether someone is angry, but I believe words should be sufficient at least for an initial effort.
Edit
I just discovered LingPipe that in fact has a tutorial on sentiment analysis using the Bo Pang and Lillian Lee Sentiment Polarity corpus I was talking about. If you use Java that may be an excellent tool to use, and even if not it goes through all of the steps I discussed above.