getNamedEntityOpinions

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

Summary

Gets the opinions expressed by user-defined entities within the text. User-defined entities are based on the entity list specified through the User Entity List option. Other parameters to control entity extraction should be specified by setting additional Entity Options. These options must be set before calling this method.
This method provides a wrapper around the underlying C API method lxaGetUserEntityOpinions.

Syntax

salience6.getUserEntityOpinions(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):
        se6.setOption_UserEntityList(session,'/path/to/list.cdl')
        opinions = se6.getUserEntityOpinions(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)

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