Skip to content
PlayOwl
Computers & communication · #339

How does a translation app change languages?

A translation app does not just swap words. It looks at the whole sentence to find the meaning, then says it in the other language.

The big idea: Translating word by word goes wrong, because languages order words differently and one word can have several meanings. The app uses the words around each word, the context, to choose well.

Start exploring
0 of 5 parts done
Two children in a park with a phone between them that turns one row of words into another, joined by crossing lines, How Things Work poster
1Watch it

How an app changes languages

  1. Lily speaks English and Mateo speaks Spanish. Lily says something to her phone, and a translation app says it again in Spanish. How can a phone change one language into another?
  2. The simplest idea is a dictionary: swap each English word for a Spanish one. The becomes el, red becomes rojo, ball becomes pelota. But 'el rojo pelota' is not how anyone says it in Spanish.
  3. Languages put words in different orders. In Spanish the color usually comes after the thing, and words change to match each other: la pelota roja. A good translation rebuilds the whole sentence, not one word at a time.
  4. Many words have more than one meaning. 'Bat' can be a flying animal or a stick for hitting a ball, and Spanish uses two different words. The app looks at the words nearby. 'Flies' and 'night' point to the animal.
  5. Nobody typed in all the rules. Instead, the app's computer program studied millions of sentences that people had already translated, and found the patterns: which words and which orders usually go together.
  6. The app speaks the Spanish sentence and Mateo understands. Translation apps are a great help, but they still make mistakes with jokes, sayings and rare words. For anything important, people check with someone who knows both languages.
2Look inside

Look closely at a translation app

The app is translating 'The bat flies at night'. Tap each part to see what it does.

  • What you say. Lily speaks or types a sentence. If she speaks, speech recognition first turns her voice into written words.
  • Language pair. The app needs to know which language to read and which to write. Here it goes from English to Spanish.
  • Word pieces. The app splits the sentence into words and pieces of words, so that it can work with each piece and with how the pieces fit together.
  • Context. To choose the meaning of 'bat', the app looks at the words around it. 'Flies' and 'night' are clues that it is the animal.
  • What it learned. The app learned from millions of sentences translated by people. From them it worked out which words, meanings and orders usually go together.
  • The translation. The app writes the sentence in Spanish, choosing each word to fit the meaning and putting the words in Spanish order.
  • Speaker. A computer voice reads the Spanish sentence out loud, so Mateo can hear it.
3Try it

Translation lab

Choose a sentence. Translate it word by word, then as a whole sentence. Watch the lines between the words and the picture in Mateo's bubble.

Experiment: What happens when the app translates one word at a time, without looking at the rest of the sentence?

  1. Choose 'the red ball' and translate it word by word. Look at the order of the Spanish words.
  2. Switch to Whole sentence. Which lines cross?
  3. Now try 'The bat flies at night' both ways. What does Mateo imagine?

What we found: Word by word, the app picks the first meaning in its dictionary and keeps the English order. With the whole sentence, it can choose the right meaning and put the words in Spanish order.

Turn on JavaScript to try it yourself.

4Solve a challenge

Context detective

In each sentence, tap the word that tells the app which kind of bat it is. Solve all three with no wrong taps for 3 stars.

5Go deeper

Why translating is more than swapping words

A translation app has a hard job. It must take a sentence in one language and say the same thing in another. The first idea most people have is to swap the words one by one, like using a dictionary. That works for 'cat' and 'gato', but it falls apart fast.

One problem is order. English says 'the red ball', but Spanish says 'la pelota roja': the color comes after the thing, and the words change their endings to match each other. Another problem is that one word can have several meanings. A 'bat' can be an animal or a piece of sports equipment, and Spanish has a different word for each. Only the rest of the sentence tells you which one is meant.

So a good app looks at the whole sentence. The words around a word are called its context, and they work like clues. In 'the bat flies at night', the clues 'flies' and 'night' point to the animal. The app learned how to use such clues by studying millions of sentences that people had already translated, finding patterns in which words go together.

Translation apps are wonderful for travel, for making friends and for reading things from other countries. But they are not perfect. Sayings such as 'it's raining cats and dogs', jokes, names and rare words can still come out wrong, and the app cannot tell when it has made a mistake. That is where our comparison breaks down: a bilingual friend understands you, while the app only predicts likely words. For important things, people still ask a human translator.

Key words

Translation
Saying the same thing in a different language.
Context
The words around a word. They give clues about what the word means here.
Ambiguous word
A word with more than one meaning, such as bat.
Word order
The order in which a language places its words. Spanish says 'ball red' where English says 'red ball'.
Idiom
A saying whose meaning is not the meaning of its words, such as 'raining cats and dogs'.
Training data
The examples a computer program learns from. Here, millions of sentences translated by people.
Attention
The part of a translation network that weighs how much each word should affect the meaning of another.

Check your thinking

  1. How does the app choose the right meaning of a word such as 'bat'?

    Show the answer

    It uses the words around it as clues. The words nearby, the context, show which meaning fits. 'Flies' and 'night' go with the animal.

  2. Which of these is a translation app most likely to get wrong?

    Show the answer

    A joke or a saying, such as 'it's raining cats and dogs'. A saying does not mean what its words say, so the app can only get it right if it has learned that saying.

  3. Why is 'el rojo pelota' a bad translation of 'the red ball'?

    Show the answer

    Spanish puts the color after the thing, and the words must match each other. Each word was swapped correctly, but Spanish uses a different order and matching endings: la pelota roja.

  4. How did the app learn to translate?

    Show the answer

    By studying millions of sentences that people had already translated. It found patterns in a huge number of examples made by human translators.

  5. An app translates between two languages for which very little translated text exists. What should you expect?

    Show the answer

    Lower quality, because the network had few examples to learn from. What the network knows comes from its training data. With few sentence pairs, it has seen fewer words, senses and constructions.