getNamedEntityOpinions

<< getNamedEntityRelationships | Back to Salience 6 python Index | getUserEntityRelationships >>

Summary

Gets the opinions expressed by named entities within the text.
This method provides a wrapper around the underlying C API method lxaGetNamedEntityOpinions.

Syntax

salience6.getNamedEntityOpinions(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 list containing with the following items:
speaker A named entity within the content that is expressing an opinion
topic A structure of information about the entity or theme which is the subject of the opinion
isTheme An indicator specifying if the topic of the opinion is an entity (0) or theme (1)
sentiment A sentiment score calculated for the opinion
quotation A quotation in which the opinion was expressed, if available

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):
        opinions = se6.getNamedEntityOpinions(session, "")
        for opinion in opinions:
            if (opinion["isTheme"]==0):
                print opinion["speaker"]["normalized_form"],
                opinion["topic"]["normalized_form"],
                opinion["quotation"]
            else:
                print opinion["speaker"]["normalized_form"],
                opinion["topic"]["theme"],
                opinion["quotation"]
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

<< getNamedEntityRelationships | Back to Salience 6 python Index | getUserEntityRelationships >>