Overview
This example demonstrates a sentiment analysis agent that goes beyond simple positive/negative classification. It tracks epistemic confidence, separates factual observations from subjective interpretations, and provides multi-dimensional sentiment scores.Use Case
Analyze text sentiment to:- Classify overall sentiment (positive, negative, neutral)
- Provide quantified sentiment scores (-1.0 to 1.0)
- Identify emotional tone and intensity
- Separate factual content from opinion
- Track confidence in sentiment assessment
- Handle ambiguous or mixed sentiment
Complete Code
sentiment_analysis.axon
Key Components
Persona: SentimentAnalyst
- Natural Language Processing: Technical understanding of text analysis
- Psychology: Understanding of emotional expression
- Linguistics: Language structure and meaning
- Analytical tone: Objective, systematic approach
Context: AnalysisMode
- Memory: No memory (stateless analysis)
- Depth: Moderate analysis (not shallow, not exhaustive)
- Temperature: Low (0.2) for consistent classifications
Custom Types
-1.0= Very negative0.0= Neutral1.0= Very positive
primary: Primary emotion (joy, anger, sadness, etc.)intensity: How strong the emotion isconfidence: How confident we are in the assessment
- overall_score: Quantified sentiment
- classification: Category (positive, negative, neutral)
- emotional_tone: Detailed emotional assessment
- factual_content: Factual statements found
- opinions: Opinion statements found
- ambiguity_score: How unclear the sentiment is
- confidence: Overall confidence in the analysis
Flow: AnalyzeSentiment
Three-step cognitive pipeline with validation: Step 1: ExtractContent- Factual statements (objective)
- Opinions (subjective)
- Emotional language (sentiment-bearing)
- Overall sentiment polarity
- Primary sentiment category
- Sentiment score
- Identify primary emotion
- Assess intensity
- Consider context
- Refines if confidence too low
- Warns on ambiguous sentiment
Usage
Validate and Run
Example Input
Example Output
Advanced Patterns
Aspect-Based Sentiment
Analyze sentiment for specific aspects:Comparative Sentiment
Compare sentiment across multiple texts:Temporal Sentiment Tracking
Track sentiment changes over time:Multi-Language Sentiment
Handle multiple languages:Best Practices
1. Separate Facts from Opinions
2. Use Range-Constrained Scores
3. Track Confidence
4. Handle Ambiguity
5. Use Low Temperature
Related Examples
Contract Analyzer
Legal contract analysis with risk assessment
Data Extraction
Extract structured data from unstructured text
Multi-Step Reasoning
Complex reasoning with chain-of-thought

