Sentiment Analyzer
The Sentiment Analyzer LOP performs sentiment analysis on conversation histories or custom text, producing structured scores and labels that quantify emotional tone. It supports four analysis backends — VADER, Transformers (with multiple HuggingFace models), TextBlob, and Stanford NLP (Stanza) — each offering different tradeoffs between speed, accuracy, and the type of metrics produced.
Requirements
Section titled “Requirements”- Python Packages (installed automatically via ChatTD’s Python Manager depending on which backend you select):
vaderSentimentfor the VADER backendtransformersfor the Transformers backendtextblobfor the TextBlob backendstanzafor the Stanford NLP backend
Input/Output
Section titled “Input/Output”Inputs
Section titled “Inputs”The operator reads from an internal input_table DAT. Wire a conversation table (with id, role, and message columns) into the operator so it can access message data for analysis.
Outputs
Section titled “Outputs”One output carrying the active results table. The operator maintains four backend-specific internal tables and a summary table:
- vader_table — compound, positive, negative, and neutral scores per message
- transformers_table — classification label (e.g., POSITIVE/NEGATIVE) and confidence score per message, plus the model used
- textblob_table — polarity (-1 to 1) and subjectivity (0 to 1) per message
- stanza_table — sentiment score per message
- summary_dat — aggregated statistics (averages, label counts) for the active backend
Analysis Backends
Section titled “Analysis Backends”| Backend | Strengths | Metrics |
|---|---|---|
| VADER | Fast, rule-based, no model download needed | Compound, positive, negative, neutral scores |
| Transformers | Most accurate, multiple model choices | Label + confidence score |
| TextBlob | Simple, includes subjectivity analysis | Polarity + subjectivity |
| Stanford NLP | Research-grade NLP pipeline | Sentiment score |
When using the Transformers backend, you can choose from several pretrained models on the Sentiment page under ‘Model Name’. The default distilbert-base-uncased-finetuned-sst-2-english is a good general-purpose choice. For financial text, select finbert. For social media content, try twitter-roberta-base-sentiment-latest or bertweet-base-sentiment-analysis.
Usage Examples
Section titled “Usage Examples”Analyzing a Full Conversation
Section titled “Analyzing a Full Conversation”- Wire a conversation table DAT (with
id,role,messagecolumns) into the Sentiment Analyzer. - On the Sentiment page, set ‘Analyze Mode’ to Full Conversation.
- Set ‘Analysis Backend’ to your preferred backend (e.g., VADER for speed, Transformers for accuracy).
- Pulse ‘Start Analysis’.
- Watch the ‘Status’ field — it will show “Analysis in progress” and then “Analysis complete”.
- Results appear in the corresponding backend table, visible in the operator viewer.
Analyzing Custom Text
Section titled “Analyzing Custom Text”- On the Sentiment page, set ‘Analyze Mode’ to Custom Text.
- Enter your text in the ‘Custom Text’ field.
- Choose your ‘Analysis Backend’.
- Pulse ‘Start Analysis’.
- The result row appears in the active backend’s table with
customas the message ID and role.
Viewing Summary Statistics
Section titled “Viewing Summary Statistics”- On the Sentiment page, set ‘Display Mode’ to Summary.
- The operator viewer switches to the summary table showing aggregated metrics for the current backend — average scores, total message counts, and (for Transformers) label distribution counts.
Tracking Sentiment Over Time
Section titled “Tracking Sentiment Over Time”- Set ‘Table Update Mode’ to Append Results to accumulate results across multiple analysis runs.
- Each row includes a timestamp, so you can track how sentiment changes over the course of a conversation.
- Use Clear Before Analysis mode if you want fresh results each time.
Table Update Modes
Section titled “Table Update Modes”The ‘Table Update Mode’ parameter controls how new results are written to the backend table:
- Append Results — adds new rows after existing data (default)
- Replace By Index — overwrites rows at matching positions from the input table
- Batch Update — collects all results, then clears the table and writes them sorted by input order
- Clear Before Analysis — clears the backend table before writing new results
Best Practices
Section titled “Best Practices”- Use VADER for real-time or high-throughput scenarios where speed matters more than nuanced accuracy.
- Use Transformers when you need the most accurate classification and can tolerate slightly longer processing times (models are downloaded on first use).
- Set ‘Analyze Mode’ to Last Message if you only need sentiment on the most recent message in a conversation, avoiding unnecessary reprocessing.
- Use the Summary display mode to get a quick overview of sentiment trends without inspecting individual rows.
Troubleshooting
Section titled “Troubleshooting”- “Message index out of range” — When using ‘Specific Message Index’ mode, ensure the index is within the range of rows in your input table (starting from 1).
- “Analysis already in progress” — Wait for the current analysis to finish before pulsing ‘Start Analysis’ again. Check the ‘Status’ field.
- Slow first run with Transformers — The selected model is downloaded on first use. Subsequent runs are faster since the model is cached locally.
- Empty results — Verify your input table has the expected
id,role, andmessagecolumns and contains data rows.
Parameters
Section titled “Parameters”Sentiment
Section titled “Sentiment”op('sentiment').par.Messageindex Int - Default:
1- Range:
- 0 to 1
- Slider Range:
- 1 to 10
op('sentiment').par.Customtext Str - Default:
"" (Empty String)
op('sentiment').par.Analyze Pulse - Default:
False
op('sentiment').par.Clear Pulse - Default:
False
op('sentiment').par.Status Str - Default:
"" (Empty String)
Changelog
Section titled “Changelog”v1.0.02024-11-10
Initial release