Salience.PrepareTextFromFile

<< Salience.PrepareText | Back to Salience 6 .Net Index | Salience.AddSection >>

Summary

Provides a path to a text file to Salience 6 for analysis. This method, or PrepareText must be called for each new piece of text that should be analyzed. The contents of the text file must be 7bit ASCII or valid UTF-8.
This method is a a wrapper around the underlying C API method lxaPrepareTextFromFile.

Syntax

public int PrepareTextFromFile(string sFile)

Parameters

sFile Full path to a readable text file

Returns

If successful, an integer return code is returned. Developers should check the integer return code to determine if warnings were issued. Otherwise, an exception is thrown with information about the failure of text preparation.

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

    //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;
    }

    int nRet = Engine.PrepareTextFromFile("C:/Testing/aFile.txt");
    if (nRet==0)
    {
        ....
    }

<< Salience.PrepareText | Back to Salience 6 .Net Index | Salience.AddSection >>