Skip to content

Commit f5fd30e

Browse files
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 changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var SentimentAnalyzer = Class.create();
2+
SentimentAnalyzer.prototype = Object.extendsObject(AbstractAjaxProcessor, {
3+
getSentiment: function() {
4+
var text = (this.getParameter('sysparm_text') || '').toLowerCase();
5+
var positive = ['thanks', 'great', 'resolved', 'appreciate'];
6+
var negative = ['issue', 'error', 'not working', 'fail', 'problem'];
7+
8+
var score = 0;
9+
positive.forEach(function(word) { if (text.includes(word)) score++; });
10+
negative.forEach(function(word) { if (text.includes(word)) score--; });
11+
12+
if (score > 0) return 'Positive';
13+
if (score < 0) return 'Negative';
14+
return 'Neutral';
15+
}
16+
});

0 commit comments

Comments
 (0)