prepareText
Summary
Prepares a piece of text for processing. This function, or its sister function prepareTextFromFile, must be called every time you want to process a different piece of text. Text should either be 7bit ASCII or UTF8.
This method provides a wrapper around the underlying C API method lxaPrepareText.
Syntax
salience6.prepareText(oSession, sText)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| A text string to be analyzed |
Returns
Returns an integer return code. Possible error return codes are specified on the Errors and Warning Codes page.
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 the underlying call to lxaPrepareText to return with LXA_ERROR.
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
ret = se6.prepareText(session,'Lexalytics is based in Amherst, MA.')
if (ret==0):
...extract results from text...
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
prepareTextFromFile
Summary
Prepares text contents of a file for processing. This function, or its sister function prepareText, must be called every time you want to process a different piece of text. The text file should either be 7bit ASCII or UTF8.
This method provides a wrapper around the underlying C API method lxaPrepareTextFromFile.
Syntax
salience6.prepareTextFromFile(oSession, sFile)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| Fully-qualified path to a readable text file |
Returns
Returns an integer return code. Possible error return codes are specified on the Errors and Warning Codes page.
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 the underlying call to lxaPrepareTextFromFile to return with LXA_ERROR.
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):
...extract results from text...
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
addSection
Summary
Adds the supplied text into a section of the document for analysis. The supplied text should be UTF-8 encoded, not UTF-16.
This method provides a wrapper around the underlying C API method lxaAddSection.
Syntax
salience6.addSection(oSession, sHeader, sText, nProcess)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| A text string specifying the header for the section |
| A text string for the section |
|
Returns
Returns an integer return code. Possible error return codes are specified on the Errors and Warning Codes page.
addSectionFromFile
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.
This method provides a wrapper around the underlying C API method lxaAddSectionFromFile.
Syntax
salience6.addSectionFromFile(oSession, sHeader, sPath, nProcess)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| A text string specifying the header for the section |
| Path to a valid text file containing text for the section |
|
Returns
Returns an integer return code. Possible error return codes are specified on the Errors and Warning Codes page.
prepareCollectionFromList
Summary
Prepares the contents of a list for processing. This function, or its sister function prepareCollectionFromFile, must be called every time you want to process a different set of related pieces of text. The list must consist of individual strings that are either 7bit ASCII or UTF8.
This method provides a wrapper around the underlying C API method lxaPrepareCollection.
Syntax
salience6.prepareCollectionFromList(oSession, sName, lstContent)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| A descriptive name for the collection |
| A list of text strings to process as a collection of related content |
Returns
Returns an integer return code. Possible error return codes are specified on the Errors and Warning Codes page.
Example
import salience6 as se6
session = se6.openSession('/path/to/license.v5','/path/to/data')
# Prepare the collection
content = []
content.append("The cruise was excellent and service was great.")
content.append("I found the temperature in the dining rooms very cold.")
...
ret = se6.prepareCollectionFromList(session, 'myCollection', content)
if (ret==0):
...extract results from text...
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
prepareCollectionFromFile
Summary
Prepares the contents of a file for collection processing. This function, or its sister function prepareCollectionFromList, must be called every time you want to process a different set of related pieces of text. The file must consist of individual strings that are either 7bit ASCII or UTF8.
This method provides a wrapper around the underlying C API method lxaPrepareCollectionFromFile.
Syntax
salience6.prepareCollectionFromFile(oSession, sName, sPath)
Parameters
| A SalienceSession object previously created via openSession |
---|---|
| A descriptive name for the collection |
| A text file containing a list of text strings to process as a collection of related content |
Returns
Returns an integer return code. Possible error return codes are 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.prepareCollectionFromList(session, 'myCollection', '/path/to/aFile.txt')
if (ret==0):
...extract results from text...
else:
if (ret==6):
print se6.getLastWarnings(session)
se6.closeSession(session)
Updated about a year ago