pub struct SentimentAnalyzer;Expand description
Rule-based sentiment analyser with negation and intensifier support.
No external dependencies — works entirely from static word lists.
Implementations§
Source§impl SentimentAnalyzer
impl SentimentAnalyzer
pub fn new() -> Self
Sourcepub fn analyze(&self, text: &str) -> Sentiment
pub fn analyze(&self, text: &str) -> Sentiment
Analyse the sentiment of text and return a Sentiment.
The algorithm:
- Tokenise by whitespace, lowercasing and stripping punctuation.
- Walk tokens left-to-right, tracking negation and intensifier state.
- Accumulate a raw score; collect matched keywords.
- Normalise score to [-1.0, 1.0] and derive a label.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SentimentAnalyzer
impl RefUnwindSafe for SentimentAnalyzer
impl Send for SentimentAnalyzer
impl Sync for SentimentAnalyzer
impl Unpin for SentimentAnalyzer
impl UnsafeUnpin for SentimentAnalyzer
impl UnwindSafe for SentimentAnalyzer
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.