Utility

API reference for utility functions that allow you to set options for the Salience Engine, Get a text representation of the current Salience session, retrieve information about your Salience environment, and many other useful actions.

lxaSetSalienceOption

Summary: Sets the value for an available option for the Salience Engine. Refer to Options documentation for the available options that may be set and their purpose.

Returns: Integer return code. To retrieve more information on the return code use lxaGetLastWarnings on the SalienceSession structure.

More information on errors and warnings can be found in the Errors and Warning Codes section of our documentation.

Function Signature:
int lxaSetSalienceOption(SalienceSession *pSession, SalienceOption *pOption, const char *acConfigurationID);

Parameter

Description

pSession

Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession

pOption

Pointer to a SalienceOption structure containing option values to be set

acConfigurationID

Character string specifying the configuration for the option, blank for the default configuration

Example:
Use lxaLoadLicense to create LexalyticsLicense structure. This will then be given to lxaOpenSalienceSession, which is then used to start a session with Salience.

/* Assuming a SalienceSession (*pSession) has already been opened with 
  a valid LexalyticsLicense */

  SalienceOption oOption;
  oOption.nOption = SALIENCEOPTION_MAXEXECUTIONTIME;
  oOption.nValue = 60;

    // Set specific option to your salience session
  lxaSetSalienceOption(pSession, &oOption);

    //...

Visit the Options section of the documentation for more information.

lxaDumpEnvironment

Summary: Provides output of options that have been set for the current Salience session and other environmental information. After use you should use lxaFreeString to free memory resources allocated to the char**, acEnvironment.

Returns: Integer return code. To retrieve more information on the return code use lxaGetLastWarnings on the SalienceSession structure.

More information on errors and warnings can be found in the Errors and Warning Codes section of our documentation.

Function Signature:
int lxaDumpEnvironment(SalienceSession *pSession, char **acEnvironment);

Parameter

Description

pSession

Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession

acEnvironment

Pointer to a char pointer which is filled with information about the Salience session environment

Example:
Use lxaLoadLicense to create LexalyticsLicense structure. This will then be given to lxaOpenSalienceSession, which is then used to start a session with Salience.

/* Assuming a SalienceSession (*pSession) has already been opened with 
  a valid LexalyticsLicense */

    // Call to lxaDumpEnivronment and store it in *pEnvironment
    char *pEnvironment;
    lxaDumpEnvironment(pSession, &pEnvironment);

    printf("%s", *pEnvironment);
    lxaFreeString(pEnvironment);

    // ...

lxaGetSalienceErrorString

Summary: Gets detailed information on any errors or warnings that may have occurred during processing. This function places this information at the memory location being passed through ppErrorString which is of type char**. After use you should free the allocated memory by calling lxaFreeString.

Returns: Integer return code. To retrieve more information on the return code use lxaGetLastWarnings on the SalienceSession structure.

More information on errors and warnings can be found in the Errors and Warning Codes section of our documentation.

Function Signature:
int lxaGetSalienceErrorString(SalienceSession *pSession, char **ppErrorString);

Parameter

Description

pSession

Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession

ppErrorString

Pointer to a char pointer containing information about errors and warnings

Example:
Use lxaLoadLicense to create LexalyticsLicense structure. This will then be given to lxaOpenSalienceSession, which is then used to start a session with Salience.

/* Assuming a SalienceSession (*pSession) has already been opened with 
  a valid LexalyticsLicense */

  char *acError;

  if(lxaOpenSalienceSession(oLicense, &pSession, &acError) == LXA_OK) {
    try {
      //Try Something
    }
    catch(...) {
      lxaGetSalienceErrorString(pSession, &acError);

      printf(*acError);

      lxaFreeString(acError);
    }

    lxaCloseSalienceSession(pSession);
  }

lxaGetLastWarnings

Summary: Gets the last warnings issued on a session. If you get a return of LXA\_OK\_WITH_WARNINGS on a function call then you can call this function to find out what the warnings were. The pWarnings pointer will be set to a bitmask containing the current warning codes.

Documentation of the warning codes can be found on the Errors and Warning Codes page.

Returns: Integer return code. To retrieve more information on the return code use lxaGetLastWarnings on the SalienceSession structure.

More information on errors and warnings can be found in the Errors and Warning Codes section of our documentation.

Function Signature:
int lxaGetLastWarnings(SalienceSession *pSession, int *pWarnings);

Parameter

Description

pSession

Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession

pWarnings

Pointer to an int that will take the warning bitmask

Example:
Use lxaLoadLicense to create LexalyticsLicense structure. This will then be given to lxaOpenSalienceSession, which is then used to start a session with Salience.

/* Assuming a SalienceSession (*pSession) has already been opened with 
  a valid LexalyticsLicense */

  int acWarnings;
  if(lxaOpenSalienceSession(oLicense, &pSession, &acWarnings) == LXA_OK) {
    try {
      //Try Something
    }
    catch(...) {
      lxaGetSalienceErrorString(pSession, &acWarnings);
            printf("d%", acWarnings)
    }
    lxaCloseSalienceSession(pSession);
  }

lxaSetSalienceCallback

Summary: Sets a callback function that Salience can use to return messages during processing.

Returns: Integer return code. To retrieve more information on the return code use lxaGetLastWarnings on the SalienceSession structure.

More information on errors and warnings can be found in the Errors and Warning Codes section of our documentation.

Function Signature:
int lxaSetSalienceCallback(SalienceSession *pSession, SalienceCallback oCallback, void *pParam);

Parameter

Description

pSession

Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession

oCallback

A pointer to the callback function that you want to use. See below for the definition of this callback function

pParam

A pointer to a piece of data that you want to be passed into the callback function

Comments

The format of the callback function is defined as

typedef int (*SalienceCallback)(void*,int,const char*);

so a real example might be:

int mycallback(void *pParam,int nCode,const char *acMessage) { printf(acMessage); printf("\n"); return 0; }

pParam will be set to whatever you set the pParam member of the lxaSetSalienceCallback call to be (useful for passing around a class). nCode and acMessage will both be set by the application to be the relevant error / warning code and associated text string.

Example:
Use lxaLoadLicense to create LexalyticsLicense structure. This will then be given to lxaOpenSalienceSession, which is then used to start a session with Salience.

char *acTagFile = "c:/sometags.dat";

//Set up the parameters as well as the license here
if (lxaOpenSalienceSession(oLicense, &pSession, &acError) == LXA_OK) {
  lxaSetSalienceCallback(pSession, &mycallback,NULL);
  lxaSetTagDefinitions(pSession, acTagFile);
  lxaCloseSalienceSession(pSession);
}

lxaSetSalienceOptionWithString

Summary: Sets one or more options via a specially formatted string. This is an alternative to lxaSetSalienceOption which requires you to programmatically define your option settings. You can also use lxaSetSalienceOptionsWithFile to load options from a file on disk. Refer to Options documentation for the available options that may be set and their purpose.

Returns: Integer return code. To retrieve more information on the return code use lxaGetLastWarnings on the SalienceSession structure.

More information on errors and warnings can be found in the Errors and Warning Codes section of our documentation.

Function Signature:
int lxaSetSalienceOption(SalienceSession *pSession, const char *acOptionString, const char *acConfigurationID);

Parameter

Description

pSession

Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession

acOptionString

Character string that sets desired options.

acConfigurationID

Character string specifying the configuration for the option, blank for the default configuration

Option String Format

Each line in the string sets one option, and the format is "". The quotes around the option name are required. If the option value is a string that should be double quoted as well. The name of each option is available on the Options page.

Example Option String

"Tagging Threshold" 50
"Lists and Tables" 1
"User Entity List" "C:/Salience/user.dat"

lxaSetSalienceOptionsWithFile

Summary: Sets one or more options via a specially formatted file. This is an alternative to lxaSetSalienceOption which requires you to programmatically define your option settings. You can also use lxaSetSalienceOptionWithString to load options from an in memory string. Refer to Options documentation for the available options that may be set and their purpose.

Returns: Integer return code. To retrieve more information on the return code use lxaGetLastWarnings on the SalienceSession structure.

More information on errors and warnings can be found in the Errors and Warning Codes section of our documentation.

Function Signature:
int lxaSetSalienceOption(SalienceSession *pSession, const char *acOptionString, const char *acConfigurationID);

Parameter

Description

pSession

Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession

acOptionString

Path to file that sets desired options.

acConfigurationID

Character string specifying the configuration for the option, blank for the default configuration

Option File Format

Each line in the file sets one option, and the format is "". The quotes around the option name are required. If the option value is a string that should be double quoted as well. The name of each option is available on the Options page.

Example Option String

"Tagging Threshold" 50
"Lists and Tables" 1
"User Entity List" "C:/Salience/user.dat"