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

Text Preparation

lxaPrepareText

Summary

Prepares a piece of text for processing. This function, or its sister function lxaPrepareTextFromFile, must be called every time you want to process a different piece of text. Text should either be 7bit ASCII or UTF8.

Syntax

int lxaPrepareText(SalienceSession *pSession, const char *acText);

Parameters

pSession

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

acText

Pointer to a char* buffer

Returns

This function returns an integer return code.

LXA_OK

Text preparation was successful

LXA_OK_WITH_WARNINGS

The text is malformed in some way. You should call [lxaGetLastWarnings][6] to find out the specifics of the warning.

Notes

Words that exceed 366 characters in length will be truncated. This is twice the length of the longest English word which is not a chemical compound.

Sentences that exceed 1000 words will cause lxaPrepareText to return with LXA_ERROR.

Example

char* acBuffer = "This is some text to process";
         ...
         SalienceSession* pSession;
         if(lxaOpenSalienceSession(oLicense, &oStartup, &pSession) != LXA_OK)
              return 1;
         lxaPrepareText(pSession,acBuffer);
         ...

lxaPrepareTextFromFile

Summary

Prepares the text contents of a file for processing. This function, or its sister function lxaPrepareText, must be called every time you want to process a different piece of text. Text should either be 7bit ASCII or UTF8.

Syntax

int lxaPrepareTextFromFile(SalienceSession *pSession, const char *acFile);

Parameters

pSession

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

acFile

Pointer to a null-terminated string containing the path to the file you want to process

Returns

This function returns an integer return code.

LXA_OK

Text preparation was successful

LXA_OK_WITH_WARNINGS

The text is malformed in some way. You should call lxaGetLastWarnings to find out the specifics of the warning.

Notes

Words that exceed 366 characters in length will be truncated. This is twice the length of the longest English word which is not a chemical compound.

Sentences that exceed 1000 words will cause lxaPrepareTextFromFile to return with LXA_ERROR.

Example

char* acPath = "/path/to/content";
         ...
         SalienceSession* pSession;
         if(lxaOpenSalienceSession(oLicense, &oStartup, &pSession) != LXA_OK)
              return 1;
         lxaPrepareTextFromFile(pSession,acPath);
         ...

lxaAddSection

Summary

Adds the supplied text into a section of the document for analysis. The supplied text should be UTF-8 encoded, not UTF-16.

Syntax

int lxaAddSection(SalienceSession *pSession, 
                  const char *acHeader,
                  const char *acText,
                  int nProcess);

Parameters

pSession

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

acHeader

Pointer to a char* buffer containing the header for the section

acText

Pointer to a char* buffer containing the text for the section

nProcess

Returns

This function returns an integer return code.

lxaAddSectionFromFile

Summary

Adds the text from the supplied file into a section of the document for analysis. The supplied text should be UTF-8 encoded, not UTF-16.

Syntax

int lxaAddSectionFromFile(SalienceSession *pSession, 
                          const char *acHeader,
                          const char *acFile,
                          int nProcess);

Parameters

pSession

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

acHeader

Pointer to a char* buffer containing the header for the section

acFile

Pointer to a char* buffer containing the path to a text file for the section

nProcess

Returns

This function returns an integer return code.

lxaPrepareCollection

Summary

Prepares the contents of a [SalienceCollection][4] structure for processing. This function, or its sister function [lxaPrepareCollectionFromFile][3], must be called every time you want to process a different set of related pieces of text. Text within individual members of collection should either be 7bit ASCII or UTF8.

Syntax

int lxaPrepareCollection(SalienceSession *pSession, SalienceCollection *pCollection);

Parameters

pSession

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

pCollection

Pointer to a SalienceCollection structure containing the related pieces of text you want to process

Returns

This function returns an integer return code.

LXA_OK

Text preparation was successful

LXA_OK_WITH_WARNINGS

The text is malformed in some way. You should call lxaGetLastWarnings to find out the specifics of the warning.

Example

vector<char*> myVector(0);
         myVector.push_back(acText1);
         myVector.push_back(acText2);
         ...
         int nSize = myVector.size();
         ...
         SalienceSession* pSession;
         if(lxaOpenSalienceSession(oLicense, &oStartup, &pSession) != LXA_OK)
              return 1;
         SalienceCollection oCollection;
         oCollection.acCollectionName = "MyCollection";
         oCollection.nSize = nSize;
         oCollection.pDocuments =
         (SalienceCollectionDocument*)malloc(sizeof(SalienceCollectionDocument) * nSize);
    
         for(int i=0; i < nSize; i++)
         {
              oCollection.pDocuments[i].acText = myVector[i];
              oCollection.pDocuments[i].acIndentifier = "myDoc";
              oCollection.pDocuments[i].nIsText = 1;
              oCollection.pDocuments[i].nSplitByLine = 0;
         }
    
         if (lxaPrepareCollection(pSession, &pCollection) != LXA_OK)
              return 1;
         ...

lxaPrepareCollectionFromFile

Summary

Prepares the contents of a file as a collection for processing. This function, or its sister function lxaPrepareCollection, must be called every time you want to process a different set of related pieces of text. The contents of the file are expected to be 7bit ASCII or UTF8.

Syntax

int lxaPrepareCollectionFromFile(SalienceSession* pSession, 
                                 const char* acCollectionName, 
                                 const char* acFile);

Parameters

pSession

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

acCollectionName

Pointer to a null-terminated string containing a descriptive name for the collection

acFile

Pointer to a null-terminated string containing the path to the file you want to process

Returns

This function returns an integer return code. The most common return codes are shown below, see the [Errors and Warning Codes][6] page for other error return codes.

LXA_OK

Text preparation was successful

LXA_OK_WITH_WARNINGS

The text is malformed in some way. You should call lxaGetLastWarnings to find out the specifics of the warning.

Comments

TODO: insert information about structure of valid file for use with lxaPrepareCollectionFromFile

Example

char* acPath = "/path/to/content";
         ...
         SalienceSession* pSession;
         if(lxaOpenSalienceSession(oLicense, &oStartup, &pSession) != LXA_OK)
              return 1;
         SalienceCollection oCollection;
         oCollection.nSize = 1;
         oCollection.acCollectionName = "MyCollection";
    
         if(lxaPrepareCollectionFromFile(pSession,oCollection.acCollectionName,acPath) != LXA_OK);
              return 1;
         ...

Updated 7 months ago

Text Preparation


Suggested Edits are limited on API Reference Pages

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