getDocumentSentiment

<< getSummary | Back to Salience 6 python Index | getDocumentThemes >>

Summary

Returns sentiment analysis of the document text. This consists of results for phrase-based and model-based sentiment analysis.
This method provides a wrapper around the underlying C API method lxaGetSentiment.

Syntax

salience6.getDocumentSentiment(oSession, acConfigurationID)

Parameters

oSession A SalienceSession object previously created via openSession
acConfigurationID An identifier for a configuration added through addConfiguration, or empty string for default configuration

Returns

If successful, returns a Python dictionary containing with the following keys:
score The phrase-based sentiment score for the document
phrases A list of phrases considered in phrase-based sentiment analysis, where each item contains a structure of information about a particular sentiment-bearing phrase
models A list of model-based sentiment results, where each item contains a structure of information about sentiment analysis based on a specific model found in the data directory

Example

    import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ret = se6.prepareTextFromFile(session,'/path/to/aFile.txt')
    if (ret==0):
        sentiment = se6.getDocumentSentiment(session, "")
        print sentiment
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

<< getSummary | Back to Salience 6 python Index | getDocumentThemes >>