Euromasters site
Euromasters site

Tutorial III

Transducers

Exercise I: American and British English

There are a number of well-known differences in spelling between American and British English. Some more or less systematic differences are listed on Spelling differences between American and British English. To the extent that these differences a regular, one might design spelling rules which automatically transform American to British spelling.
  • Give a regular expression which obligatorily replaces ize by ise and yze to yse. Ensure that your trasnducers accepts all words (i.e. also words which do not contain ize).

    One approach is to write an expression which optionally applies first, and to compose this with a recognizer (i.e. an identity transducer) which filters ize  and yze atterns.

  • Give a regular expression which changes eling to elling. Why does this rule `overgenerate'?

Exercise II: Hyphenation

Assume a language with a simple syllable structure:
  • A nucleus always consists of exactly one vowel
  • An onset or coda can contain at most one consonant
  • If a consonant occurs between two vowels, it is the onset of the second syllable (and not the coda of the first syllable)
Examples
pasta    --> pas-ta
paella   --> pa-el-la
macaroni --> ma-ca-ro-ni
  1. Give a regular expression which inserts a hyphen after each syllable. One approach is to define a transducer which inserts hyphens optionally first, and to compose this transducer with a recognizer which filters illegal hyphenation patterns.
  2. Ensure that no hyphen is inserted after the last syllable. One approach is to add an end-of-word marker (say #) to each word and to specify a filter which refers to this marker.

Exercise III: Translating Number Expressions

The file Tutorial3/translation.pl contains macros for converting number expressions from 1 to 99 in English and Dutch into the corresponding number:
twentyone      --> 21
tweeendertig   --> 31
  • Write macros for translating number expressions from English to Dutch and vice versa.
  • Add macros for converting number expressions from a third language (of your choice) to numbers, and add the macros for translating between this language and English and Dutch.