A.2.2 The MATCH Command

The MATCH command searches for word in the database index. The searching algorithm is called strategy. The following strategies are supported by the server:

exact

Match a word exactly (case-insensitive).

prefix

Match a word prefix (case-insensitive).

soundex

Match using SOUNDEX algorithm.

lev

Match headwords within given Levenshtein distance. That distance, called a Levenshtein threshold is by default 1. It can be modified using the XLEV extension command (see section XLEV).

dlev

Match headwords within given Damerau-Levenshtein distance. That distance is the same as for the ‘lev’ strategy.

re

Match using POSIX 1003.2 (a.k.a ‘extended’) regular expressions.

regexp

Match using basic regular expressions.

The dictorg module (see section The dictorg module.) additionally provides the following strategy:

suffix

Match word suffixes (case-insensitive).

Other modules may provide more matching strategies.

Command: MATCH database strategy word

Match word in database using strategy. As with DEFINE, the database can be ‘!’ or ‘*’ (See section The DEFINE Command, for a detailed description of these wildcards).

The strategy is either the name of a strategy to use, or a dot (‘.’), meaning to use default strategy. The default strategy is set using default-strategy configuration file statement (see section default-strategy. Its default value is ‘lev’, which means ‘use Levenshtein algorithm’ (see above).

If no matches are found in any of the searched databases, then response code 552 will be returned. Otherwise, response code 152 will be returned followed by a list of matched words, one per line, in the form:

 
database word

Thus, prepending a ‘DEFINE ’ to each such response, one obtains a valid DEFINE command.

The textual body of the match list is terminated with a line containing only a dot character.

Following the list, response code 250 is sent, which includes timing information, if timing directive is set in the configuration file (see section Tuning).

Possible responses:

550 Invalid database, use SHOW DB for a list
551 Invalid strategy, use SHOW STRAT for a list
552 No match
152 n matches found: list follows
250 ok (optional timing information here)

Examples:

 
C: MATCH * . "weather"
S: 152 12 matches found: list follows
C: eng-afr "feather"
C: eng-afr "leather"
C: eng-afr "weather"
C: eng-deu "feather"
C: eng-deu "heather"
C: eng-deu "leather"
C: eng-deu "weather"
C: eng-deu "wether"
C: eng-deu "wheather"
C: devils "WEATHER"
S: .
S: 250 Command complete [d/m/c = 0/12/100677 0.489r 0.479u 0.007s]