ProgrammingWithZoe

Autocorrect

Last Updated:

For example, imagine you are given the following brief:

You are to produce a system that automatically corrects spelling and typing errors

This brief is both vague and has a broad scope; two common and disastrous traits of briefs you will be given over your career. The brief could describe anything from a simple program that corrects errors in a text file to the complex autocorrection systems found on most phones. At the core of these possible end products is a shared problem; given a word from some text, can the program correct any errors in that word. This core problem is much easier to tackle than having to think about the rest of a potential system at the same time. Of course, the other information is vital to be able to present the finished product to your client or the user, but it does not make solving the core problem any simpler.

Breaking down problems

Once you have extracted the core problems from a brief, the next step is to explore if the problem can be broken down further. Being able to break down a problem into smaller and smaller chunks allows us to think about each of them in isolation.

Using the previous example of a text correction system, we can take the extracted problem and break it down further.

Given a word from some text, can the program correct any errors in that word

There are many avenues of thoughts for what you might consider correct, you might wish to find the closest match based on letters in the word or you might want to find the word that requires the least amount of "correction". Additionally you might want to take into account the distance between keys on a keyboard to determine if something was a typo or miss-spelling.

To provide more scope to the problem definition, we can assume that your program has access to a dictionary of "correct" words to use for corrections. This dictionary could come from anywhere, and when focusing on your problem, it is ok to assume that some resources you need will be provided by external processes. There will be instances where you will need a resouce that is highly complex (we will be using one shortly)

For the computer to be able to replace the incorrect word with a correct one the computer must first identify what word it should replace the mistake with. Assume that you have also been given a list of all "correct" words from a dictionary or such. From that list, how could a computer find the right one to use to replace the incorrect word?

To do this, we must compare the word to all known "good" words (for now we will assume you have this list already) a