2

I am doing a project in Java, and I am looking for some open-source/tool that will given a sentence return if the sentence has a negative or a positive meaning.

For example:

  1. I have a problem-Negative.
  2. I don't have a problem-Positive.
  3. I have a working connection-Positive

Does such tool exist?

StKiller
  • 7,631
  • 10
  • 43
  • 56
Eddie Dovzhik
  • 297
  • 1
  • 6
  • 14
  • 5
    What do you feel when you ask if such a tool exists? – Ingo Nov 30 '11 at 10:24
  • I don't think I cannot say you are wrong... – fortran Nov 30 '11 at 10:31
  • I am not talking about crazy sentences with sarcasm and 7 different negatives. Something a little more basic. – Eddie Dovzhik Nov 30 '11 at 10:39
  • 1
    Apparently too basic, IMHO. How is, for instance, "I have a problem." negative? Do you think, for instance, that "I do not have the slightest problems with alcohol." is positive, even if uttered by a well known alcoholic? – Ingo Nov 30 '11 at 11:20

4 Answers4

2

I do not know of a tool that will do this particular task. I believe most of them are tight to specific needs and won't be easily portable. However, one way of doing it will be to have your set of positive and negative words predefined. Then, given an input sentence count the positive and negative words in it and whichever number is greater, this will be your conclusion. Check here : http://en.wikipedia.org/wiki/Sentiment_analysis . This thread may be of help too: Algorithm to determine how positive or negative a statement/text is

Community
  • 1
  • 1
Petar
  • 2,241
  • 1
  • 24
  • 38
  • `Then, given an input sentence count the positive and negative words in it and whichever number is greater, this will be your conclusion.` isn't this a bit too naive? Let's say: "problem" is a negative word, then how about `It worked out without the slightest problems.` – Ingo Nov 30 '11 at 10:37
  • Its not naive. A lot of sentiment analysis tools work with similar ideas in mind. "It worked out without the slightest problems" is a difficult challenge that cannot be easily solved :) I just tried to give the guy some directions. – Petar Nov 30 '11 at 11:38
  • Maybe it's not naive. Maybe it's a clever trick of the marketing industry to get people to pay more for placing advertising on pages with alledgedly "positive" sentiments. After all, the computer says it's 87% positive sentiment, therefore it must be true, right? – Ingo Nov 30 '11 at 17:11
  • I dont get the point you are trying to make :) I dont think it is relevant to the question asked. – Petar Nov 30 '11 at 22:27
1

I can not imagine that such a tool exists. (Because that would mean to recognize Sarcasm, and I know this was some research topic.)

Ralph
  • 118,862
  • 56
  • 287
  • 383
  • A tool may exists, yet if it's reliable is another question. – Ingo Nov 30 '11 at 10:35
  • 1
    @Ingo: Is that (your comment) a positive or negative sentence? – Ralph Nov 30 '11 at 10:59
  • depends on whether you count sceptizism as positive or negative. :) This is, IMHO, the main question in this issue: apparently it is thought that "positive" and "negative" are givens. – Ingo Nov 30 '11 at 11:16
  • Don't let the perfect get in the way of the good. Surely there are no tools that get it 100% correct, but you can reasonably easily get to 80% accuracy for review data. – Rob Neuhaus Nov 30 '11 at 13:51
  • How do you measure accuracy of figures about sentiments? – Ingo Nov 30 '11 at 17:08
  • Ask humans to label a sample of data. See how often the machine agrees with the human. – Rob Neuhaus Nov 30 '11 at 19:31
1

You could get started with the basic ideas of Eliza there is also a java implementation it does primitive natural language processing.

stacker
  • 68,052
  • 28
  • 140
  • 210
0

I find this question overly simplistic. For over a decade, entire teams of researchers have been trying to identify sentiment in text. Even the simplest sentences are often difficult, and are highly context-dependent. For example

Read the book.

is a positive sentence if it appears in a book review. The same sentence is negative if it appears in a movie review. As Ingo points out, simply counting positive/negative words will not work out at all. The placement of negators in the parse-tree of the sentence matters, and as my example shows, there are many sentences with no positive/negative words, but different sentiment polarities in different contexts. Here's another example off the top of my head

The crazy movie held its audience captive.

but,

The crazy king held the peasants captive.

Chthonic Project
  • 8,216
  • 1
  • 43
  • 92