Created
March 29, 2018 00:25
-
-
Save ajb413/9336737d4a582c1bf430f3a53513c341 to your computer and use it in GitHub Desktop.
Amazon Comprehend code snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.sentimentAnalysis(plainText, message.timetoken) | |
.then(function(id, sentiment) { | |
var messageInfoSpan = $('span[data-identifier="' + id + '"]'); | |
var messageDiv = $('div[data-identifier="' + id + '"]'); | |
if (sentiment.Sentiment && | |
sentiment.SentimentScore && | |
sentiment.SentimentScore.Negative && | |
sentiment.SentimentScore.Positive | |
) { | |
messageDiv.removeClass('neutral'); | |
messageDiv.addClass(sentiment.Sentiment); | |
var neg = (sentiment.SentimentScore.Negative * 100).toFixed(2); | |
var pos = (sentiment.SentimentScore.Positive * 100).toFixed(2); | |
messageInfoSpan.text('+' + pos + '% -' + neg + '%'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment