How To Train Your Keyboard

How your next word is predicted — and how you can make it more accurate.

How To Train Your Keyboard

How your next word is predicted — and how you can make it more accurate.

Have you ever cursed the autocorrect on your phone?

Tried typing someone’s name, maybe, and had it changed to a random, entirely unrelated word about eleven times in a row before it registered as the actual thing?

(Granted, brown people probably have this problem more than white people, given that “saree” keeps turning into “Sarah” and not the other way around, but I’m sure you’ve had your differences.)

Have you ever sent a message to someone, only to realise that it made no sense, or worse, meant something entirely different and possibly suggestive?

Then, it’s time to train your keyboard.

Before we begin messing with the keyboard, let’s look at how it actually works. The main job of the keyboard — apart from typing the letters you press — is to guess what you want to write. And to do that, it needs to know how writing works.

Writing is quite random. One word follows another, stopping here and there for commas and sentences, and ending up in a different order each time. Analyse the words all you want: you can’t predict how a good story will turn out. Otherwise, what would be the point in reading it?

That said, writing does have a pattern. If you’re given a series of words, you can make a good guess at what sort of word is going to come next. For example, take the first few words of 1984 by George Orwell.

It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, his chin nuzzled into his breast in an effort to escape the vile wind, slipped quickly through the glass …

You probably guessed what the next word is going to be. And you did that using your knowledge of what you’ve read earlier. That’s the knowledge your keyboard needs to have, too.

On the other hand, not all word-combinations make valid sentences. You can generate a list of words like this:

to a teeth put exported were farmers lizards quite many years pumps beast considered mention shores aboriginal called among consisted Australian market every tanks oil inland runs become equipment an rot helicopters lot future they observe cities every when just

…but that doesn’t make a proper sentence. You just know it, without analysing, though the reason why is complicated.

There are many ways the sentence is wrong. “Put”, for example, is usually followed by a noun like “lizards” and not a transitive verb like “exported”. (Unless “exported” was meant to be treated as an adjective, in which case the next word should be a noun or an extra adjective, not “were” which is a subjunctive verb).

If you’re a keyboard, you don’t have to remember all those rules. You can just scan through masses of text, and come up with a list of what comes after what. For instance, take this passage from the Snipette article Time Travel:

Light takes eight minutes to reach you from the Sun. So when you check where the Sun is, you’re only checking where it was, eight minutes ago. Light from Saturn takes over an hour to reach you. Light from the nearest star takes years.

This small passage gives us a few patterns. The word “eight” is always followed by “minutes”, for example. If someone writes “Light”, the next word could be “from” or “takes” — and “from” is, as far as we can see, twice as common as “takes”.

Looking at this text, you can draw up a table like this:

As you scan more passages of text, you’ll find more and more next-words combinations. Soon, each word will have too many “next-word” options to be useful. But then you can start predicting based on the previous two words, or three words, or howmanyever words you want:

Table similar to previous one, showing entries for “thank you” and “what you”

That makes predictions better. The word “you” can have almost anything coming after it, but the two-word combination “thank you” is usually followed by either “for” or “so”.

This kind of text-scanning is called “Markov analysis”. You go through the text to build your word-table, and then used that table to predict more words.

To make their suggestions, all keyboards had to do was look through lots and lots of text, to make a very big, detailed table. Then, they could look up that table to correct peoples’ typing.

But keyboards didn’t stop there. They went a step further.

Different people write differently. They have different writing styles. One person may say see, you, and later while for another person the word “you” is always followed by “soon”. They may use special, private words that aren’t there in the Markov dictionary.

That’s why keyboards don’t stop their analysis after being installed. They continue building their tables based on what you write.

This new, personal table is given higher priority than the original one. So the keyboard quickly learns your special words and phrases, and starts giving suggestions designed specially for you.

When I type “Write for” on my keyboard, the first suggestion that pops up is the word “Snipette”. The editor of the New York Times probably sees something quite different.

As you use your keyboard, it slowly gets to know you better. Which is great, but it also means you have to be careful, especially when you’ve just started using it. You don’t want to give it the wrong first-impression.

What I mean is, don’t ignore its initial mistakes. Don’t let it get away with “good” instead of “great” or “fine” instead of “well”. No matter how tiny the mistakes, go back and correct every single one of them.

Why do I say this? Because your keyboard is not just making the mistake once. It’s going to remember the mistake, record it in your private Markov table, and think you actually like to say “good”. This is even more important in the early days, when your table’s just starting to be built and your keyboard doesn’t yet know you very well. If you ignore it, you’ll end up typing like the keyboard, instead of making the keyboard type like you.

Over time, your keyboard’s suggestions will start to get better. It’ll make mistakes less often, and you won’t have to correct it as much as before.

So there you have it — how to train your keyboard. Just correct its mistakes as it corrects yours. It’s an ongoing process, but it only gets easier.

Until, of course, you decide to throw away your device and buy a new one…

Want to write with us? To diversify our content, we’re looking out for new authors to write at Snipette. That means you! Aspiring writers: we’ll help you shape your piece. Established writers: Click here to get started.