# add-spell-rule(2)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

add-spell-rule - Add a new spelling rule to the dictionary

## SYNOPSIS

n add-spell-rule [ "rule-letter" "base-ending" "remove" "derive-ending" ]

## DESCRIPTION

add-spell-rule adds a new spelling rule to the speller. The rules effectively define the prefix and suffix character replacements of words, which is given an alphabetical identifier used within the speller , in conjunction with the language dictionary. The letter conventions are defined by the Free Software Foundation GNU ispell(1) package.

add-spell-rule is used in the MicroEmacs 2009 dictionary initialization files called <language>r.emf, e.g. `americar.erf`, `britishr.erf` supplied in the MicroEmacs macros directory.

The command takes a single numeric argument n to control the addition of a rule to the speller, as follows:-

`0` add-spell-rule

Removes all existing rules and re-initializes. This is, by convention, explicitly called before instantiating a new set of rules.

`-1` add-spell-rule "rule-letter" "base-ending" "" "deriv-ending"

`-2` add-spell-rule "rule-letter" "base-ending" "" "deriv-ending"

Adds a prefix rule, an argument of -1 indicates that this prefix rule cannot be used with a suffix rule. An argument of -2 indicates it can be matched with any suffix rule which can be used with a prefix rule (e.g. argument of 2).

"rule-letter" is any character in the range `A`-`z` except '`_`', all rules of the given letter must be a prefix rule of the same type (i.e. same argument). The start of a base word must match the given "base-ending" regular expression string for the rule to be applied, the "remove" string must be empty for a prefix and the "deriv-ending" is the prefix string. Example, for the American language;-

`-2 add-spell-rule "I" "" "" "in"` ; As in disposed > indisposed

A prefix rule of type '`I`' can be applied to any base word which has rule '`I`' enabled, and it prefixes "`in`" to the word.

`1` add-spell-rule "rule-letter" "base-ending" "remove" "deriv-ending"

`2` add-spell-rule "rule-letter" "base-ending" "remove" "deriv-ending"

Add suffix rules. An argument of 1 indicates that this prefix rule cannot be used with a prefix rule. An argument of 2 indicates it can be matched with any prefix rule which can be used with a suffix rule (i.e. argument of -2).

"rule-letter" is any character in the range `A`-`z`, all rules of the given letter must be a suffix rule of the same type (i.e. same argument). The end of a base word must match the given "base-ending" regular expression string for the rule to be applied, the "remove" string must be a fixed string and the "deriv-ending" must also be a fixed string which is appended to the base-word after "remove" has been removed. Example, for the American language;-

    2 add-spell-rule "N" "e" "e" "ion"     ; As in create > creation
    2 add-spell-rule "N" "y" "y" "ication" ; As in multiply > multiplication
    2 add-spell-rule "N" "[^ey]" "" "en"   ; As in fall > fallen

A suffix rule of type '`N`' can be applied to any base word which has rule '`N`' enabled, and it can be used with prefixes, e.g. with rule;-

    -2 add-spell-rule "A" "" "" "re"       ; As in enter > reenter

to derive "recreation" from "create". A rule which cannot be used with prefixes, i.e.:

    1 add-spell-rule "V" "e" "e" "ive"     ; As in create > creative
    1 add-spell-rule "V" "[^e]" "" "ive"   ; As in prevent > preventive

While some prefix words are legal, such as "recreative" but some are not, such as "collect" where "recollect" is correct, so is "collective" but "recollective" is not.

## SPECIAL RULES

Following are special forms of add-spell-rule used for tuning the spell support, note that an argument can not be given:-

add-spell-rule "-" "<y|n>"

Enables and disables the acceptance of hyphens joining correct words. By default the phrase "`out-of-date`" would be accepted in American even though the phrase does not exist in the American dictionary. This is because the three words making up the phrase are correct and by default hyphens joining words are allowed. Some Latin language such as Spanish do not use this concept so this feature can be disable.

add-spell-rule "#" "score"

Sets the maximum allowed error score when creating a spelling guess list. When comparing a dictionary word with the user supplied word, spell checks for differences, each difference or error is scored in the range of 20 to 27 points, once the maximum allowed score has been exceeded the word is ignored. The default guess error score is 60, allowing for 2 errors.

add-spell-rule "*" "regex"

Adds a correct word in the form of a regex if a word being spell checked is completely matched by the regex the word is deemed to be correct. For example, the following rule can be used to make the spell-checker allow all hex numbers:

    add-spell-rule "*" "0[xX][[:xdigit:]]+"

This will completely match the words "`0x0`", "`0xff`" etc but not "`0x00z`" as the whole word is not matched, only the first 4 letters.

## NOTES

The format of the dictionary is a list of base words with each word having a list of rules which can be applied to that word. Therefore the list of words and the rules used for them are linked e.g.

    aback
    abaft
    abandon/DGRS
    abandonment/S
    abase/DGRS
    abasement/S
    abash/DGS
    abashed/U
    abate/DGRS

where the "`/...`" is the valid list of rules for that word.

The '_' character is used to separate different rule lists for a single word.

The format of the dictionary word list and the rule list is compatible with ispell(1).

## SEE ALSO

add-dictionary(2), spell(2) spell-buffer(3), spell-word(3), ispell(1).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>