Getting various forms of Sentiments

The sentiment generated by Symbl is at the message and topic levels, more often or not, specific use cases might require generating a conversation-level sentiment. Because Symbl provides you with sentiments at a very fragmented level, you can aggregate them corresponding to your business use case:

1. User level sentiment :
Symbl, in its output, associates every message with a user (depends upon what information is provided while processing the file with Symbl APIs) . Because you can see which user has said which sentences, you can easily aggregate the sentiments said by one user to get to the overall user sentiment for the whole conversation.

The same process can be repeated for multiple users to get user-level sentiments corresponding to each user.

2. Overall conversation sentiment :
To get the conversation-level sentiment, one can aggregate the overall sentiment of all the messages or all the topics. Each can provide you with aggregated conversation sentiment.

Various other ways of aggregating the sentiment are a little complex and consider weighted averages.

For example, you can aggregate based on the ratios of talk time of each message; the sentences with a longer duration should get more weight while aggregating the sentiments. You can get the metadata about the talk time and silence using our Analytics API.

Given below is a sample script that will do that for you :

  1. messages.json is the output of

GET /v1/conversations/{conversationId}/messages?sentiment=true

  1. Analytics.json is the output of

GET /v1/conversations/{conversationId}/analytics

const messages = require('./messages.json').messages

const messageAnalytics = require('./analytics.json')

let weightedSentimentTotal = 0

const duration = messageAnalytics.metrics[1].seconds

messages.forEach(message => {

// interval talk time per message

const messageInterval = (new Date(message.endTime) - new Date(message.startTime)) / 1000

// ratio of message talk time to entire conversation

const sentimentWeight = messageInterval / duration

// weighted sentiment score per message

const weightedSentiment = message.sentiment.polarity.score * sentimentWeight

// summation of weighted sentiments

weightedSentimentTotal += weightedSentiment

})

console.log('weighted avg sentiment', weightedSentimentTotal)

The above script will calculate the weighted aggregated sentiment of the conversation. This can apply to both conversations and user-level sentiment.