Example #1
0
 def get_overall_sentiment_for_agent_sentences(self):
     """
     Returns overall sentiment for agent sentences.
     :return: overall compound sentiment score of agent sentences:
             -1 is neg, 0 is neutral, 1 is pos
     """
     if len(self.agent_msgs) > 0:
         text = ' '.join(self.agent_msgs)
         sentiment = get_sentiment_for_sentence(text,
                                                self.sentiment_analyzer)
         return sentiment
     else:
         raise ValueError('List of agent messages is empty.')
Example #2
0
 def get_overall_sentiment_for_list_of_sentences(self, list_of_text):
     """
     Returns overall sentiment for a list of sentences.
     :param list_of_text: [list], list of input strings
     :return: overall compound sentiment score of the list_of_text:
             -1 is neg, 0 is neutral, 1 is pos
     """
     if len(list_of_text) > 0:
         text = ' '.join(list_of_text)
         sentiment = get_sentiment_for_sentence(text,
                                                self.sentiment_analyzer)
         return sentiment
     else:
         raise ValueError('List of sentences has length 0.')
Example #3
0
 def get_overall_sentiment_for_chat(self):
     """
     Returns overall sentiment for the whole conversation, i.e.
     client and agent sentences together.
     :return: overall compound sentiment score of client and
              agent sentences: -1 is neg, 0 is neutral, 1 is pos
     """
     if len(self.client_msgs) > 0 and len(self.agent_msgs) > 0:
         text = ' '.join(self.client_msgs)
         text += ' ' + ' '.join(self.agent_msgs)
         sentiment = get_sentiment_for_sentence(text,
                                                self.sentiment_analyzer)
         return sentiment
     else:
         raise ValueError('List of client or agent messages is empty.')