pub struct SentimentIntensityAnalyzer { /* private fields */ }Expand description
The analyzer, holding the loaded lexicons.
Construction parses the vendored VADER 3.3.2 data once, and scoring
reuses the parsed tables. Two analyzers are interchangeable: same input,
same bits, which tests/properties.rs asserts.
Implementations§
Source§impl SentimentIntensityAnalyzer
impl SentimentIntensityAnalyzer
Sourcepub fn new() -> SentimentIntensityAnalyzer
pub fn new() -> SentimentIntensityAnalyzer
Build an analyzer over the vendored VADER 3.3.2 lexicons.
Infallible: the data is vendored and its digests are enforced by
tests/provenance.rs before any caller exists.
Sourcepub fn polarity_scores(&self, text: &str) -> SentimentScores
pub fn polarity_scores(&self, text: &str) -> SentimentScores
Score one text. Total: every &str input returns scores.
Text with nothing scoreable is neutral, not an error, exactly as the reference scores it:
use vader_parity::SentimentIntensityAnalyzer;
let analyzer = SentimentIntensityAnalyzer::new();
assert_eq!(analyzer.polarity_scores("is?").compound, 0.0);
assert_eq!(analyzer.polarity_scores("is?").neu, 1.0);
assert_eq!(analyzer.polarity_scores("").compound, 0.0);Trait Implementations§
Auto Trait Implementations§
impl Freeze for SentimentIntensityAnalyzer
impl RefUnwindSafe for SentimentIntensityAnalyzer
impl Send for SentimentIntensityAnalyzer
impl Sync for SentimentIntensityAnalyzer
impl Unpin for SentimentIntensityAnalyzer
impl UnsafeUnpin for SentimentIntensityAnalyzer
impl UnwindSafe for SentimentIntensityAnalyzer
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