Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

In 1899 brachten de Ladies of the Trinity Church (Claremont, New Hamshire, VSA) een kookboek uit. Daarin staat deze bijdrage van mevrouw L.M. Dow:

4 1/2 cups 1st Kings 4:22
1 1/2 cups Judges 5:25
2 cups Jeremiah 6:20
2 cups 1st Samuel 30:12
2 cups Nahum 3:12
1 cup Numbers 17:8
1/2 cup Judges 4:19
2 tablespoons of 1st Samuel 14:25
1 pinch of Leviticus 2:13
2 teaspoons of Amos 4:5
6 teaspoons Jeremiah 17:11

De eerste regel vraagt om 4 1/2 kopjes bloem. In de King James versie van de Bijbel lezen we in het boek getiteld The First Book of the Kings, hoofdstuk 4, vers 22:

And Solomon’s provision for one day was thirty measures of fine flour, and threescore measures of meal.

Het dertiende woord van dit vers is flour (bloem), waarbij woorden bestaan uit de langst mogelijke opeenvolging van letters (zodat Solomon's bestaat uit twee woorden: Solomon en s).

Op dezelfde manier verwijzen de overige regels van het recept respectievelijk naar de ingrediënten boter (butter), suiker (cane), rozijnen (raisins), vijgen (figs), amandelen (almonds), melk (milk), honing (honey), zout (salt), gist (leaven) en eieren (eggs). Er worden geen bakinstructies gegeven.

Opgave

De Bijbel is een bundeling van verschillende kortere boeken die los van elkaar en over verschillende periodes geschreven zijn, en pas later werden samengevoegd. Elk boek heeft een unieke titel.

Sinds het vroege begin van de dertiende eeuw werden al deze boeken verder onderverdeeld in hoofdstukken die elk ongeveer één pagina lang zijn. Sinds het midden van de zestiende eeuw wordt elk hoofdstuk verder onderverdeeld in verzen van een paar korte regels of zinnen lang. De hoofdstukken binnen een boek worden oplopend genummerd vanaf 1. De verzen worden binnen een hoofdstuk ook oplopend genummerd vanaf 1. De gebruikelijke manier om naar een bijbelvers te verwijzen is met de titel van het boek, het volgnummer van het hoofdstuk, een dubbelpunt en het volgnummer van het vers. Zo staat Genesis 3:5 bijvoorbeeld voor een fragment uit het boek Genesis, hoofdstuk 3, vers 5.

We werken met bijbelbestanden die een collectie verzen uit de Bijbel bevatten. Een bijbelbestand gebruikt het volgende formaat (bijbel.txt):

# The First Book of Moses: Called Genesis

1:1 In the beginning God created the heaven and the earth.

1:2 And the earth was without form, and void; and darkness was upon
the face of the deep. And the Spirit of God moved upon the face of the
waters.

1:3 And God said, Let there be light: and there was light.

# The First Book of Samuel

14:25 And all they of the land came to a wood; and there was honey
upon the ground.

30:12 And they gave him a piece of a cake of figs, and two clusters of
raisins: and when he had eaten, his spirit came again to him: for he
had eaten no bread, nor drunk any water, three days and three nights.

# The First Book of the Kings

4:22 And Solomon’s provision for one day was thirty measures of fine
flour, and threescore measures of meal,

Het bestand bestaat uit meerdere paragrafen die van elkaar gescheiden worden door één of meer lege regels. Een lege regel bevat enkel witruimtekarakters (spaties en tabs). Een paragraaf bestaat uit één of meer niet-lege regels. We maken onderscheid tussen twee soorten paragrafen:

Alle verzen die in een bijbelbestand volgen op de titel van een boek, behoren tot dat boek.

Gevraagd wordt:

Voorbeeld

In deze interactieve sessie gaan we ervan uit dat de huidige directory het tekstbestand bijbel.txt bevat.

>>> paragrafen = lees_paragrafen('bijbel.txt')
>>> paragrafen
['# The First Book of Moses: Called Genesis', '1:1 In the beginning God created the heaven and the earth.', '1:2 And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.', '1:3 And God said, Let there be light: and there was light.', '# The First Book of Samuel', '14:25 And all they of the land came to a wood; and there was honey upon the ground.', '30:12 And they gave him a piece of a cake of figs, and two clusters of raisins: and when he had eaten, his spirit came again to him: for he had eaten no bread, nor drunk any water, three days and three nights.', '# The First Book of the Kings', '4:22 And Solomon’s provision for one day was thirty measures of fine flour, and threescore measures of meal,']

>>> bijbel = lees_bijbel(paragrafen)
>>> bijbel
{'The First Book of Moses: Called Genesis': {'1:1': 'In the beginning God created the heaven and the earth.', '1:2': 'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.', '1:3': 'And God said, Let there be light: and there was light.'}, 'The First Book of Samuel': {'14:25': 'And all they of the land came to a wood; and there was honey upon the ground.', '30:12': 'And they gave him a piece of a cake of figs, and two clusters of raisins: and when he had eaten, his spirit came again to him: for he had eaten no bread, nor drunk any water, three days and three nights.'}, 'The First Book of the Kings': {'4:22': 'And Solomon’s provision for one day was thirty measures of fine flour, and threescore measures of meal,'}}

>>> vers(bijbel, 'The First Book of Moses: Called Genesis', 1, 1)
'In the beginning God created the heaven and the earth.'
>>> vers(bijbel, 'The First Book of the Kings', 4, 22)
'And Solomon’s provision for one day was thirty measures of fine flour, and threescore measures of meal,'
>>> vers(bijbel, 'The First Book of Samuel', 30, 12)
'And they gave him a piece of a cake of figs, and two clusters of raisins: and when he had eaten, his spirit came again to him: for he had eaten no bread, nor drunk any water, three days and three nights.'
>>> vers(bijbel, 'The First Book of Samuel', 14, 25)
'And all they of the land came to a wood; and there was honey upon the ground.'

>>> extraheer_woorden('In the beginning God created the heaven and the earth.')
['In', 'the', 'beginning', 'God', 'created', 'the', 'heaven', 'and', 'the', 'earth']
>>> extraheer_woorden('And Solomon’s provision for one day was thirty measures of fine flour, and threescore measures of meal,')
['And', 'Solomon', 's', 'provision', 'for', 'one', 'day', 'was', 'thirty', 'measures', 'of', 'fine', 'flour', 'and', 'threescore', 'measures', 'of', 'meal']
>>> extraheer_woorden('And they gave him a piece of a cake of figs, and two clusters of raisins: and when he had eaten, his spirit came again to him: for he had eaten no bread, nor drunk any water, three days and three nights.')
['And', 'they', 'gave', 'him', 'a', 'piece', 'of', 'a', 'cake', 'of', 'figs', 'and', 'two', 'clusters', 'of', 'raisins', 'and', 'when', 'he', 'had', 'eaten', 'his', 'spirit', 'came', 'again', 'to', 'him', 'for', 'he', 'had', 'eaten', 'no', 'bread', 'nor', 'drunk', 'any', 'water', 'three', 'days', 'and', 'three', 'nights']
>>> extraheer_woorden('And all they of the land came to a wood; and there was honey upon the ground.')
['And', 'all', 'they', 'of', 'the', 'land', 'came', 'to', 'a', 'wood', 'and', 'there', 'was', 'honey', 'upon', 'the', 'ground']

>>> woord(bijbel, 'The First Book of Moses: Called Genesis', 1, 1, 10)
'earth'
>>> woord(bijbel, 'The First Book of the Kings', 4, 22, 13)
'flour'
>>> woord(bijbel, 'The First Book of Samuel', 30, 12, 16)
'raisins'
>>> woord(bijbel, 'The First Book of Samuel', 14, 25, 14)
'honey'