pub struct Sentiment {
pub positive_hits: u32,
pub negative_hits: u32,
pub tokens: u32,
}Expand description
The polarity result of scoring a piece of text.
All fields are derived from simple case-insensitive whole-word matching
against POSITIVE_WORDS and NEGATIVE_WORDS.
Fields§
§positive_hits: u32Number of positive lexicon words matched.
negative_hits: u32Number of negative lexicon words matched.
tokens: u32Total tokens the lexicons were matched against (word count).
Implementations§
Source§impl Sentiment
impl Sentiment
Sourcepub fn net(&self) -> i64
pub fn net(&self) -> i64
Net polarity: positive_hits - negative_hits.
Positive when the text leans positive, negative when it leans negative, zero when balanced (or empty).
Sourcepub fn comparison(&self) -> f64
pub fn comparison(&self) -> f64
Comparison score in -1.0..=1.0:
(positive - negative) / (positive + negative).
Returns 0.0 when no polarity words were found.
Proportion of polarity-bearing tokens that are positive, in 0.0..=1.0.
Returns 0.0 when no polarity words were found.
Trait Implementations§
impl Eq for Sentiment
impl StructuralPartialEq for Sentiment
Auto Trait Implementations§
impl Freeze for Sentiment
impl RefUnwindSafe for Sentiment
impl Send for Sentiment
impl Sync for Sentiment
impl Unpin for Sentiment
impl UnsafeUnpin for Sentiment
impl UnwindSafe for Sentiment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more