Detects positive sentiment percentage of input text using cognitive ML; returns $SentimentPercentage, shows face, graph, and status for analysis.
How to add the Cognitive Sentiment robot skill
- Load the most recent release of ARC (Get ARC).
- Press the Project tab from the top menu bar in ARC.
- Press Add Robot Skill from the button ribbon bar in ARC.
- Choose the Artificial Intelligence category tab.
- Press the Cognitive Sentiment icon to add the robot skill to your project.
Don't have a robot yet?
Follow the Getting Started Guide to build a robot and use the Cognitive Sentiment robot skill.
How to use the Cognitive Sentiment robot skill
The Cognitive Sentiment skill analyzes a piece of text and estimates how positive it is using a cloud-based machine learning service. After analysis, ARC will:
- Show the result in the skill’s Status/Response area
- Store the result in the global variable
$SentimentPercentage
You can test phrases manually in the skill window, or send text to the skill from scripts using
ControlCommand().
Main Window
1. Text Field
Type (or paste) the phrase you want analyzed. This can be a single sentence like “I love sunny days.” or a longer piece of text.
2. Detect Button
Click Detect to send the text to the sentiment service. When the result returns, ARC will display the sentiment percentage and update the graph/face.
3. Average Sentiment Face
This face is a quick visual summary of the average sentiment from all the phrases you have analyzed in this session. The numeric average is shown above the face.
4. Sentiment Graph
The graph plots each analysis result over time:
- Horizontal axis: each text entry you analyzed (1st, 2nd, 3rd, etc.)
- Vertical axis: sentiment direction and strength (above zero is more positive, below zero is more negative)
- A line connects points so you can see how sentiment changes from one phrase to the next
5. Status Display
Shows what was sent for analysis and the detected sentiment percentage. This is the easiest place to confirm the skill received your text and returned a result.
How to Use Cognitive Sentiment (Step-by-Step)
-
Add the skill to your project:
In ARC, go to Project → Add Skill → Artificial Intelligence → Cognitive Sentiment. -
Enter text to analyze:
Type your phrase into the Text Field. -
Run detection:
Press Enter in the text field or click the Detect button. -
Read the results:
Check the Status Display for the percentage, watch the Sentiment Face for the average, and review the Graph if you are testing multiple phrases.
$SentimentPercentage to decide how the robot should respond.
Using Sentiment in Scripts (ControlCommand)
You can trigger analysis from any ARC script using ControlCommand(). This is useful when you want to analyze:
- speech recognition results
- chat messages
- text coming from sensors, web APIs, or other skills
Example: Detect sentiment from a typed phrase
ControlCommand("Sentiment", Detect, "I love sunny days")
Example: Detect sentiment from a variable
If your text is already stored in a variable (for example, from speech recognition), send that variable:
ControlCommand("Sentiment", Detect, $MyText)
Reading the result
After detection completes, the sentiment score is saved in the global variable:
$SentimentPercentage
$SentimentPercentage.
