getNamedEntities

Summary

Returns the entities from text based on model-based or datafile-based entity extraction. Parameters to control entity extraction should be specified by setting Entity Options.

This method provides a wrapper around the underlying C API method lxaGetNamedEntities.

Syntax

salience6.getNamedEntities(oSession, acConfigurationID)

Parameters

oSessionA SalienceSession object previously created via openSession
acConfigurationIDAn identifier for a configuration added through addConfiguration, or empty string for default configuration

Returns

If successful, returns a Python list containing the following items:

normalized_formNormalized form of the entity
typeType of entity (Company, Person, Place, Product, etc.)
labelDescriptive label for the entity
scoreSentiment score for the entity
evidenceA measure of how much evidence the sentiment score was based on (1 to 7)
confidentWhether the entity passed any confidence queries
aboutWhether the document is about this entity
summaryA summary of the document related to this entity
mentionsA list of objects providing mention information for the entity
themesA list of objects providing theme information for the entity
related_entitiesA dictionary of entity objects providing labeled references to entities related to this entity (currently used by meta-entities, likely to be expanded).
attributesA list of dictionaries, one for each attribute defined for the entity. Each attribute dictionary contains the keys attribute_label and attribute_value for the name and value, respectively, of the attribute.

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):
        entities = se6.getNamedEntities(session,"")
        for entity in entities:
            print entity["normalized_form"], entity["type"]
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

getUserEntities

Summary

Returns the user-defined entities from text. This is 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 lxaGetUserDefinedEntities.

Syntax

salience6.getUserEntities(oSession, acConfigurationID)

Parameters

oSessionA SalienceSession object previously created via openSession
acConfigurationIDAn identifier for a configuration added through addConfiguration, or empty string for default configuration

Returns

If successful, returns a Python list containing the following items:

normalized_formNormalized form of the entity
typeType of entity (Company, Person, Place, Product, etc.)
labelDescriptive label for the entity
scoreSentiment score for the entity
evidenceA measure of how much evidence the sentiment score was based on (1 to 7)
confidentWhether the entity passed any confidence queries
aboutWhether the document is about this entity
summaryA summary of the document related to this entity
mentionsA list of objects providing mention information for the entity
themesA list of objects providing theme information for the entity
attributesA list of dictionaries, one for each attribute defined for the entity. Each attribute dictionary contains the keys label and value for the name and value, respectively, of the attribute.

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

getNamedEntityRelationships

Summary

Gets the relationships between named entities within the text.

This method provides a wrapper around the underlying C API method lxaGetNamedEntityRelationships.

Syntax

salience6.getNamedEntityRelationships(oSession, acConfigurationID)

Parameters

oSessionA SalienceSession object previously created via openSession
acConfigurationIDAn identifier for a configuration added through addConfiguration, or empty string for default configuration

Returns

If successful, returns a Python list containing the following items:

entitiesA list of the entities that are related, with mention information about each entity
typeType of relationship as defined in the relationship pattern files (Occupation, etc.)
confidenceA measure of confidence in the relationship detection for the entities
extraA 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):
        relations = se6.getNamedEntityRelationships(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

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

oSessionA SalienceSession object previously created via openSession
acConfigurationIDAn identifier for a configuration added through addConfiguration, or empty string for default configuration

Returns

If successful, returns a Python list containing the following items:

speakerA named entity within the content that is expressing an opinion
topicA structure of information about the entity or theme which is the subject of the opinion
isThemeAn indicator specifying if the topic of the opinion is an entity (0) or theme (1)
sentimentA sentiment score calculated for the opinion
quotationA 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)

getUserEntityRelationships

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

oSessionA SalienceSession object previously created via openSession
acConfigurationIDAn identifier for a configuration added through addConfiguration, or empty string for default configuration

Returns

If successful, returns a Python list containing the following items:

entitiesA list of the entities that are related, with mention information about each entity
typeType of relationship as defined in the relationship pattern files (Occupation, etc.)
confidenceA measure of confidence in the relationship detection for the entities
extraA 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)

getUserEntityOpinions

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.getNamedEntityOpinions(oSession, acConfigurationID)

Parameters

oSessionA SalienceSession object previously created via openSession
acConfigurationIDAn identifier for a configuration added through addConfiguration, or empty string for default configuration

Returns

If successful, returns a Python list containing the following items:

speakerA named entity within the content that is expressing an opinion
topicA structure of information about the entity or theme which is the subject of the opinion
isThemeAn indicator specifying if the topic of the opinion is an entity (0) or theme (1)
sentimentA sentiment score calculated for the opinion
quotationA 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)