Cadmium::Sentiment
Uses sentiment analysis to score a sentence's "feeling". Cadmium::Sentiment
also takes advantage of emojis to further increase accuracy.
Constants
NEGATORS = {"cant" => 1, "can't" => 1, "dont" => 1, "don't" => 1, "doesnt" => 1, "doesn't" => 1, "not" => 1, "non" => 1, "wont" => 1, "won't" => 1, "isnt" => 1, "isn't" => 1, "wasnt" => 1, "wasn't" => 1}
Negate the next word in the phrase.
Class methods
data=(data : String | Nil)
Set the sentiment data. Format should look like:
convince 1
cover - up -3
cramp -1
Where higher numbers are more positive, lower numbers are more negative, and 0 is neutral.
tokenizer=(tokenizer : Cadmium::Tokenizer)
Manage the Tokenizer that the sentiment analyzer uses.
Instance methods
analyze(phrase, inject = nil)
Analyze a phrase and return a result hash comprised of a score,
comparative analysis (a score based soley on number of negative
and positive words), tokens, words, positive (positive words),
and negative (negative words).
pp Cadmium::Sentiment.analyze("You are a piece of 💩")
# => {score: -1,
# comparative: -1,
# tokens: ["You", "are", "a", "piece", "of", "💩"],
# words: ["💩"],
# positive: [],
# negative: ["💩"]}