5.5.3 Relationships Between Words
As well as word frequencies, predictive mode dictionaries can store
certain relationships between words, to make learning more
effective. With each word in a dictionary, a list of other words can be
associated. Predictive mode automatically ensures that the weights of
the words in this list are always at least as large as that of the word
they are associated with.
This is most useful when one word is a prefix for another. For example,
you may want to ensure that, however frequently the word ‘learning’
is used, the weight of the word ‘learn’ is always kept at least as
big, so that it always takes precedence when completing.
The following functions allow you to define and undefine such prefix
relationships (note that despite the command names and descriptions,
predictive-define-prefix and
predictive-undefine-prefix can be used to define relationships
between any two words, not just prefixes; however,
predictive-define-all-prefixes and the
predictive-auto-define-prefixes feature can only define actual
prefix relationships):
- predictive-define-prefix
- Define one word to be a prefix of another. Predictive mode will ensure
that the weight of the “prefix” word is always at least as large as
that of the other. (Note that the word does not actually have to be a
prefix of the other; this can be used to define a relationship between
any two words, so that the weight of one is always larger than the
other.)
- predictive-undefine-prefix
- Remove a “prefix” definition. (As for
predictive-define-prefix, the word does not actually have to
be a prefix of the other.)
- predictive-define-all-prefixes
- Add the given prefix to the prefix definitions of all words that for
which it is a prefix, or define all possible prefix relationships in the
dictionary if no explicit prefix is supplied. In the latter case, a
numerical prefix argument sets a minimum word length for which to define
a prefix relationship; relationships are only defined for words that are
at least this long (the prefixes defined for those words can
still be any length).
- predictive-undefine-all-prefixes
- The analogue of predictive-define-all-prefixes. Remove the
given prefix from the prefix definitions of all words, or remove all
prefix definitions in the dictionary if no explicit prefix is
supplied. In the latter case, a numerical prefix argument sets a minimum
word length for which to undefine prefix relationships (the
length of the prefixes that are undefined is still not restricted
in any way).
The following variable is used to help guess a likely prefix as a
default for predictive-define-prefix and
predictive-undefine-prefix. It's default value is only
appropriate for English.
- predictive-guess-prefix-suffixes
- List of suffixes to use when guessing a likely prefix for a word. The
suffixes a tried in the order they appear in the list, and the first one
that matches the end of the word is used: the guessed prefix is the
original word with the suffix removed.
Ensuring that prefixes take precedence when completing words is almost
always a good idea. It makes predictive completion much more convenient
(especially dynamic completion, see Dynamic Completion). Therefore,
predictive mode includes a feature that, when enabled (the default),
automatically defines all the prefix relationships whenever a word is
added to a dictionary.
- predictive-auto-define-prefixes
- When non-nil, predictive mode will automatically update all prefix
relationships for a word in a dictionary when the word is added. The
new word will always take precedence over any word that is an extension
of it, and in their turn any words that are prefixes of the new word
will take precedence over it.