Next: , Up: Dictionary Learning


5.5.1 Learning from Buffers and Files

Predictive mode can learn word weights from existing text. The following commands can be used to do this. Note that they will not add new words to a dictionary; they only update weights of words that are already in the dictionary. The learning commands take account of region-local dictionaries, and will ensure words are learnt in the correct dictionaries (see Region-Local Dictionaries).

Usually, you want to accumulate knowledge from each new piece of text. But sometimes, you may want to start from scratch, and reset the word weights to zero before starting to train a dictionary (for example, to erase the predefined weights from the supplied English dictionary, so that you can train it on your own writing style). You can use the predictive-reset-weight command for this purpose (see Creating Dictionaries).

Note that all the learning commands (even the “fast” ones!) can take a long time to run.

predictive-learn-from-buffer
Learns weights for words in a dictionary from text in a buffer. If no explicit dictionary is specified, this learns word weights for all dictionaries used by the current buffer (see Loading and Saving Dictionaries). Each occurrence of a word increments its weight in the dictionary. By default, only occurrences that occur in a region where the dictionary is active are counted (see Region-Local Dictionaries). If an explicit dictionary is specified, this can be overridden by supplying a prefix argument, in which case all occurrences are counted, irrespective of whether the dictionary is active at the word occurrence. Note that you cannot use this command to add words to a dictionary, only to train the weights of words already in a dictionary (see predictive-fast-learn-or-add-from-buffer, below).
predictive-learn-from-file
Like predictive-learn-from-buffer, but learns from a file instead of a buffer.
predictive-fast-learn-or-add-from-buffer
Similar to predictive-learn-from-buffer. It runs faster for large dictionaries, at the expense of missing some words. Specifically, only words consisting entirely of word- or symbol-constituent characters (according to the buffer's syntax table) will be taken into account. Also, unlike predictive-learn-from-buffer, this command takes into account the setting of the predictive-auto-add-to-dict option. If an explicit dictionary is specified, words that are not already in the dictionary will be added to it if predictive-auto-add-to-dict has any non-nil value. If no explicit dictionary is specified, predictive-auto-add-to-dict has the usual effect, as do the other auto-add-related options (see Automatic Learning).
predictive-fast-learn-or-add-from-file
Like predictive-fast-learn-or-add-from-buffer, but learns from a file instead of a buffer.