Package spoonerism :: Module spoonerism
[hide private]
[frames] | no frames]

Module spoonerism

This module contains a class Word and a main function which can be used to create "word transformations" from pairs of Finnish words. A word transformation is obtained by merging two words according to a particular set of rules. The concept is similar to the English concept of a Spoonerism.

In a Finnish spoonerisms, each of the two words is transformed by exchanging its initial letters with the initial letters of the other word. There are further details to this process they are explained below. Let's use the traditional base word "kontti" in the examples that follow.

Easy basic case: "henri" and "kontinen". Take the first consonant and vowel "henri" (i.e., "he") and exchange them with those of the word "kontinen" (i.e., "ko"):

henri kontinen: konri hentinen
tarja halonen: harja talonen

If the word starts with several consonants, they are all moved into the other word. If there are no consonants, then only the vowel is moved:

frakki kontti: kokki frantti
ovi kello: kevi ollo

In the examples above, all the vowels were "short". If the same vowel letter appears twice in a row in a word, the vowel is considered "long". The length of a vowel will remain the same even when the letters change:

haamu kontti: koomu hantti

Elaboration of the example: The word "haamu" has a long vowel "aa". When the initial letters are replaced by "k" and "o", it becomes "koomu" (not "komu"). The base word "kontti" has a short vowel "o". When its initial letters are replaced by "h" and "a", it becomes "hantti" (not "haantti").

Even if there are two vowels in the first syllable, only the first one matters:

hauva kontti: kouva hantti
puoskari kontti: kooskari puntti

There are three kinds of vowels in Finnish: front vowels ('ä', 'y', 'ö'), back vowels ('a', 'u', 'o') and neutral ('e', 'i'). Due to a phenomenon called vowel harmony ("vokaalisointu"), the back vowels 'a', 'u' and 'o' cannot occur in the same word with the corresponding front vowels 'ä', 'y' and 'ö'. In a Finnish spoonerism, if one of the vowels 'a', 'u' or 'o' is placed at the beginning of a word, then all vowels 'ä', 'y' and 'ö' in the rest of the word must be replaced with corresponding back vowels. And vice versa. This is called assimilation. The vowels 'e' and 'i' are neutral, and are not assimilated by anything else or cause assimilation in other vowels.

Note that the vowel harmony rule is applied before concatenating the two parts of the spoonerism, as shown in the examples below. I.e., vowel harmony has no effect over the word border of a resulting spoonerism:

hylje etu: elje hyty
brutto nyrkki: nyttö brurkki

In reality, there are some exceptions to vowel harmony - e.g. loan words such as "vampyyri" and many composite words. However, this class assumes that vowel harmony always holds.

Below are a few further examples of word transformations:

hylje kala: kalje hylä
frakki stressi: strekki frassi
ovi korva: kovi orva
haapa hylky: hyypä halku
puoskari alusta: aoskari pulusta
puoskari hymy: hyöskäri pumu
Classes [hide private]
  Word
The class Word represents Finnish words that can be transformed according to the rules of a Finnish spoonerism.
Functions [hide private]
 
main()
This main method creates a spoonerism from the two Finnish words given as command line parameters, and prints out result on a single line.
Variables [hide private]
  __package__ = 'spoonerism'
Function Details [hide private]

main()

 

This main method creates a spoonerism from the two Finnish words given as command line parameters, and prints out result on a single line. For instance, given the parameter array ["haamu", "kontti"] produces "koomu hantti".

The program reads input from the command line parameters a.k.a. "program arguments". Two parameters from the user are expected, each of which should be a word in Finnish. Can be found from sys.argv.

When assigning the command line value to a variable, it needs encoding. This is because of the Finnish_phonetics class that uses unicode characters. Use the following assignment:

   word = unicode(sys.argv[1], 'utf-8')

   Likewise, before printing, the resulting words need to be encoded back, like::

   print new_word.encode('utf-8')

Goblin runs on a system that uses utf-8 encoding, so you may need to change that for testing, but remember to use utf-8 when submitting to Goblin.