IComparerClass.FreeTextComparer

Syntax

FreeTextComparer: IComparer;

Description

The FreeTextComparer property returns an object for free text comparison.

Comments

On comparing it checks occurrence of the X string in the Y string. If the string consists of several words, occurrence is checked by each word individually. On searching occurrence, noun endings are skipped. For example, for words Income, Incomes, the occurrence Income is searched.

For this object the IComparer.Compare method returns:

To use advanced comparison parameters, cast value of the FreeTextComparer property to the IFreeTextComparer type.

Example

Sub UserProc;

 

Function TestCompare(x : String; y : String): Integer;

Var

pComparer : IComparer;

iResult : Integer;

Begin

pComparer := Comparer.FreeTextComparer;

iResult := pComparer.Compare(x, y);

Select Case iResult

Case  0: Debug.WriteLine("'" + x + "'  '" + y + "' - objects match");

Case -1: Debug.WriteLine("'" + x + "'  '" + y + "' -> partial match or occurrence is not found");

End Select;

Return iResult;

End Function TestCompare;

Begin

TestCompare("find a cat", "finding of cats is some kind of difficult process"); // 0

TestCompare("find a cat", "now we see how cats are found"); //-1

TestCompare("find cats", "there is a cat. find it"); // 0

TestCompare("houses", "housing problem"); //0

TestCompare("trade houses", "trade house"); //0

TestCompare("houses trade", "trade house"); //-1

TestCompare("Income", "country population"); //-1

End Sub UserProc;

After executing the example the result of comparison is displayed in the console window:

Module execution started

'find a cat'  'finding of cats is some kind of difficult process' -> objects match

'find a cat'  'now we see how cats are found' -> partial match or occurrence is not found

'find cats'  'there is a cat. find it' -> objects match

'houses'  'housing problem' -> objects match

'trade houses'  'trade house' -> objects match

'houses trade'  'trade house' -> partial match or occurrence are not found

'Income'  'country population' ->partial match or occurrence are not found.

Module execution finished

See also:

IComparerClass