1.5 Text Autocorrection

Text autocorrection and autocompletion are not just about fixing obvious typos. This is a complex system for predicting intent, operating at the intersection of linguistics, statistics, and machine learning. Its task is not just to correct a word, but to predict and generate the most likely continuation of your thought.

Level 1: Statistical and Dictionary Model (Classic Autocorrection)

This is the foundation that works even on simple phones.

Levenshtein Distance

When you type "солнце" (sun) and the system sees "сонце," it calculates how many actions (add, delete, replace a character) are needed to turn one into the other. The distance between "солнце" and "сонце" is 1 (replacing "л" with "н"). The algorithm searches the dictionary for the word with the minimum distance and suggests it.

N-gram Models (Bigrams, Trigrams)

The system analyzes the frequency of word combinations in huge text corpora. If after the word "очень" (very) the word "хорошо" (good) most often follows in the language, then when typing "очень хор" it will suggest "хорошо." This is prediction based on a local context of 2-3 previous words.

Keyboard Geometry

The algorithm considers that you might have pressed a neighboring key. The error "пртвет" (instead of "привет" - hello) is easily corrected because "р" and "и" are next to each other on a QWERTY keyboard.

Level 2: Contextual Model Based on Machine Learning

Modern systems (Google Gboard, SwiftKey, iOS) use more sophisticated approaches.

Language Models (LM)

These are neural networks (often based on the transformer architecture, like in BERT or GPT, but much smaller), trained to predict a missing word in a sentence. They analyze not 2-3 previous words, but the entire context.

Example: Input: "Buy milk and [gap] at the store." A classical model, seeing "and," might suggest "bread." But a neural network, seeing "milk," might suggest "cookies" or "eggs" as a more likely combination in real shopping lists.

Real-time Personalization

The system learns your personal style:

  • Vocabulary: If you often use the word "нейросеть" (neural network), it stops being underlined as an error and is suggested in autocomplete.
  • Style: If you start letters with "Приветствую!" (Greetings!) instead of "Привет" (Hello), the system remembers that.
  • App Context: In a messenger you more often write "ок" (k), in email — "окей, понял" (okay, got it). The system adapts suggestions.

Level 3: Predictive Input and Generation (The Most Modern Stage)

Here, the system doesn't wait for a mistake but tries to guess entire phrases.

Smart Suggestions (Smart Compose in Gmail)

When you start typing "Добрый..." (Good...), the system in grey text might suggest "...день! Надеюсь, у вас всё хорошо." (...day! Hope you're doing well.). This works thanks to a huge language model trained on billions of emails, which understands patterns of business and personal correspondence.

Continuation Generation

In some keyboards (e.g., from OpenAI), after your sentence, several options for its continuation might be offered. This is already a generative model working on the GPT principle.

How is This Technically Implemented on Your Phone?

  1. Tokenization. Your input is split into tokens (words, parts of words, punctuation).
  2. Vectorization. Each token is converted into a vector (a set of numbers) that represents its meaning. Words with similar meanings have close vectors.
  3. Context Analysis. A neural network (often Recurrent - RNN or Transformer) processes the sequence of vectors, creating a "contextual representation" of everything written.
  4. Prediction. The network's output is a probability distribution over the entire vocabulary. For the position of the next word, the top 3 most likely candidates are calculated.
  5. Ranking and Output. Candidates are filtered by grammar rules, your history, and context, then offered to you.

Problems and Limitations:

1. Contextual Traps

The phrase "У меня нет ничего против синих [gap]" (I have nothing against blue [gap]). A model trained on news might suggest "ворот" (collars - meaning police), but in the context of laundry, "носков" (socks) is needed. The system lacks common sense and understanding of the real world.

2. Echo Chamber

Autocompletion can reinforce your speech patterns and clichés, making language more standardized and less unique.

3. The "Black Box" Problem

The user doesn't understand why the system suggests a particular word. This can lead to unexpected and sometimes awkward corrections (the well-known problem with "offensive" autocorrection).

4. Data Dependency

The quality of predictions directly depends on the texts the model was trained on. If they were biased in a certain direction, the bias will manifest in the suggestions too.

Evolution: From Correction to Co-Creation

Autocorrection is evolving from an error-fixing tool to an assisted writing tool. It is starting to understand not just words, but intentions:

  • If you start a list, it will suggest formatting.
  • If you write about a meeting, it will suggest inserting a date from the calendar.
  • If you use professional jargon, it will adapt to it.

This makes it a prototype of future personal AI communication assistants that will operate at the level of meaning, not symbols, helping to formulate thoughts faster and more accurately, while simultaneously raising questions about preserving the authenticity of the human voice in digital communication.

Previous: 1.4 Social Media Filters Next Section: 2.0 ChatGPT and Neural Networks