liveBook · Manning

Letter deletion

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

Letter deletion is the operation of generating strings by removing one letter from an existing string.

Letter deletion generates candidate strings by removing one letter from an existing string. It helps identify spelling mistakes caused by an extra letter, such as changing “thourough” to “thorough.” section 7.3

Use the technique as one subtask in a spelling-suggestion process:

  • Pass the misspelled string to a deletion function. section 7.5.2
  • Loop through its letters, removing one letter at each position. section 7.5.2
  • Return the resulting strings as possible candidates for comparison with real words. section 7.3

Deleting one letter

For the input “cu,” deleting one letter produces “u” and “c.” For “thourough,” deleting the first “u” produces “thorough,” a correctly spelled word. section 7.3 section 7.5.2

Table 7.2 Examples of the add_letter, delete_letter, and change_letter function
Input String
Strings Returned by add_letter
Strings Returned by delete_letter
Strings Returned by change_letter
cu
acu, bcu, ccu, …, zcu cau, cbu, ccu, …, czu cua, cub, cuc, …, cuz
u, c
au, bu, du, …, zu, ca, cb, cc, …, cz
cad
acad, bcad, ccad, …, zcad caad, cbad, ccad, …, czad caad, cabd, cacd, …, cazd cada, cadb, cadc, …, cadz
ad, cd, ca
aad, bad, dad, …, za cbd, ccd, cdd, …, czd caa, cab, cac, …, caz

Compare deletion with adding and changing letters through representative function outputs. section 7.5.2

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

How deep it goes
Defines deletion and assigns it a loop-based function, stopping short of handling transposed or multiple errors.
Examples
Uses “thourough” becoming “thorough” and tabulated outputs for inputs such as “cu” and “cad.”
What you can do after
Apply it via a delete_letter function to generate every string formed by removing one letter.
How it connects
Connects letter deletion with spelling suggestions, string processing, functions, loops, and top-down design.

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.