Class DocumentSentiment

java.lang.Object
com.lexalytics.salience.DocumentSentiment

public class DocumentSentiment
extends java.lang.Object

The DocumentSentiment object provides all document-level sentiment results from Salience. This includes both phrase-based and model-based sentiment results.

This object is returned from calls to the Salience.getDocumentSentiment(boolean) API method.

  • Constructor Summary

    Constructors 
    Constructor Description
    DocumentSentiment​(float sentimentScore, java.util.Vector<SentimentModelScores> sentimentModelResults, java.util.Vector<SentimentPhrase> sentimentPhrases, java.util.Vector<Topic> emotionResults)
    Creates a new DocumentSentiment object.
  • Method Summary

    Modifier and Type Method Description
    java.util.Vector<Topic> getEmotionResults()
    Added in Salience 5.1: Retrieves the emotions detected in the document, which provide a different perspective to the sentiment score for the document.
    java.util.Vector<SentimentModelScores> getSentimentModelResults()
    Retrieves the model-based sentiment analysis for the document.
    java.util.Vector<SentimentPhrase> getSentimentPhrases()
    Retrieves the phrase-based sentiment analysis for the document.
    float getSentimentScore()
    Retrieves the phrase-based sentiment score for the document.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DocumentSentiment

      public DocumentSentiment​(float sentimentScore, java.util.Vector<SentimentModelScores> sentimentModelResults, java.util.Vector<SentimentPhrase> sentimentPhrases, java.util.Vector<Topic> emotionResults)
      Creates a new DocumentSentiment object. This is not intended for client use. DocumentSentiment objects are created by Salience Engine when related API methods are called.
      Parameters:
      sentimentScore - The phrase-based document sentiment score.
      sentimentModelResults - A Vector containing SentimentModelScores providing model-based sentiment results.
      sentimentPhrases - A Vector containing SentimentPhrase objects providing phrase-based sentiment details.
      emotionResults - Added in Salience 5.1: A Vector containing Topic objects providing experimental emotion results.
  • Method Details

    • getSentimentScore

      public float getSentimentScore()
      Retrieves the phrase-based sentiment score for the document. This is a number generally between -1 and +1, although modifiers and intensifiers can cause it to fall outside this range. A higher number indicates more positive sentiment, a lower number indicates more negative sentiment. Neutral sentiment is considered a range of values that are close to zero, the exact range of neutral sentiment may vary based on the content being analyzed.
      Returns:
      A number indicating phrase-based sentiment.
    • getSentimentModelResults

      public java.util.Vector<SentimentModelScores> getSentimentModelResults()
      Retrieves the model-based sentiment analysis for the document. The default data directory contains a model trained on general business news. The Salience distribution contains a tool called the SentimentModelBuilder which can be used to develop custom sentiment models. Multiple sentiment models can be used at the same time.
      Returns:
      A Vector of SentimentModelScores objects, each containing the analysis based on a particular sentiment model.
    • getSentimentPhrases

      public java.util.Vector<SentimentPhrase> getSentimentPhrases()
      Retrieves the phrase-based sentiment analysis for the document. This is based on the out-of-the-box sentiment files, as well as any custom hand-scored dictionary (HSD) files that have been created to tune sentiment analysis for particular content. The phrases contained in this Vector contribute to the overall document sentiment score, thus tuning these phrases has a direct impact on document-level sentiment, as well as entity-, theme-, and topic- level sentiment for phrases related to those items.
      Returns:
      A Vector of SentimentPhrase objects, each containing information about a sentiment-bearing phrase detected.
    • getEmotionResults

      public java.util.Vector<Topic> getEmotionResults()
      Added in Salience 5.1: Retrieves the emotions detected in the document, which provide a different perspective to the sentiment score for the document. This is an experimental feature added to the product in Salience 5.1.
      Returns:
      A Vector of Topic objects, each containing information about an emotion detected.