Commit f5fd30e
authored
Create SentimentAnalyzer.js
var SentimentAnalyzer = Class.create();
SentimentAnalyzer.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSentiment: function() {
var text = (this.getParameter('sysparm_text') || '').toLowerCase();
var positive = ['thanks', 'great', 'resolved', 'appreciate'];
var negative = ['issue', 'error', 'not working', 'fail', 'problem'];
var score = 0;
positive.forEach(function(word) { if (text.includes(word)) score++; });
negative.forEach(function(word) { if (text.includes(word)) score--; });
if (score > 0) return 'Positive';
if (score < 0) return 'Negative';
return 'Neutral';
}
});1 parent 904a62c commit f5fd30e
File tree
1 file changed
+16
-0
lines changed- Client-Side Components/Catalog Client Script/Incident Sentiment Detector (Using Simple Word Matching, No AI)
1 file changed
+16
-0
lines changedLines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments