Double Dutch — also known as Tutnese or King Tut Language — is a secret language primarily used in English spoken countries, although the rules can be easily modified to apply to almost any language.
In Double Dutch vowels are pronounced normally, but each consonant is replaced with a syllable that starts with the consonant. The following table contains some examples of syllables that can be used as a replacement for consonants:
letter | possible syllables |
---|---|
b | bub |
c | cash, coch |
d | dud |
f | fuf, fud |
g | gug |
h | hash, hutch |
j | jay, jug |
letter | possible syllables |
---|---|
k | kuck, kuk |
l | lul |
m | mum |
n | nun |
p | pub, pup |
q | quack, queue |
r | rug, rur |
letter | possible syllables |
---|---|
s | sus |
t | tut |
v | vuv |
w | wack, wash |
x | xux |
y | yub, yuck |
z | zub, zug |
Instead of individually translating two successive repetitions of the same consonant, only the first consonant is translated and its translation is preceded by the syllable squa to indicate doubling. For two successive repetitions of the same vowel, the prefix becomes squat instead and an extra suffix h is appended. For example, the double vowel oo would be spoken as squat-oh in Double Dutch.
If the letter (or the first letter of two successive repetitions of the same letter) that must be translated is a lowercase letter, the translation of the letter(s) is all lowercase. If the letter (or the first letter of two successive repetitions of the same letter) that must be translated is an uppercase letter, the translation of the letter(s) starts with an uppercase letter followed by lowercase letters.
Sentences are translated into Double Dutch word by word, with words defined as the longest possible succession of letters. All characters in the sentence that are not letters remain unchanged in the translation.
In this assignment we consider the vowels to be the letters a, e, i, o and u. All other letters are considered to be consonants. The Double Dutch translation of all consonants into their corresponding syllables is defined in a text file whose lines start with a consonant, a space, a dash (-), a space and the syllable that replaces the consonant in the translation. As such, each consonant is translated by a single syllable. Your solution may assume that none of the words has more than two successive repetitions of the same letter. Your task:
Write a function consonants that takes the location of a text file containing the Double Dutch translation of all consonants into their corresponding syllable. The function must return a dictionary that maps each consonant into its corresponding syllable as defined in the given text file. In case the given text file does not contain a valid translation of all consonants into syllables, the function must raise an AssertionError with the message invalid translation. This is the case if
a line contains a letter that is not a consonant
a line contains a syllable that does not start with the consonant on the same line
not all consonants of the alphabet appear in the text file
some consonants appear more than once in the text file
Write a function translateWord that takes two arguments: i) a word that only contains letters and ii) a dictionary that maps all consonants of the alphabet onto a syllable that starts with the consonant. The function must return the Double Dutch translation of the given word, based on the mapping from consonants to syllables as defined in the given dictionary.
In the following interactive session we assume the text file dutchLetters.txt1 to be located in the current directory.
>>> dutchLetter = consonants('dutchLetters.txt')
>>> dutchLetter['s']
'sus'
>>> dutchLetter['q']
'quack'
>>> dutchLetter['d']
'dud'
>>> dutchLetter['e']
Traceback (most recent call last):
KeyError: 'e'
>>> dutchLetter
>>> translateWord('took', dutchLetter)
'tutsquatohkuck'
>>> translateWord('BAMBOO', dutchLetter)
'BubAMumBubSquatoh'
>>> translateWord('Yesterday', dutchLetter)
'Yubesustuterugdudayub'
>>> translate('I took a walk to the park yesterday.', dutchLetter)
'I tutsquatohkuck a wackalulkuck tuto tuthashe pubarugkuck yubesustuterugdudayub.'
The secret language Double Dutch appears to have been invented and used by black slaves in the American south, to teach spelling and conceal what they said, at a time when literacy among slaves was forbidden.
Maya Angelou2 mentions learning Tutnese as a child in the first volume of her autobiography I Know Why the Caged Birds Sing3. She and her friend Louise
spent tedious hours teaching ourselves the Tut language. You (yack oh you) know (kack nug oh wug) what (wack hash a tut). Since all the other children spoke Pig Latin, we were superior because Tut was hard to speak and even harder to understand.
Today, Double Dutch is usually used by children who use it to converse in privacy from adults, by members of historically marginalized minority groups for the same reason when in presence of authority figures such as police (pupolulisus or pizolizice), or simply for amusement and humor.