In Belgium a borough is the territory of a former municipality that was independent before the big municipal reorganizations in the 1960s-70s. A merged municipality (abbreviated municipality) therefore counts as many boroughs as there were once communities before the merger. A former municipality may call itself a borough if it was an independent municipality on January 1, 1961, the official start date of the great reorganization.
The name borough has no legal or governing consequences. However, on the basis of the area of the former municipalities it is possible to set up municipal departments. There a local administrative office can be established in a borough hall, often in the former town hall, which offers a limited service for administrative formalities (population, marital status), of which the documents will be sent to the central administration for processing.The police may have a department or commissioner's office on the same premises. Cultural activities (library, meeting rooms) can also be present.
Given is a file with all names of the boroughs from a specific region. Each line of the file contains the name of a borough, followed by a tab and the name of the (merger) municipality to which the borough now belongs. Asked:
Write a function readMunicipalities to which the name of a text file must be passed. This text file contains a listing of all the boroughs in a particular region. The function must return a dictionary, that shows the names of all the (merger) municipalities in that region on the collection of all the boroughs of which the (merger) municipality exists.
Write a function searchMunicipalities to which two arguments should be passed: the name of a borough and a dictionary that shows the names of the(merger) municipalities on a collection of all boroughs of which the municipality exists. The function must return a collection of the names of all the (merger) municipalities that have a borough with the specified name.
Write a function compounds to which a dictionary must be passed that shows the names of (merger) municipalities on a set of all the boroughs of which the (merger) municipality exists. The function must return a collection of the names of all the (merger) municipalities in the dictionary, of which the name of the municipality contains at least one hyphen (-), and if you split the name at the hyphens, all parts also form the name of a borough. Thus, the Flemish municipality of Knokke-Heist, for example, has two names: Knokke and Heist.
In the following interactive example session
we assume that the file vlaams_gewest.txt1 is in the
current directory.
>>> boroughs = readMunicipalities('vlaams_gewest.txt')
>>> boroughs['Anzegem']
{'Anzegem', 'Gijzelbrechtegem', 'Tiegem', 'Kaster', 'Vichte', 'Ingooigem'}
>>> boroughs['Oostende']
{'Stene', 'Zandvoorde', 'Oostende'}
>>> boroughs['Zonnebeke']
{'Zandvoorde', 'Zonnebeke', 'Geluveld', 'Passendale', 'Beselare'}
>>> searchMunicipalities('Tiegem', boroughs)
{'Anzegem'}
>>> searchMunicipalities('Vladslo', boroughs)
{'Diksmuide'}
>>> searchMunicipalities('Zandvoorde', boroughs)
{'Zonnebeke', 'Oostende'}
>>> searchMunicipalities('Heusden', boroughs)
{'Destelbergen', 'Heusden-Zolder'}
>>> searchMunicipalities('Berchem', boroughs)
{'Antwerpen', 'Kluisbergen'}
>>> searchMunicipalities('Meldert', boroughs)
{'Hoegaarden', 'Lummen', 'Aalst'}
>>> searchMunicipalities('Beveren', boroughs)
{'Beveren', 'Waregem', 'Roeselare', 'Alveringem'}
>>> compounds(boroughs)
{'Knokke-Heist', 'Langemark-Poelkapelle', 'Scherpenheuvel-Zichem', 'Hamont-Achel', 'Houthalen-Helchteren', 'Lo-Reninge', 'Erpe-Mere', 'Spiere-Helkijn', 'Meeuwen-Gruitrode', 'Dilsen-Stokkem', 'Heusden-Zolder', 'Hechtel-Eksel'}