Every call to analyze() returns a Result with a label and four numbers. This page explains where they come from.
$result = Sentiment::analyze('VADER is smart, handsome, and funny.');
$result->compound; // 0.8316
$result->positive; // 0.746
$result->neutral; // 0.254
$result->negative; // 0.0
$result->label; // Label::Positive
Compound
compound is the one number to use when you want a single score. It runs from -1 (extremely negative) to +1 (extremely positive), rounded to four decimals.
It is computed in three steps:
- Every word found in the lexicon contributes its valence (-4 to +4), adjusted by the rules below.
- The valences are summed.
- The sum is normalized so it always lands between -1 and +1. Long, strongly worded text approaches the limits but never passes them.
Because of that last step, a compound of 0.5 does not mean “50% positive”. Read it as a position on a scale: close to 0 is neutral, close to ±1 is emphatic.
Positive, neutral and negative
positive, neutral and negative are ratios between 0 and 1, rounded to three decimals. They show how the text splits between positive signal, negative signal and everything else, and they add up to about 1.
For VADER is smart, handsome, and funny., 74.6% of the signal is positive, none is negative, and the remaining 25.4% is neutral (words with no sentiment, such as VADER and is).
These ratios are not probabilities. A text that is mostly neutral words with one mildly positive word can have a high neutral and still a clearly positive compound. Use them to see how a text is built, and use compound (or the label) to decide.
Label
The Label is derived from compound and the threshold:
| Condition | Label |
|---|---|
compound >= threshold (and above 0) |
Label::Positive |
compound <= -threshold (and below 0) |
Label::Negative |
| anything else | Label::Neutral |
The default threshold is 0.05, the value recommended by the VADER authors.
What changes a score
The model does not just add up word values. These rules shape the result:
| Rule | Example | Effect |
|---|---|---|
| Negation | not good |
Flips and softens the word |
| Intensifier | very good, extremely bad |
Strengthens the word |
| Dampener | kind of good, slightly bad |
Weakens the word |
| ALL CAPS | this is GREAT |
Strengthens the shouted word |
| Exclamation marks | great!!! |
Adds emphasis, up to 4 marks |
| Question marks | great??? |
Adds a little emphasis |
| Contrast | good food but terrible service |
The part after “but” weighs more |
| Emoticons and emoji | :), ❤️, 😠 |
Count as sentiment words |
For example, these English texts are in increasing order of positivity: not good, good, very good, VERY good!!!.
Indonesian has the same rules plus intensifiers that come after the word (bagus banget), contrast words such as tapi and namun, and informal negations such as gak. See Languages.
Examples
| Text | Label | Compound | Pos | Neu | Neg |
|---|---|---|---|---|---|
| This package is awesome!English | positive | 0.6588 | 0.594 | 0.406 | 0.000 |
| The movie was good.English | positive | 0.4404 | 0.492 | 0.508 | 0.000 |
| The movie was not good.English | negative | -0.3412 | 0.000 | 0.624 | 0.376 |
| It isn't bad at all.English | positive | 0.4310 | 0.416 | 0.584 | 0.000 |
| The service was extremely good.English | positive | 0.4927 | 0.444 | 0.556 | 0.000 |
| The service was kind of good.English | positive | 0.3832 | 0.343 | 0.657 | 0.000 |
| The plot was good, but the ending was terrible.English | negative | -0.4939 | 0.149 | 0.534 | 0.317 |
| I LOVE this phone.English | positive | 0.7125 | 0.622 | 0.378 | 0.000 |
| The concert was great!!!English | positive | 0.7163 | 0.624 | 0.376 | 0.000 |
| Thanks for the help :)English | positive | 0.8225 | 0.811 | 0.189 | 0.000 |
| Loved the show 😍English | positive | 0.7845 | 0.580 | 0.420 | 0.000 |
| Worst day ever 😭English | negative | -0.8020 | 0.000 | 0.357 | 0.643 |
| The meeting is at 3 pm.English | neutral | 0.0000 | 0.000 | 1.000 | 0.000 |
| Filmnya bagus banget!Indonesian | positive | 0.6230 | 0.671 | 0.329 | 0.000 |
| Makanannya enak sekali.Indonesian | positive | 0.5849 | 0.655 | 0.345 | 0.000 |
| Pelayanannya tidak ramah.Indonesian | negative | -0.3570 | 0.000 | 0.446 | 0.554 |
| Tempatnya nyaman tapi harganya mahal.Indonesian | negative | -0.1280 | 0.267 | 0.400 | 0.333 |
| Aku BENCI antrean panjang!!!Indonesian | negative | -0.6817 | 0.000 | 0.394 | 0.606 |
| Hotelnya lumayan, tapi kamarnya kotor.Indonesian | negative | -0.6428 | 0.162 | 0.324 | 0.514 |
| Kamera hp ini keren parah 😍Indonesian | positive | 0.7778 | 0.492 | 0.508 | 0.000 |
| Besok rapat jam 3 sore.Indonesian | neutral | 0.0000 | 0.000 | 1.000 | 0.000 |
Tips
- Classify with the label, rank with
compound. - Empty or whitespace-only text gives all zeros and a neutral label.
- Text with no known words is neutral. The model only knows what its lexicon knows; add your own words for domain slang.
- Long text is better analyzed sentence by sentence. See Long text.