Skip to main content

extract_emotion

Function extract_emotion 

Source
pub fn extract_emotion(text: &str) -> ExtractionResult
Expand description

Extract emotional state from text using structural signals.

This replaces word-list-only valence detection. Instead of matching individual words, it detects:

  1. What event happened (achievement, error, fix, challenge, building)
  2. What speech act was used (question, imperative, contemplation)
  3. What context type the text is in (code, personal, philosophical)
  4. Whether this is a self-correction (positive structural signal)

Self-corrections override event detection: if the text contains a self-correction signal, the emotion is positive (learning/humility) regardless of negative words.