| ibi Patterns .NET API

Loading...
Searching...
No Matches
Public Member Functions | List of all members
NetricsServerInterface.NetricsWeightedDictionary Class Reference

Objects of this class represent a weighted dictionary, used to define terms with lesser or greater importance. More...

## Public Member Functions
| NetricsWeightedDictionary (String name)
| Create an empty Weighted Dictionary.
| NetricsWeightedDictionary (String name, String filename, String encoding)
void | addEquivalenceClass (String[] terms, double weight)
| Add terms with associated weight.
int | addClassesFrom (NetricsFieldedReader rsrc)
| Add a set of classes from a fielded source.
Public Member Functions inherited from NetricsServerInterface.NetricsBaseThesaurus
void | setCharmap (String name)
| Specifies the character map used to translate thesaurus entries.
void | setExactMatchMode ()
| Select exact match mode.

## Detailed Description

Objects of this class represent a weighted dictionary, used to define terms with lesser or greater importance.

A weighted dictionary is used to weight terms which should have more or less relevance than other terms. For instance, in a company names table, the term "company" might be given less weight as it is less indicative of a match (i.e. it is shared by many company names that are unrelated)."

## Constructor & Destructor Documentation

## ◆ NetricsWeightedDictionary() [1/2]

NetricsServerInterface.NetricsWeightedDictionary.NetricsWeightedDictionary | ( | String | name | ) |
| inline

Create an empty Weighted Dictionary.

A weighted dictionary is used to weight terms which should have more or less relevance than other terms. For instance, in a company names table, the term "company" might be given less weight as it is less indicative of a match (i.e. it is shared by many company names that are unrelated).

This constructor creates an empty Weighted Dictionary (one with no equivalence classes defined) with the given name. Equivalence classes must be added using the addEquivalenceClass or addClassesFrom methods.

Parameters

  name | The name of the weighted dictionary to be created.

See also
  NetricsWeightedDictionary(String, String, String)

Sample code

See also
  NetricsWeightedDictionary.addEquivalenceClass(String[], double), NetricsWeightedDictionary.addClassesFrom(NetricsFieldedReader)

## ◆ NetricsWeightedDictionary() [2/2]

NetricsServerInterface.NetricsWeightedDictionary.NetricsWeightedDictionary | ( | String | name,
|  | String | filename,
|  | String | encoding
| ) |  |
| inline

A constructor used to load a weighted dictionary from a file

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.

This sample code shows how to create a Weighted Dictionary in an ibi™ Patterns - Search Server.

using NetricsServerInterface; <br>
class MyClass
{
private static NetricsServerInterface.NetricsServerInterface si = null; <br>
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");
}
}
}
NetricsServerInterface.NetricsException
A NetricsException is thrown whenever an error occurs.
Definition: NetricsException.cs:32
NetricsServerInterface.NetricsException.getErrorDescription
String getErrorDescription()
Get the description of the error.
Definition: NetricsException.cs:110
NetricsServerInterface.NetricsServerInterface
Base class for all interactions with the ibi™ Patterns - Search Server.
Definition: NetricsServerInterface.cs:62
NetricsServerInterface.NetricsWeightedDictionary
Objects of this class represent a weighted dictionary, used to define terms with lesser or greater im...
Definition: NetricsWeightedDictionary.cs:22
NetricsServerInterface
ibi™ Patterns - Search .NET Interface Overview.
Definition: BaseObjectStats.cs:14

Parameters

  name | The name of the dictionary to be created
  filename | The name of the file (on the server) from which to read the thesaurus. The file must be located inside the server's loadable-data directory.
  encoding | This defines the character encoding used in the file. Currently supported encodings are: "UTF-8" or "LATIN1". DEFAULT: "LATIN1"

## Member Function Documentation

## ◆ addClassesFrom()

int NetricsServerInterface.NetricsWeightedDictionary.addClassesFrom | ( | NetricsFieldedReader | rsrc | ) |
| inline

Add a set of classes from a fielded source.

This adds a set of equivalence classes from a fielded record source. Each fielded record is considered one equivalence class. The first entry must be the class weight (as a string representation of a floating point value). Thus each equivalence class must have at least two entries.

Parameters

  rsrc | A NetricsFieldedReader object that provides the equivalence classes.

Returns
  the number of classes added.

## ◆ addEquivalenceClass()

void NetricsServerInterface.NetricsWeightedDictionary.addEquivalenceClass | ( | String[] | terms,
|  | double | weight
| ) |  |
| inline

Add terms with associated weight.

This adds one class of equivalent terms to the weighted dictionary.

Parameters

  terms | The terms to be weighted.
  weight | The weighting factor applied to the terms.