//! Built-in seed examples for DADOES smoke tests and domain augmentation. use crate::{ LinearMoodModel, ModelError, Mood, OwnedTrainingExample, TrainConfig, TrainingExample, }; /// Returns the seed examples used by the first DADOES baseline. #[must_use] pub fn seed_training_examples() -> &'static [TrainingExample<'static>] { &SEED_TRAINING_EXAMPLES } /// Trains the built-in seed model. pub fn train_seed_model() -> Result { LinearMoodModel::train(seed_training_examples(), TrainConfig::default()) } /// Returns owned seed examples with full DADOES label supervision. pub fn owned_seed_training_examples() -> Result, ModelError> { seed_training_examples() .iter() .map(|example| OwnedTrainingExample::new(example.text.to_owned(), example.labels.to_vec())) .collect() } const SEED_TRAINING_EXAMPLES: [TrainingExample<'static>; 32] = [ TrainingExample { text: "I finished the shelter and felt happy with the quiet progress.", labels: &[Mood::Happy, Mood::Satisfied], }, TrainingExample { text: "The plan worked exactly as I hoped, and I feel satisfied tonight.", labels: &[Mood::Satisfied], }, TrainingExample { text: "I found a bright new cave and I am excited to explore it tomorrow.", labels: &[Mood::Excited, Mood::Curious], }, TrainingExample { text: "The strange signal beyond the ridge made me curious.", labels: &[Mood::Curious], }, TrainingExample { text: "The storm trapped me outside and I felt anxious until I reached camp.", labels: &[Mood::Anxious], }, TrainingExample { text: "I kept failing to craft the tool, and the repeated mistake was frustrating.", labels: &[Mood::Frustrated], }, TrainingExample { text: "I lost the garden today and felt sad watching the work disappear.", labels: &[Mood::Sad], }, TrainingExample { text: "The broken promise made me angry for the rest of the evening.", labels: &[Mood::Angry], }, TrainingExample { text: "No one visited the camp, and I felt lonely after sunset.", labels: &[Mood::Lonely], }, TrainingExample { text: "Sorting the same stones all day left me bored and restless.", labels: &[Mood::Bored], }, TrainingExample { text: "My legs ached after hauling timber, and I am tired now.", labels: &[Mood::Tired], }, TrainingExample { text: "The first green shoots appeared, so I feel hopeful about the harvest.", labels: &[Mood::Hopeful], }, TrainingExample { text: "I repaired the fence, counted supplies, and ended the day neutral.", labels: &[Mood::Neutral], }, TrainingExample { text: "I was not happy with the failed bridge repair.", labels: &[Mood::Frustrated, Mood::Sad], }, TrainingExample { text: "A narrow escape from the wolves left me anxious and tired.", labels: &[Mood::Anxious, Mood::Tired], }, TrainingExample { text: "I finally solved the lock, and the success made me excited and satisfied.", labels: &[Mood::Excited, Mood::Satisfied], }, TrainingExample { text: "The empty road made the world feel lonely and quiet.", labels: &[Mood::Lonely, Mood::Sad], }, TrainingExample { text: "Another day of waiting with no news made me bored.", labels: &[Mood::Bored], }, TrainingExample { text: "I still believe the missing map can be found, and that feels hopeful.", labels: &[Mood::Hopeful], }, TrainingExample { text: "The new footprints near the river made me curious and a little anxious.", labels: &[Mood::Curious, Mood::Anxious], }, TrainingExample { text: "I argued with the trader and walked away angry.", labels: &[Mood::Angry], }, TrainingExample { text: "The meal was warm, the roof held, and I felt happy.", labels: &[Mood::Happy, Mood::Satisfied], }, TrainingExample { text: "I tried the same route again and again until I felt frustrated.", labels: &[Mood::Frustrated, Mood::Tired], }, TrainingExample { text: "The day passed without danger or surprise.", labels: &[Mood::Neutral], }, TrainingExample { text: "I am exhausted after digging, carrying, and repairing since dawn.", labels: &[Mood::Tired], }, TrainingExample { text: "I discovered a hidden room and cannot wait to return.", labels: &[Mood::Excited, Mood::Curious], }, TrainingExample { text: "The ruined notebook reminded me of everything I lost.", labels: &[Mood::Sad], }, TrainingExample { text: "The path is difficult, but tomorrow still looks possible.", labels: &[Mood::Hopeful], }, TrainingExample { text: "I failed at the bridge again and felt frustrated and exhausted tonight.", labels: &[Mood::Frustrated, Mood::Tired], }, TrainingExample { text: "Another failed repair left me exhausted, blocked, and frustrated.", labels: &[Mood::Frustrated, Mood::Tired], }, TrainingExample { text: "The work succeeded, and I felt satisfied instead of frustrated.", labels: &[Mood::Satisfied], }, TrainingExample { text: "Nothing went wrong today, but nothing felt especially meaningful either.", labels: &[Mood::Neutral], }, ]; #[cfg(test)] mod tests { use super::*; use crate::EmotionClassifier; #[test] fn seed_model_detects_frustrated_report() { let model = train_seed_model(); assert!(model.is_ok()); if let Ok(model) = model { let analysis = model.classify( "I failed at the bridge again and felt frustrated and exhausted tonight.", ); let active: Vec = analysis .active_moods(0.35) .map(|score| score.mood) .collect(); assert!(active.contains(&Mood::Frustrated)); } } #[test] fn seed_model_detects_curious_report() { let model = train_seed_model(); assert!(model.is_ok()); if let Ok(model) = model { let analysis = model.classify("The strange footprints made me curious about the river path."); let primary = analysis.primary_mood(); assert!(primary.is_some()); if let Some(primary) = primary { assert_eq!(primary.mood, Mood::Curious); } } } }