module Cadmium::Sentiment
Overview
Uses sentiment analysis to score a sentence's "feeling". Cadmium::Sentiment
also takes advantage of emojis to further increase accuracy.
Extended Modules
Defined in:
cadmium/sentiment/sentiment.crConstant Summary
-
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 Method Summary
-
.data=(data : String | Nil)
Set the sentiment data.
-
.sentiment_data
Gets the raw sentiment data.
-
.tokenizer : Cadmium::Tokenizer::Base
Manage the
Tokenizer
that the sentiment analyzer uses. -
.tokenizer=(tokenizer : Cadmium::Tokenizer::Base)
Manage the
Tokenizer
that the sentiment analyzer uses.
Instance Method Summary
-
#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).
Class Method Detail
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.
Manage the Tokenizer
that the sentiment analyzer uses.
Manage the Tokenizer
that the sentiment analyzer uses.
Instance Method Detail
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: ["💩"]}