A constructor used to load a weighted dictionary from a file
Namespace: NetricsServerInterface
Assembly: NetricsServerInterface (in NetricsServerInterface.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub New( _ ByVal name As String, _ ByVal filename As String, _ ByVal encoding As String _ ) |
C# |
---|
public NetricsWeightedDictionary( string name, string filename, string encoding ) |
C++ |
---|
public: NetricsWeightedDictionary( String name, String filename, String encoding ) sealed |
J# |
---|
public NetricsWeightedDictionary( string name, string filename, string encoding ) |
JScript |
---|
public function NetricsWeightedDictionary( name : String, filename : String, encoding : String ) |
Parameters
- name
- The name of the dictionary to be created
- filename
- The name of the file from which to read the dictionary. This file must be accessible by the server.
- encoding
- This defines the character encoding used in the file. Currently supported encodings are: "UTF-8" or "LATIN1". DEFAULT: "LATIN1"
Remarks
In this case, dictionary equivalence classes are loaded from a CSV file read by the server. Each line will be an equivalence class and terms are comma separated. Do not call addEquivalenceClass or addClassesFrom when using this constructor - it will throw an exception. For a weighted dictionary there should be at least two items per line. The first item is the weight and the remaining items are the terms to be weighted. File should be CSV format.
A sample Weighted Dictionary csv file consisting of 3 classes follows:
0.6,Liability Limited Company,LLC,L.L.C.
0.2,Inc,Incorporated
-1.0,the
The special weight value -1.0 is used to indicate a "stop token" A stop token is treated as if it does not exist at all.
Example
This sample code shows how to create a Weighted Dictionary in a TIBCO Patterns Engine.
![]() | |
---|---|
using NetricsServerInterface; class MyClass { private static NetricsServerInterface.NetricsServerInterface si = null; public static void Main() { try { String host = "localhost"; int port = 5051; si = new NetricsServerInterface.NetricsServerInterface(host, port); // Weighted Dictionary input csv file String file = "c:\\temp\\WeightedDictionary.csv"; //Combined Thesaurus name String thesaurus = "myWeightedDictionary"; // Use default encoding which is LATIN1 specified by the null NetricsWeightedDictionary wd = new NetricsWeightedDictionary(thesaurus, file, null); si.wdcreate(wd); Console.Write("Weighted Dictionary created.\n"); } catch (NetricsException e) { Console.Write(e.getErrorDescription() + "\n"); } } } |