<< Salience.AddSentimentDictionary | Back to Salience 6 .Net Index | Salience.PrepareTextFromFile >>


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


public int PrepareText(string sText)


sText String containing the text to be analyzed


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.


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.


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

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

    int nRet = Engine.PrepareText("Lexalytics is headquartered in Amherst, MA");
    if (nRet==0)

<< Salience.AddSentimentDictionary | Back to Salience 6 .Net Index | Salience.PrepareTextFromFile >>