Thesaurus support

Here is the syntax of each definition group:

Read syntax diagramSkip visual syntax diagramSyntax of a thesaurus definition

>>-:WORDS--+--------------------------------+--\n--------------->
           +-:SYNONYM-----------------------+
           '-:RELATED--+------------------+-'
                       '- ( --number-- ) -'

   .----------------------------------------------------------------.
   V                                                                |
>----+-member-term--+--------------------+--------------------+--\n-+-><
     |              '- ( --strength-- ) -'                    |
     '-+-.SYNONYM_OF-----------------------+--associated-term-'
       +-.RELATED_TO--+------------------+-+
       |              '- ( --number-- ) -' |
       +-.BROADER--+------------------+----+
       |           '- ( --number-- ) -'    |
       '-.NARROWER--+------------------+---'
                    '- ( --number-- ) -'

Note that \n is not part of the syntax, but represents the end of a line in the thesaurus definition file.

You can insert comment lines in a thesaurus definition file like this:

# my comment text
:WORDS
A keyword that begins a group of related words.
:SYNONYM,
:RELATED [(number)],
A relation name.

Relation names consist of a relation type and a number. If the number is omitted, zero is assumed, which is the system-provided relation name. :SYNONYM is always the system-provided relation name.

Relation names that begin with a colon, such as :SYNONYM, precede a list of words that are related to each other by the same relation. For example:

:WORDS
 :SYNONYM
   air steward
   cabin staff member
   flight attendant
member-term
A term to be included in the thesaurus dictionary.

This parameter can be useful if you do not want a thesaurus lookup to include words that have a weak relation to the looked up term. Strength is a numerical value from 1 to 100. The default value is 100.

.SYNONYM_OF,
.RELATED_TO [(number)], .BROADER [(number)],
.NARROWER [(number)]
A relation name. Relation names consist of a relation type and a number. If the number is omitted, zero is assumed, which is the system-provided relation name. The relation name .SYNONYM is always the system-provided relation name.

Relation names that begin with a period, such as .SYNONYM_OF, define the relation between one word and another. For example:

:WORDS
   air steward
 .SYNONYM_OF cabin staff member
 .SYNONYM_OF flight attendant

The optional number identifies a user-defined relation. This must be a unique number from the whole thesaurus definition file (currently 1 to 128). For example: RELATED_TO(42).

If you want to use symbolic names for thesaurus relations in your application instead of the relation name and number, your application must handle the name-to-number mapping. For example, if you define the relation opposite_of as RELATED_TO(1), your application must map this name to the internal relation name RELATED_TO(1).

associated-term
Each associated term must be preceded by the relation name. The associated term is related to each member term with respect to the specified relation. If all member terms are related to each other, this can be specified using a member relation. Here is an example of an associated term:
:WORDS:SYNONYM
  reject
  decline
    RELATED_TO(1) accept