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

openSession

Summary

This method creates a Salience 6 session using the provided license file and path to data directory. The session can be used to access further functionality of Salience 6.

The method provides a wrapper around the underlying C API methods lxaLoadLicense and lxaOpenSalienceSession.

Syntax

salience6.openSession(sLicensePath, sDataPath)

Parameters

sLicensePath

String containing the path to the required license file

sDataPath

String containing the path to the data directory to use for the session

Returns

If successful, the method returns a SalienceSession object that can be used for processing text.

Example

>>> import salience6 as se6
>>> session = se6.openSession('/path/to/license.v5','/path/to/data')
>>> session
<SalienceSession object at 0x2b5d6b006db0>
>>>

openShortFormSession

Summary

This method creates a Salience 6 session specifically tuned to shorter content such as tweets or other micro-blog content. Similar to openSession, the method requires a path to a license file and path to data directory. The session can be used to access further functionality of Salience 6.

The method provides a wrapper around the underlying C API methods lxaLoadLicense and lxaOpenSalienceSession, with the Short Form mode switch enabled.

Operating in short-form mode sets different default values for specific Salience options to values more appropriate to processing shorter content. For example, the default value for the text threshold option is 80% alphanumeric content. Short content can fail this threshold with an extra exclamation mark, so short form decreases the default threshold to 25%. Note that any options set to different default values by enabling short-form mode can be adjusted by subsequent API calls to the various option methods.

Syntax

salience6.openShortFormSession(sLicensePath, sDataPath)

Parameters

sLicensePath

String containing the path to the required license file

sDataPath

String containing the path to the data directory to use for the session

Returns

If successful, the method returns a SalienceSession object that can be used for processing short-form text, such as Twitter or other micro-blog content.

Example

>>> import salience6 as se6
>>> session = se6.openShortFormSession('/path/to/license.v5','/path/to/data')
>>> session
<SalienceSession object at 0x2b5d6b006db0>
>>>

closeSession

Summary

Closes a Salience 6 session, freeing any remaining memory associated with the session. This method provides a wrapper around the underlying C API method lxaCloseSalienceSession.

Syntax

salience6.closeSession(oSession)

Parameters

oSession

A SalienceSession object previously created via openSession

Returns

If successful, returns 0.

Example

>>> import salience6 as se6
>>> session = se6.openSession('/path/to/license.v5','/path/to/data')
>>> session
<SalienceSession object at 0x2b5d6b006db0>
>>> 
>>> se6.closeSession(session)
0

addConfiguration

Summary

Supports the analysis of content through multiple user directories.

This method adds the specified user directory, with the customizations and tuning it contains, to the specified Salience session. After adding a configuration to the Salience session, additional processing options and results from various API methods can be retrieved by using the identifier provided in sConfigurationID.

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

Syntax

salience6.addConfiguration(oSession, sUserDir, sConfigurationID)

Parameters

oSession

A SalienceSession object previously created via openSession

sUserDir

Path to a user directory to use for this configuration

sConfigurationID

Character string specifying a unique identifier for this configuration

Returns

If successful, returns 0. If unsuccessful, returns LXA_CONFIG_IN_USE to indicate the provided configuration ID has already been added to the session.

removeConfiguration

Summary

This method removes the specified configuration from those used in processing content in the the current Salience session.

Calling this method with a value for sConfigurationID that has not been previously added by a call to addConfiguration will result in an error code returned. Additionally, calling this method with an empty string (which identifies the default configuration) will result in an error.

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

Syntax

salience6.removeConfiguration(oSession, sConfigurationID)

Parameters

oSession

A SalienceSession object previously created via openSession

sConfigurationID

Character string specifying a unique identifier for this configuration

Returns

If successful, returns 0. If unsuccessful, returns LXA_INVALID_CONFIG to indicate the provided configuration ID has not been added to the session or cannot be removed.

getVersion

Summary

Retrieves version information about the underlying Salience 6 engine in use by the wrapper. This is helpful information for any troubleshooting or diagnostics.

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

Syntax

salience6.getVersion()

Parameters

None.

Returns

If successful, returns a string containing the version information

Example

>>> import salience6 as se6
>>> version = se6.getVersion()
>>> version
'Lexalytics Salience 6.0.0.8781 x86-64 (Component: Salience6) (Branch: /projects) 
....
>>>

getLastWarnings

Summary

Retrieves any warnings issues regarding the last API call made. Documentation of the warning codes can be found on the Errors and Warning Codes page.

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

Syntax

salience6.getLastWarnings(oSession)

Parameters

oSession

A SalienceSession object previously created via openSession

Returns

If successful, returns an integer that is a bitmask of possible warning codes as specified on the Errors and Warning Codes page.

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ret = se6.prepareTextFromFile(session,'/path/to/file.txt')
    if (ret==0):
        ...extract results from text...
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 

    se6.closeSession(session)

dumpEnvironment

Summary

Provides output of options that have been set for the current Salience session and other environmental information.

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

Syntax

salience6.dumpEnvironment(oSession)

Parameters

oSession

A SalienceSession object previously created via openSession

Returns

If successful, returns a string containing environment information.

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ...set options for Salience session...
    print se6.dumpEnvironment(session)
    ...
    se6.closeSession(session)

resetThemes

Summary

Reinitializes theme processing within Salience 6 without the need to reinitialize the entire session. This allows modifications to be made to data files that affect theme extraction, and that portion of the Salience 6 engine to be reloaded with the updated data files.

Syntax

salience6.resetThemes()

Parameters

None.

Returns

TODO: document return from method

Example

import salience6 as se6
    session = se6.openSession('/path/to/license.v5','/path/to/data')
    ...check if external modifications have been to theme data files...
    se6.resetThemes()
    ...
    se6.closeSession(session)

runModelSmokeTest

Summary

Runs smoke tests to ensure that the installed Salience version is compatible with the models in the data directory. Please use the output of this function to create detailed reports for support engagements.

A smoke test is successful if the number of "success" messages is at least 1 (showing that smoke testing was invoked) and the number of "failure" messages is 0 (showing that no errors arose during smoke testing).

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

Syntax

salience6.runModelSmokeTest(oSession, ,acConfigurationID)

Parameters

oSession

A SalienceSession object previously created via openSession

lSuccesses

A list structure for containing the results for smoke tests that succeeded

lFailures

A list structure for containing the results for smoke tests that succeeded

Returns

If successful, returns a Python dictionary containing with the following keys:

document_terms

A list of tokens contained with the document and their term frequencies

fingerprint

A string containing the calculated fingerprint of the document (DEPRECATED)

internal_version

A string providing the internal Salience representation of the document after preprocessing

sentences

A list of the individual sentences in the document, where each sentence item contains a structure of information about the sentence.

sentence_count

An integer giving the count of sentences in the document

word_count

An integer giving the count of words in the document

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):
        details = se6.getDocumentDetails(session,"")
        print details
    else:
        if (ret==6):
            print se6.getLastWarnings(session) 
    se6.closeSession(session)

Updated 7 months ago

Session


Suggested Edits are limited on API Reference Pages

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