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

Collection

getCollectionThemes

Summary

Retrieves the themes extracted across all documents in the collection. These results can be adjusted through the available Collection Options, which must be set before this call is made.

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

Syntax

salience6.getCollectionThemes(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 of theme items containing the following information:

theme

The text of the theme

stemmed_theme

The stemmed version of the theme

normalized_theme

The normalized version of the theme

theme_type

2 (indicates collection theme)

score

The number of themes rolled up into this theme

sentiment

A sentiment score derived by aggregating the sentences from collection documents that contain the theme into a single document

evidence

The number of sentiment phrases used in determining sentiment score above

about

Not used for collection themes

summary

Not used for collection themes

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
    if (ret==0):
        themes = se6.getCollectionThemes(session, "")
        for theme in themes:
            print theme["theme"], theme["sentiment"]
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

getCollectionFacets

Summary

Retrieves the facets extracted across all documents in the collection. These results can be adjusted through the available Collection Options, which must be set before this call is made.

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

Syntax

salience6.getCollectionFacets(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 of theme items containing the following information:

facet

The text of the facet

total_hits

The count of occurrences for the facet

positive_hits

The number of occurrences which are associated with positive sentiment

negative_hits

The number of occurrences which are associated with negative sentiment

neutral_hits

The number of occurrences which are associated with neutral sentiment

mentions

A list of tuples containing information about facet mentions

positive_mentions

A list of tuples containing information about positive mentions of a facet, based on the value of the Neutral Upper Bound option

negative_mentions

A list of tuples containing information about negative mentions of a facet, based on the value of the Neutral Lower Bound option

neutral_mentions

A list of tuples containing information about neutral mentions of a facet, based on the value of the Neutral Upper Bound and Neutral Lower Bound options

attributes

A list of structures containing information about the attributes for the facet

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
    if (ret==0):
        facets = se6.getCollectionFacets(session, "")
        for facet in facets:
            print facet["facet"], facet["total_hits"]
            for attribute in facet["attributes"]:
                print attribute["attribute"], len(attribute["mentions"])
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

getCollectionQueryDefinedTopics

Summary

Returns the topics determined for the collection via user-defined queries. Before calling this method, you must specify the topic list using the Topic List option.

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

Syntax

salience6.getCollectionQueryDefinedTopics(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 of items containing the following information about topics:

topic

The label for the topic

hits

The number of documents in the collection with hits for the query topic

score

0 (not used)

sentiment

An average of the sentiment values for topic hits within the collection

documents

A list of collection document IDs containing query matches

type

0 (indicates query topic result)

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
    if (ret==0):
        topics = se6.getCollectionQueryDefinedTopics(session, "")
        for topic in topics:
            print topic["topic"], topic["hits"]
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

getCollectionConceptDefinedTopics

Summary

Returns the topics determined for the collection via the Salience 6 Concept Matrix. Before calling this method, you must specify a concept topic list using the Concept Topic List option.

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

Syntax

salience6.getCollectionConceptDefinedTopics(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 of items containing the following information about topics:

topic

The label for the topic

hits

The number of documents in the collection with hits for the query topic

score

0 (not used)

sentiment

An average of the sentiment values for topic hits within the collection

documents

A list of collection document IDs containing query matches

type

1 (indicates concept topic result)

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
    if (ret==0):
        topics = se6.getCollectionConceptDefinedTopics(session, "")
        for topic in topics:
            print topic["topic"], topic["hits"], topic["score"]
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

getCollectionEntities

Summary

Returns the entities from collection based on model-based or datafile-based entity extraction. Parameters to control entity extraction should be specified by setting Entity Options. Other adjustments can be made through the available Collection Options, which must be set before this call is made.

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

Syntax

salience6.getCollectionEntities(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 of items containing the following information:

normalized

The normalized form for the entity

type

The entity type (Person, Place, Company, Product, etc.)

label

A descriptive label for the entity

hits

The number of occurrences of the entity within the collection

positive_hits

The occurrences of the entity within the collection associated with positive sentiment

negative_hits

The occurrences of the entity within the collection associated with negative sentiment

neutral_hits

The occurrences of the entity within the collection associated with neutral sentiment

mentions

A list of structures containing information about occurrences of the entity

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
    if (ret==0):
        entities = se6.getCollectionEntities(session, "")
        for entity in entities:
            print entity["normalized"], entity["type"], entity["hits"]
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

getCollectionUserEntities

Summary

Returns the user-defined entities from the collection. This is based on the entity list specified through the User Entity List option. Other adjustments can be made through the available Collection Options, which must be set before this call is made.

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

Syntax

salience6.getCollectionUserEntities(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 of items containing the following information:

normalized

The normalized form for the entity

type

The entity type (Person, Place, Company, Product, etc.)

label

A descriptive label for the entity

hits

The number of occurrences of the entity within the collection

positive_hits

The occurrences of the entity within the collection associated with positive sentiment

negative_hits

The occurrences of the entity within the collection associated with negative sentiment

neutral_hits

The occurrences of the entity within the collection associated with neutral sentiment

mentions

A list of structures containing information about occurrences of the entity

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ret = se6.prepareCollectionFromFile(session,'myCollection','/path/to/aFile.txt')
    if (ret==0):
        entities = se6.getCollectionUserEntities(session, "")
        for entity in entities:
            print entity["normalized"], entity["type"], entity["hits"]
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

Updated 7 months ago

Collection


Suggested Edits are limited on API Reference Pages

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