Next: , Previous: Through the C API, Up: Writing programs to use Aspell

6.2 Through A Pipe

When given the pipe or -a command, Aspell goes into a pipe mode that is compatible with ispell -a. Aspell also defines its own set of extensions to Ispell pipe mode.

6.2.1 Format of the Data Stream

In this mode, Aspell prints a one-line version identification message, and then begins reading lines of input. For each input line, a single line is written to the standard output for each word checked for spelling on the line. If the word was found in the main dictionary, or your personal dictionary, then the line contains only a `*'.

If the word is not in the dictionary, but there are suggestions, then the line contains an `&', a space, the misspelled word, a space, the number of near misses, the number of characters between the beginning of the line and the beginning of the misspelled word, a colon, another space, and a list of the suggestions separated by commas and spaces.

If you set the option run-together and Aspell thinks this word is a combination of two words in the dictionary, then it prints a single `-' in one line.

Finally, if the word does not appear in the dictionary, and there are no suggestions, then the line contains a `#', a space, the misspelled word, a space, and the character offset from the beginning of the line. Each sentence of text input is terminated with an additional blank line, indicating that Aspell has completed processing the input line.

These output lines can be summarized as follows:

     OK: *
     Suggestions: & original count offset: miss, miss, ...
     None: # original offset

When in the -a mode, Aspell will also accept lines of single words prefixed with any of `*', `&', `@', `+', `-', `~', `#', `!', `%', or `^'. A line starting with `*' tells Aspell to insert the word into the user's dictionary. A line starting with `&' tells Aspell to insert an all-lowercase version of the word into the user's dictionary. A line starting with `@' causes Aspell to accept this word in the future. A line starting with `+', followed immediately by a valid mode will cause Aspell to parse future input according the syntax of that formatter. A line consisting solely of a `+' will place Aspell in TeX/LaTeX mode (similar to the -t option) and `-' returns Aspell to its default mode (which is Nroff unless otherwise specified). (but these commands are obsolete). A line `~', is ignored for Ispell compatibility. A line prefixed with `#' will cause the personal dictionaries to be saved. A line prefixed with `!' will turn on terse mode (see below), and a line prefixed with `%' will return Aspell to normal (non-terse) mode. Any input following the prefix characters `+', `-', `#', `!', `~', or `%' is ignored, as is any input following. To allow spell-checking of lines beginning with these characters, a line starting with `^' has that character removed before it is passed to the spell-checking code. It is recommended that programmatic interfaces prefix every data line with an uparrow to protect themselves against future changes in Aspell.

To summarize these:

*word Add a word to the personal dictionary
&word Insert the all-lowercase version of the word in the personal dictionary
@word Accept the word, but leave it out of the dictionary
# Save the current personal dictionary
~ Ignored for Ispell compatibility.
+ Enter TeX mode.
+mode Enter the mode specified by mode.
- Enter the default mode.
! Enter terse mode
% Exit terse mode
^ Spell-check the rest of the line

In terse mode, Aspell will not print lines beginning with `*', which indicate correct words. This significantly improves running speed when the driving program is going to ignore correct words anyway.

In addition to the above commands which are designed for Ispell compatibility Aspell also supports its own extensions. All Aspell extensions follow the following format.

     $$command [data]

Where data may or may not be required depending on the particular command. Aspell currently supports the following commands:

cs option,value Change a configuration option.
cr option Prints the value of a configuration option.
pp Returns a list of all words in the current personal wordlist.
ps Returns a list of all words in the current session dictionary.
l Returns the current language name.
ra mis,cor Add the word pair to the replacement dictionary for later use. Returns nothing.

Anything returned is returned on its own line. All lists returned have the following format

     num of items: item1, item2, etc

(Part of the preceding section was directly copied out of the Ispell manual)