The Options File feature of Salience allows users to set one or more options via a specially formatted file for a Salience session. This is an alternative to functions like setOption which requires users to programmatically define option settings. Refer to Options documentation for the available options that may be set and their purpose.
- Setting more than one Option using the Options File removes the need to call the setOptions function more than once. By having a file of all the options set for a session in a single place, changes can be made more efficiently and with less looking through code.
- By setting all the options for a session with one file, users reduce the amount of redundant work needed to create different Salience sessions. One Option File can be made and referenced in various sessions. Alternatively, different Options Files can be made for various uses. For example, one for Twitter data and one for long articles. \ Options Files have the same formatting no matter the wrapper being used so a file made for one wrapper can be used for another as well.
The first step in using the Options File feature is to make an Options File. This is a specifically formatted file in which a user can set all the options that they desire. Each line in the file sets one option, and the format is "". The quotes around the option name are required. If the option value is a string that should be double quoted as well. The any options and their settings can be found on the Options page. This file can be saved in a variety of formats, such as .dat or .txt. For this example the file was saved as a .txt file.
An example of an Options file can be seen below.
"Flatten All Upper Case" 1
"One Sentence" 0
"Max Collection Size" 50000
"Collection Result Size" 20
"User Directory" "C:/Program Files (x86)/Lexalytics/data/user"
The code snips provided below are based on the Salience Python wrapper, a similar approach exists in the other wrappers provided in the Salience distribution. The code operates on these initial assumptions:
- Processing on Windows
- With salience6 imported as import salience6 as SE6
- Start by initializing a Salience session with the path to your license file and path to the default data directory
session = SE6.openSession(licensePath, dataDirectoryPath)
- Call setOptionsWithFile() with the session and path to your options file
Note: If you want to check and see that your options were set you can use the line
to print out the options for your session before and after calling setOptionsWithFile
- Perform any other actions with Salience as desired.
There is a negligible performance impact when using the Options File feature.
The C API sentiment dictionary option allows users to add, set, or clear HSD (hand-scored dictionary) files. The Sentiment Dictionary option in the Options File feature only allows for the addition of HSD files. If you want to layer HSD files you simply add an additional “Sentiment Dictionary” line to the Options File as seen below.
"Sentiment Dictionary" "path_to_first_HSD_file"
"Sentiment Dictionary" "path_to_second_HSD_file"
Updated over 1 year ago