lxaLoadLicense
Summary
This function loads a license file.
Syntax
int lxaLoadLicense(const char* acPath, LexalyticsLicense* pLicense, char** acError);
Parameters
| Pointer to a null-terminated string containing the path to the required license file |
---|---|
| Pointer to a LexalyticsLicense structure |
| Pointer to a char* buffer |
Returns
If the license is not loaded, i.e. the return value is not LXA_OK then acError
will be filled with a descriptive error message. You should use lxaFreeString to free this buffer.
Example
char* acLicensePath = "/path/to/license/file";
char* acError;
LexalyticsLicense oLicense;
if(lxaLoadLicense(acLicensePath, &oLicense, &acError) != LXA_OK)
{
std::cout << acError << std::endl;
return 1;
}
lxaFreeString(acError);
...
lxaOpenSalienceSession
Summary
Opens the session. You MUST call this function before you call any others as you have to pass the SalienceSession structure into any of the other functions.
Syntax
int lxaOpenSalienceSession(LexalyticsLicense pLicense,
SalienceSessionStartup* pOptions,
SalienceSession **ppSession);
Parameters
| Pointer to a LexalyticsLicense structure |
---|---|
| Pointer to a SalienceSessionStartup structure |
| Pointer to a pointer to a SalienceSession structure |
Returns
If a session is not created (i.e. the return value is not LXA_OK) then the acError
member of the SalienceSessionStartup structure will be filled with a descriptive error message. This is a fixed length character buffer, and does not need to be freed via lxaFreeString.
Example
char* acPath = "/path/to/content";
char* acLicensePath = "/path/to/license/file";
char* acDataDirectory = "/path/to/data/directory";
char* acError;
LexalyticsLicense oLicense;
if(lxaLoadLicense(acLicensePath, &oLicense, &acError) != LXA_OK)
{
std::cout << acError << std::endl;
return 1;
}
SalienceSessionStartup oStartup;
strcpy(oStartup.acDataDirectory, acDataDirectory);
oStartup.nStartupLog = 1;
SalienceSession* pSession;
if(lxaOpenSalienceSession(oLicense, &oStartup, &pSession) != LXA_OK)
return 1;
...
lxaCloseSalienceSession
Summary
Closes the Salience session. Call this function when you finished to free up all the allocated resources.
Syntax
int lxaCloseSalienceSession(SalienceSession *pSession);
Parameters
| Pointer to the SalienceSession structure |
---|
Returns
Integer return code.
Example
char* acPath = "/path/to/content";
char* acLicensePath = "/path/to/license/file";
char* acDataDirectory = "/path/to/data/directory";
char* acError;
LexalyticsLicense oLicense;
if(lxaLoadLicense(acLicensePath, &oLicense, &acError) != LXA_OK)
{
std::cout << acError << std::endl;
return 1;
}
SalienceSessionStartup oStartup;
strcpy(oStartup.acDataDirectory, acDataDirectory);
oStartup.nStartupLog = 1;
SalienceSession* pSession;
if(lxaOpenSalienceSession(oLicense, &oStartup, &pSession) != LXA_OK)
return 1;
...
lxaCloseSalienceSession(pSession);
lxaGetSalienceVersion
Summary
Gets the version of the library. You can use this to display a version of the underlying Salience Engine in use. Call lxaFreeString to release the memory.
Syntax
int lxaGetSalienceVersion(char **ppBuffer);
Parameters
| Pointer to a char* buffer |
---|
Returns
Integer return code.
Example
char* acVersion;
lxaGetSalienceVersion(&acVersion);
std::cout << acVersion << std::endl;
lxaFreeString(acVersion);
lxaGetDefaultSalienceLocation
Summary
Gets the root location for the Salience installation. On Windows, this is based on the value of a registry key created during install. On Linux, it is based on the lxainstall
environment variable. Call lxaFreeString to release the memory.
Syntax
int lxaGetDefaultSalienceLocation(char **ppBuffer);
Parameters
| Pointer to a char* buffer |
---|
Returns
Integer return code.
Example
char* acRootPath;
lxaGetDefaultSalienceLocation(&acRootPath);
std::cout << acRootPath << std::endl;
lxaFreeString(acRootPath);
lxaAddSalienceConfiguration
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 acConfigurationID
.
Calling this method with a value for acConfigurationID
that has been previously added will result in an error code returned.
Syntax
int lxaAddSalienceConfiguration(SalienceSession *pSession,
const char *acUserDir,
const char *acConfigurationID);
Parameters
| Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession |
---|---|
| Path to a user directory to use for this configuration |
| Character string specifying a unique identifier for this configuration |
Returns
Integer return code. LXA_OK
indicates success, LXA_CONFIG_IN_USE
indicates the provided configuration ID has already been added to the session.
lxaRemoveSalienceConfiguration
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 acConfigurationID
that has not been previously added by a call to lxaAddSalienceConfiguration 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.
Syntax
int lxaRemoveSalienceConfiguration(SalienceSession *pSession,
const char *acConfigurationID);
Parameters
| Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession |
---|---|
| Character string specifying a unique identifier for a configuration previously added to the session |
Returns
Integer return code. LXA_OK
indicates success, LXA_INVALID_CONFIG
indicates the provided configuration ID has already been added to the session, also returned if this method is called with an empty string for acConfigurationID
.
lxaRunModelSmokeTest
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).
The acConfigurationID
parameter specifies the configuration for the results, which are returned in a ModelSmokeTestList structure. Configurations are defined using the method lxaAddSalienceConfiguration.
Syntax
| Pointer to a SalienceSession structure previously returned by a call to lxaOpenSalienceSession |
---|---|
| Pointer to a ModelSmokeTestList structure that will get filled in by the call |
| Pointer to a ModelSmokeTestList structure that will get filled in by the call |
| Character string specifying the configuration for the results, blank for the default configuration |
Returns
This method returns an integer return code.
Example
ModelSmokeTestList oSuccesses;
ModelSmokeTestList oFailures;
int ret = lxaRunModelSmokeTest(pSession,&oSuccesses, &oFailures, acConfigId);
if (ret != 0) {
cout << "function failed with Salience error " << ret << endl;
} else if (oSuccesses.nEntries == 0) {
cout << "smoke testing was not successfully invoked." << endl;
} else if (oFailures.nEntries == 0) {
cout << "No errors found." << endl;
} else {
for (int i = 0; oFailures.nEntries; i++) {
cout << "acModelPath: " << oFailures.pEntries->acModelPath << endl;
cout << "acMessage: " << oFailures.pEntries->acMessage << endl;
cout << "acExplanation: " << oFailures.pEntries->acExplanation << endl;
cout << "acDocumentId: " << oFailures.pEntries->acDocumentId << endl;
cout << "acExpectedLabel: " << oFailures.pEntries->acExpectedLabel << endl;
cout << "acActualLabel: " << oFailures.pEntries->acActualLabel << endl;
cout << "acExpectedSpanOffset: " << oFailures.pEntries->acExpectedSpanOffset << endl;
cout << "acActualSpanOffset: " << oFailures.pEntries->acActualSpanOffset << endl;
cout << "acExpectedSpanLength: " << oFailures.pEntries->acExpectedSpanLength << endl;
cout << "acActualSpanLength: " << oFailures.pEntries->acActualSpanLength << endl;
}
}
Updated 11 months ago