You are on page 1of 11

Hidden 

Markov Models and Spelling 
Correction on the iPhone
Dr. Jeffrey L. Popyack
Department of Computer Science
How the iPhone Does Spelling 
Correction
iPhone User Interface
• The iPhone uses a touch‐screen 
user interface.  Users type by 
tapping a virtual keyboard.
• In order to be a useful device, 
humans need to be able to enter 
text quickly and accurately.
• Human Factors:  Humans make 
mistakes.  In general, the size of 
the iPhone’s virtual keyboard is 
too small for human fingers to 
enter text quickly and accurately.
iPhone User Interface
• Artificial Intelligence:  
– Can the iPhone’s computational 
power be used to do spelling 
correction while the user is typing?
– Can an algorithm be developed that 
can detect and correct errors?
– How many calculations can be made 
between individual key‐clicks?
– Can the necessary calculations be 
done faster than the user can type?
Hidden Markov Model
A Hidden Markov Model can describe a situation where 
events occur but cannot be accurately observed.  If the 
relationship between the observed info and the hidden info is

Hidden? Hidden? Hidden?

• Observed • Observed • Observed

known, the hidden info can be deduced with some likelihood 
of success.  This can be done to estimate hidden values or 
predict future hidden values.
Hidden Markov Model
In this case, the “hidden” info is what the 
user meant to type, and the “observed” info 
is what they did type.

T H E

• Observed:  • Observed:  • Observed: 


T G R

iPhone designers recognize that a certain percentage of the time, 
the user will tap a neighboring key instead of the desired key.  
Suppose they hit the correct key 60% of the time.
Hidden Markov Model
T G R
.6 .6 .6
R ‐ .1 T ‐ .08 E ‐ .1
Y ‐ .08
F ‐ .1 D ‐ .1
F ‐ .08
G ‐ .1 F ‐ .1 Possible Words:
H ‐ .08 TGR – Probability = .6 * .6 * .6 = .216
Y ‐ .1 T ‐ .1 TGE – Probability = .6 * .6 * .1 = .036
V ‐ .08 …
THE – Probability = .6 * .08 * .1 = .0048

The most likely word is the one with the 
RYE – Probability = .1 * .08 * .1 = .001 
highest probability that is in the dictionary.
What Did the User Mean?
• MPY

• WOWEE
What Did the User Mean?
• MPY
NOT
• WOWEE
What Did the User Mean?
• MPY
NOT
• WOWEE
SPADE
Notes
• We used the probability “.6” for the likelihood that the 
user typed the correct letter.  In reality, this is a value 
that would be determined through careful research.  It 
might vary for different letters.
• The iPhone interface suggests a word as a replacement 
for a given word that is typed, and will automatically 
replace the typed word with the suggested word unless 
the user cancels the action.  A different process would 
be appropriate if the suggested word is often wrong.
• Certain words in the dictionary may be used much 
more frequently than others ‐

You might also like