Salience

The Salience Developer Hub

Welcome to the Salience developer hub. You'll find comprehensive guides and documentation to help you start working with Salience as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

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

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 the following items:

normalized_form

Normalized form of the entity

type

Type of entity (Company, Person, Place, Product, etc.)

label

Descriptive label for the entity

score

Sentiment score for the entity

evidence

A measure of how much evidence the sentiment score was based on (1 to 7)

confident

Whether the entity passed any confidence queries

about

Whether the document is about this entity

summary

A summary of the document related to this entity

mentions

A list of objects providing mention information for the entity

themes

A list of objects providing theme information for the entity

related_entities

A dictionary of entity objects providing labeled references to entities related to this entity (currently used by meta-entities, likely to be expanded).

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

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 the following items:

normalized_form

Normalized form of the entity

type

Type of entity (Company, Person, Place, Product, etc.)

label

Descriptive label for the entity

score

Sentiment score for the entity

evidence

A measure of how much evidence the sentiment score was based on (1 to 7)

confident

Whether the entity passed any confidence queries

about

Whether the document is about this entity

summary

A summary of the document related to this entity

mentions

A list of objects providing mention information for the entity

themes

A list of objects providing theme information for the entity

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

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 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):
        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

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 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)

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

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 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)

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

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 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)

Updated 3 months ago

Entity


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.