getUserEntityRelationships

<< getNamedEntityOpinions | Back to Salience 6 python Index | getUserEntityOpinions >>

Summary

Gets the relationships between 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 lxaGetUserEntityRelationships.

Syntax

salience6.getUserEntityRelationships(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:
entities A list of the entities that are related, with mention information about each entity
type Type of relationship as defined in the relationship pattern files (Occupation, etc.)
confidence A measure of confidence in the relationship detection for the entities
extra A placeholder for an extra information that can be detected about the relationship

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')
        relations = se6.getUserEntityRelationships(session, "")
        for relation in relations:
            print relation["type"], 
                  relation["entities"][0]["normalized_form"],
                  relation["entities"][1]["normalized_form"]
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

<< getNamedEntityOpinions | Back to Salience 6 python Index | getUserEntityOpinions >>