Internet Direct (Indy)
Home
PreviousUpNext
TIdDICT.Match Method (String, String, String, TIdMatchList)

Searches a dictionary index for words that match the specified criteria.

Pascal
procedure Match(
    const AWord: String; 
    const ADBName: String; 
    const AStrat: String; 
    AResults: TIdMatchList
); overload;
Parameters 
Description 
AWord 
Word to match in the selected database.
 
ADBName 
Database to search for word matches.
 
AStrat 
Search strategy for the matches.
 
AResults 
Container for matches found in the dictionary indices. 

Match is an overloaded method used to search an index for a dictionary on the DICT server, and reports words found using a particular search strategy. Not all strategies are useful for all dictionaries, and some dictionaries may support additional search strategies (e.g., reverse lookup). 

Match sends the DICT MATCH command using the provided arguments. 

AWord indictes the word to match, and is used relative to the search strategy. 

AResults is the container for the word matches found using a given search strategy. 

All DICT servers implement the MATCH command, and must support the "exact" and "prefix" strategies. These are easy to implement and are generally the most useful. Other strategies are server dependent. 

The "exact" strategy matches a word exactly, although different servers may treat non-alphanumeric data differently. Case-insensitive comparison which ignores non-alphanumeric characters and which folds whitespace is useful for English-language dictionaries. Other comparisons may be more appropriate for other languages or when using extended character sets. 

The "prefix" strategy is similar to "exact", except that it only compares the first part of the word. 

Different servers may implement these algorithms differently. The requirement is that strategies with the names "exact" and "prefix" exist so that a simple client can use them. 

Other strategies that might be considered by a server implementor are matches based on substring, suffix, regular expressions, soundex [KNUTH73], and Levenshtein [PZ85] algorithms. These last two are especially useful for correcting spelling errors. Other useful strategies perform some sort of "reverse" lookup (i.e., by searching definitions to find the word that the query suggests). 

If the database name is specified with an exclamation point (decimal code 33, "!"), then all of the databases will be searched until a match is found, and all matches in that database will be displayed. If the database name is specified with a star (decimal code 42, "*"), then all of the matches in all available databases will be displayed. In both of these special cases, the databases will be searched in the same order as that printed by the "SHOW DB" command. 

If the strategy is specified using a period (decimal code 46, "."), then the word will be matched using a server-dependent default strategy, which should be the best strategy available for interactive spell checking. This is usually a derivative of the Levenshtein algorithm [PZ85]. 

Match sends the DICT MATCH command using the values indicated in ADBName, AStrat, and AWord as arguments. 

If no matches are found in any of the searched databases, then status code 552 will be returned. 

Otherwise, status code 152 will be returned followed by a list of matched words in AResults. 

This makes the responses directly useful in a DEFINE command. 

Following the list, status code 250 is sent, which may include server-specific timing and statistical information, as discussed in the section on the DEFINE command. 

 

Responses

 

Rsp 
Meaning 
550 
Invalid database, use "SHOW DB" for list of databases 
551 
Invalid strategy, use "SHOW STRAT" for a list of strategies 
552 
No match 
152 
n matches found - text follows 
250 
ok (optional timing information here) 

TIdDICT.Match 

TIdMatchList

Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.