One of the most exciting things about learning foreign languages is the fact that some words cannot be translated literally. Simply because they have no direct counterpart in our own language. After all, how on earth would you ever translate the fourteen different words the Inuit use for snow? Or the Swedish word lagom, which means something like "not too much and not too little".

The Swedish language itself has no words that are equivalent to grandmother or grandfather. When naming their ancestors, Swedes indeed always indicate if they refer to the descent along the maternal or paternal lineage. Mother is translated in Swedish as mor and father as far. Your maternal grandmother becomes mormor (literally: your mother's mother) and your paternal grandmother becomes farmor (literally: your father's mother). Analogously, they translate the maternal grandfather as morfar and the paternal grandfather as farfar. If we would take over the same naming scheme in English, we would end up with something like mama, mafa, fama and fafa. That would sound really crazy, no?

morfar, farmor, mormor and farfar
Swedes make a distinction between grandmother and grandfather along maternal (mormor and morfar) and paternal (farfar and farmor) lineages.

Swedes extend this naming scheme to refer to their great-grandparents, great-great-grandparents and more distant ancestors. As such, morfarfar is your mother's father's father and farmorfarmor is your father's mother's father's mother.

The Swedish way to describe ancestors sometimes results in quite complex situations. Ancestors are indeed addressed in different ways by their offspring, even though they are of the same generation. If a grandmother has grandchildren of both her daughters and her sons, they will be shouting both farmor and mormor all day long. Meanwhile, grandfather will be confused whether his first response should go to morfar or farfar.

Assignment

We'll work with family trees that have been constructed according to a simplified model, which assumes the following conditions to be fulfilled:

The illustration below shows an example of such a family tree, where women are shown in pink and men in blue. Couples having children are connected by a thick horizontal line. The other relationships should be read from top to bottom, with mother and father on top and their children on the next line. The last condition we have imposed on the family trees means that there's no incest within the family (for example, we can find no children resulting from a relationship between a father and his daughter, nor from relationships between cousins).

family tree
Example of a family tree, where women are shown in pink and men in blue. Couples having children are connected by a thick horizontal line. The other relationships should be read from top to bottom, with mother and father on top and their children on the next line.

The relationships in a family tree are stored in a text file with UTF-81 character encoding, whose lines each contain three or more space-separated names. The first name is that of a mother, the second name that of a father and the remaining names are from their children. This way, the example file given below corresponds to the relationships as depicted in the illustration above.

Alana Ronan Beatrice August
Beatrice Clarence Ramiro Regan
Alexandra Ramiro Carlos Luciana Ciara
Regan Damari Alberto Natalee
Amira August Drake Eric Rosa Jadon
Rosa Jovanni Kole Sincere Emmy Gabriella Xzavier
Teresa Jadon Cadence Gavyn Aryana

Note that there is no imposed order in which the lines are listed in the text file. Your task:

Example

In the following interactive session, we assume the text file data.txt2 to be located in the current directory. This is the text file that corresponds to the family tree that is used as an example in the description of this assignment.

>>> relationships = family_members('data.txt3')
>>> relationships['Sincere']
{'father': 'Jovanni', 'mother': 'Rosa'}
>>> relationships['August']
{'father': 'Ronan', 'mother': 'Alana', 'children': {'Eric', 'Drake', 'Jadon', 'Rosa'}}
>>> relationships['Ronan']
{'children': {'Beatrice', 'August'}}

>>> ancestor('Drake', 'mor', relationships)
'Amira'
>>> ancestor('Rosa', 'farmor', relationships)
'Alana'
>>> ancestor('Sincere', 'morfarfar', relationships)
'Ronan'
>>> ancestor('Luciana', 'morfarmor', relationships)
Traceback (most recent call last):
AssertionError: unknown ancestor

>>> descendants('Ronan', 1, relationships)
{'far': {'Beatrice', 'August'}}
>>> descendants('Ronan', 2, relationships)
{'morfar': {'Regan', 'Ramiro'}, 'farfar': {'Rosa', 'Eric', 'Jadon', 'Drake'}}
>>> descendants('Ronan', 3, relationships)
{'farmorfar': {'Carlos', 'Luciana', 'Ciara'}, 'farfarfar': {'Gavyn', 'Cadence', 'Aryana'}, 'mormorfar': {'Alberto', 'Natalee'}, 'morfarfar': {'Kole', 'Emmy', 'Sincere', 'Xzavier', 'Gabriella'}}

Epilogue

The word mamihlapinatapai is derived from the Yaghan language4 of Terra del Fuego. It is listed in The Guineness Book of World Records as the "most succinct word", and is also considered one of the hardest words to translate. It allegedly refers to "a look shared by two people, each wishing that the other would initiate something that they both desire but which neither wants to begin". A slightly different interpretation of the meaning also exists: "It is that look across the table when two people are sharing an unspoken but private moment. When each knows the other understands and is in agreement with what is being expressed. An expressive and meaningful silence."

According to a 2004 survey of 1000 linguists, the most difficult word in the world to translate is ilunga. The word comes from Tshiluba5, an official language of the Democratic Republic of the Congo. It means "a person who is ready to forgive any abuse for the first time and to tolerate it a second time, but never a third time".

Some favorite words of Stockholm University linguist Mikael Parkvall, from his Limits of language: almost everything you didn't know about language and languages6 (2006):

  • klunen (Frisian): to walk or run overland with skates on (usually from one body of frozen water to another)

  • aɣone (Kuot): to drink from a bottle in such a fashion that drool trickles from the mouth back into the bottle

  • fringsen (German): to steal coal from railway wagons or potatoes from fields in order to survive

  • knedlikový (Czech): rather partial to dumplings

  • qamigartuk (Yup'ik): he goes seal-hunting with a small sled and kayak in the spring

  • baleŋga (Chavacano): excessive swinging of arms while walking

  • kallsup (Swedish): a gulp of water that a bather accidentally inhales

  • googly (English): (of an off-breaking cricket ball) disguised by the bowler with an apparent leg-break action

Gunwinggu7 — a language spoken in northwestern Australia — uses different verbs to describe the hopping of different species of wallaroo: