Salience Constructor

<< | Back to Salience 6 .Net Index | Salience.GetSalienceVersion >>

Summary

The constructor instantiates a Salience object which provides access to document-level API functionality. For collection-level functionality, a SalienceCollection object should be instantiated.
The constructor provides a wrapper around the underlying C API methods lxaLoadLicense and lxaOpenSalienceSession.

Syntax

Salience(string sLicensePath, string sDataPath)
Salience(string sLicensePath, string sDataPath, string sUserDir)
Salience(string sLicensePath, string sDataPath, string sUserDir, string sLogPath)
Salience(string sLicensePath, string sDataPath, string sUserDir, string sLogPath, SALIENCE_MODE nSalienceMode)
Salience(string sLicensePath, SalienceStartup oStartup)

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
sUserDir String containing the path to a user directory of data file customizations
sLogPath String containing the path to writable location for a startup log
nSalienceMode An integer SALIENCE_MODE value specifying an optional mode for Salience
oStartup A SalienceStartup object containing startup information for the session

Returns

If successful, the constructor returns a Salience object that can be used for processing text. Otherwise, an exception is thrown with information about the failure of the constructor.

Example

    //The SalienceEngine object wraps all of the Salience functionality 
    //and must be initialized to use the library.
    Salience Engine = null;

    //If this application will be run on multiple machines, it may be helpful to read these paths 
    //from a configuration file or a registry key to avoid introducing dependencies on where the 
    //license and data must be installed.
    string licensePath = "C:/Program Files/Lexalytics/License.v5";
    string dataPath = "C:/Program Files/Lexalytics/data";

    try
    {
        //We declared Engine before initializing it so we could put this in a try/catch block, and 
        //have the rest of the code outside.
        Engine = new Salience(licensePath, dataPath);
    }
    catch (SalienceException e)
    {
        /*If the SalienceEngine constructor throws an error, one of these is likely to be true:
         * 1) The license file is missing/invalid/out of date
         * 2) The data directory was missing or contained incorrect files
         * 3) Salience6.dll could not be found. */
        System.Console.WriteLine("Error Loading SalienceEngine: " + e.Message);
        return;
    }

<< | Back to Salience 6 .Net Index | Salience.GetSalienceVersion >>