ibi Patterns .NET API
Loading...
Searching...
No Matches
NetricsServerInterface.NetricsThesaurus Class Reference

This class contains a list of synonyms that can be used while searching. More...

Public Member Functions

 NetricsThesaurus (String name)
 A thesaurus is used to equate terms which are not typographically similar.
 
 NetricsThesaurus (String name, String filename, String encoding)
 A thesaurus is used to equate terms which are not typographically similar.
 
void addEquivalenceClass (String[] terms)
 Add an array of synonyms.
 
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

This class contains a list of synonyms that can be used while searching.

See also
NetricsServerInterface.thcreate

Constructor & Destructor Documentation

◆ NetricsThesaurus() [1/2]

NetricsServerInterface.NetricsThesaurus.NetricsThesaurus ( String  name)
inline

A thesaurus is used to equate terms which are not typographically similar.

Dick is a commonly used nickname for Richard, and the terms should be considered to be equivalent. This can be accomplished by loading a thesaurus in which these two terms share an equivalence class. In general, all terms which are synonyms but are not typographically similar should be included in a thesaurus. If a term is included in two equivalence classes, it is considered to be a synonym for all terms in both classes. However, each term in the first class is not considered to be a synonym of each term in the second class. For instance, although duck might be a synonym for bird and crouch, bird and crouch are not considered synonyms.

This constructor creates an empty thesaurus, one with no equivalence classes. Classes must be added using the addClassesFrom or addEquivalenceClass methods.

Parameters
nameThe name of the thesaurus
See also
NetricsThesaurus(String, String, String)

Sample code

◆ NetricsThesaurus() [2/2]

NetricsServerInterface.NetricsThesaurus.NetricsThesaurus ( String  name,
String  filename,
String  encoding 
)
inline

A thesaurus is used to equate terms which are not typographically similar.

In this case, thesaurus 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 addEquivalence class when using this constructor - it will throw an exception.

A sample Thesaurus csv file consisting of 2 records follows:

Margaret,Margie,Peggy
Inc,Incorporated

This sample code shows how to create a Thesaurus in the ibi™ Patterns - Search Server running on the localhost listening to port 5051.

class MyClass
{
private static NetricsServerInterface.NetricsServerInterface si = null; <br>
public static void Main()
{
try
{
String host = "localhost";
int port = 5051;
// Thesaurus input csv file
String file = "c:\\temp\\nicknames.csv";
//Combined Thesaurus name
String thesaurus = "nicknames";
// Use default encoding which is LATIN1 specified by the null
NetricsThesaurus th = new NetricsThesaurus(thesaurus, file, null);
si.thcreate(th);
Console.Write("Thesaurus created.\n");
}
catch (NetricsException e)
{
Console.Write(e.getErrorDescription() + "\n");
}
}
}
A NetricsException is thrown whenever an error occurs.
Definition: NetricsException.cs:32
String getErrorDescription()
Get the description of the error.
Definition: NetricsException.cs:110
Base class for all interactions with the ibi™ Patterns - Search Server.
Definition: NetricsServerInterface.cs:62
This class contains a list of synonyms that can be used while searching.
Definition: NetricsThesaurus.cs:17
ibi™ Patterns - Search .NET Interface Overview.
Definition: BaseObjectStats.cs:14
Parameters
nameThe name of the thesaurus to be created
filenameThe 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.
encodingThis defines the character encoding used in the file. Currently supported encodings are: "UTF-8" or "LATIN1". DEFAULT: "LATIN1"

Member Function Documentation

◆ addClassesFrom()

int NetricsServerInterface.NetricsThesaurus.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. Each equivalence class must have at least two entries.

Parameters
rsrcA NetricsFieldedReader object that provides the equivalence classes.
Returns
the number of classes added.

◆ addEquivalenceClass()

void NetricsServerInterface.NetricsThesaurus.addEquivalenceClass ( String[]  terms)
inline

Add an array of synonyms.

Parameters
termsAll Strings which are elements of the array are considered to be equal for the purpose of record scoring.