liveBook · Manning

Spelling correction

As explained in Learn AI-Assisted Python Programming, Second Edition

A spelling suggestion is a proposed correctly spelled word corresponding to a misspelled input.

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

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Explains functional decomposition and candidate filtering, but defers detailed correction algorithms.
Examples
Uses sucessful, thourough, acceptible, and carf with an English word-list file.
What you can do after
Build it from scratch as a Python program that reads a word list and prints possible corrections.
How it connects
Connects spelling suggestions with spell checking, problem decomposition, top-down design, functions, and input-process-output.

Also explained in

Compare how 2 books explain spelling correction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.