Class 23 — Friday March 27

It's a fact, look it up

Really need to know — What lies farther down the road — Need a future map


Look both ways


Agenda


Updated 3/22/2021


Examples


To do


Huh?


Babelfish — a translation dictionary in CSV format

a, a

aab, water

aamadam, came

aamadand, came

...

ziba, beautiful

zur, to

zu, to

zwei, two

 


Problem text translation using babelfish dictionary

Goal

Some possible interactions

Enter phrase to be translated: dónde está mi lápiz

where is my pencil

Enter phrase to be translated: est la baguette fraîche aujourd'hui

is the baguatte fresh today

Enter phrase to be translated: je %#@#&# ból svayam !!

I _%#@#&#_ hurt myself _!!_

Enter phrase to be translated: hvor er den skriget maleri af Munch

where is the scream painting by Münch

Enter phrase to be translated: hacer 뭔가 frais oggi

do something cool today

  • List of words making up the user text.
  • Dictionary loaded with the entries from the babelfish web file.
  • Translation accumulation.
  • For example, French word heureuse for happiness is not in the babelfish dictionary, so it would be translated as _heureuse_.
  • If a word is known to the babelish dictionary, its translation is added to the accumulation.
  • If instead a word is unknown, the word surrounded by underscores is added to the accumulation.

Spell correction — program spell_rite.py

  • If a correction is known, the correction is offered within asterisks.
  • If instead no correction is known, the word is flagged with underscores.

Enter text: I am as happy as I can be

I am as happy as I can be

Enter text: I am a Newyorker who is livin in virginia

I am a *New Yorker* who is _livin_ in *Virginia*

Enter text:

 


Here we go

  • We will get to that likely in another three classes or so.

You are already experienced with functions and modules (e.g,, wc.py)


Babelfish — Hitchhiker's Guide to the Galaxy

Everaldo Coelho (YellowIcon); / LGPL (http://www.gnu.org/licenses/lgpl.html)

Ziggurat of Ur

Hardnfast / CC BY (https://creativecommons.org/licenses/by/3.0)

 


  🦆 © 2022 Jim Cohoon   Resources from previous semesters are available.