5.1 Creating Dictionaries
Predictive mode dictionaries store words along with their associated
weights, used to rank the words in order of likelihood. The weight is
just an integer value, which can be thought of as the relative frequency
of a word (relative to the other words in the dictionary). A dictionary
can also store prefix relationships between words, See Relationships Between Words.
The following commands are used to manually create and modify
- Create a new dictionary. The dictionary name is read from the
mini-buffer. You can optionally supply a filename to associate with the
dictionary. The dictionary will be saved to this file by default (just
as a buffer is saved to its associated file). You may also supply a file
containing a list of words with which to populate the new
dictionary. The predictive-completion-speed and
predictive-dict-autosave variables set the new dictionary's
completion speed and autosave flag (see below).
- Create a new meta-dictionary. A meta-dictionary is a wrapper around two
or more dictionaries that behaves as if it was a single, combined
dictionary. The weight of a word is the sum of it's weights in the
constituent dictionaries, and the prefix relationships from all
constituent dictionaries are merged (see Relationships Between Words). Apart from supplying a list of constituent dictionaries, the
other options are identical to those for
- Insert a word into a dictionary. The dictionary name and word are read
from the mini-buffer (defaults to the word at the point). An optional
prefix argument specifies the weight. If the word is not already in the
dictionary, it will be added to it with that initial weight (or 0 if
none is supplied). If the word is already in the dictionary, its weight
will be incremented by the weight value (or by 1 if none is supplied).
- Completely remove a word from a dictionary. The dictionary name and word
are read from the mini-buffer (defaults to the word at the point).
- Reset the weight of a word in a dictionary to 0. The dictionary name and
word are read from the mini-buffer. If no word is supplied, reset the
weights of all words in the dictionary. If a prefix argument is
supplied, reset weight(s) to that value, rather than 0.
- Display the number of words in a dictionary.
The file containing the list of words used to populate a dictionary has
to conform to a specific format:
"word" weight [prefix-list]
Each line contains one word word, delimited by ‘""’, followed
by an integer weight which specifies the word's weight, separated
by white-space from the word itself. Note that the `words' in a
dictionary do not have to be words in the usual sense. They can be
arbitrary sequences of characters, including white-space and punctuation
characters. The quote character ‘"’ can be included in a word by
escaping it: ‘\"’. Optionally, a list of words which are prefixes
of word can be specified in prefix-list at the end of the
line, again separated from the weight by white-space
(see Relationships Between Words). If present, it should be of the
(:prefixes ("prefix1" "prefix2" ...))
Note that trailing whitespace on any line is not allowed.
The following variables set defaults for other dictionary properties. To
change their values for a single dictionary, set the variable to the
desired value before creating the dictionary, resetting the value
- Sets the default completion speed of dictionaries created with
predictive-create-dict. This is the desired upper limit on the
time it takes to find completions. If it takes longer than this to find
a particular completion, the results are cached so that they can be
retrieved faster next time. Thus lower values result in faster
completion, at the expense of dictionaries taking up more memory.
Due to the efficient data structures used by the dictionaries, it is
typically safe to set this quite low (the default is 0.1 seconds). Most
completions will be found faster than this even on slow computers, and
only a few of the very slowest will need to be cached.
- Sets the default autosave property for dictionaries created with
predictive-create-dict. If non-nil, modified dictionaries will
automatically be saved when they are unloaded (either with the
predictive-dict-unload command, or when exiting emacs). If
nil, any unsaved modifications will be lost unless the dictionary is
saved manually. See Loading and Saving Dictionaries.