A spelling suggestion is a correctly spelled word proposed for a potentially misspelled input. A useful program separates the task into input, processing, and output instead of placing everything in one function. section 7.4
A spelling-suggestion program divides its work into:
- Input: ask for a word and use a collection of correctly spelled words. section 7.4
- Process: try possible changes and retain results that are real words. section 7.4
- Output: show the resulting suggestions, typically one per line. section 7.7.8
A simple correction
Given the misspelled input “sucessful,” the program can suggest “successful.” Inputs such as “thourough,” “acceptible,” and “carf” demonstrate single or multiple possible results. section 7.7.8
Table 7.1 A summary of the input, process data, and output tasks
|
Phase
|
Role
|
Spelling Suggestions Example
|
|---|---|---|
|
Input
|
Take, as input, the information needed for the function.
|
Provide the misspelled word
sucessful and a collection of real words (properly spelled words).
|
|
Process data
|
Perform the operation specified by the function on that data.
|
Consider changes to that word that might result in a correctly spelled word, for example, adding a letter
c either before or after the
c in
sucessful would produce the real word
successful. Many other incorrect words (i.e.,
scucessful obtained by adding the letter
c before the
u) may also be attempted, but only real words should be in the result.
|
|
Output
|
Return the result of that data processing.
|
Return the suggestion “successful”.
|
The input-process-output table maps each programming phase to the spelling-suggestion task and its expected result. section 7.4

