DADOES / examples /library_usage.rs
Ryan.K
Initial DADOES mood classifier library
b0bcd9b unverified
Raw
History Blame Contribute Delete
831 Bytes
use std::process::ExitCode;
use dadoes::{DadoesClassifier, EmotionClassifier};
fn main() -> ExitCode {
match run() {
Ok(()) => ExitCode::SUCCESS,
Err(error) => {
eprintln!("{error}");
ExitCode::from(1)
}
}
}
fn run() -> Result<(), dadoes::ModelIoError> {
let classifier = DadoesClassifier::from_default_model()?;
let analysis =
classifier.classify("I failed at the bridge again and felt frustrated and exhausted.");
if let Some(primary) = analysis.primary_mood() {
println!(
"primary={} score={:.3}",
primary.mood.as_str(),
primary.score
);
}
for score in classifier.active_moods(&analysis) {
println!("active={} score={:.3}", score.mood.as_str(), score.score);
}
Ok(())
}