Beispiel #1
0
def _is_it_a_first_name(field, wp):
    """
    Find out if the field contains the name of a first name.
    Returns True or False
    """

    list_of_vornamen = _get_vornamenListe()
    field = _low_cap_all(field)

    for name in list_of_vornamen:
        if field == name:
            if field.upper() not in wp.offices:
                return True

    return False
Beispiel #2
0
def _is_it_a_city(field):
    """
    Find out if the field contains the name of a city in NRW. Since this
    field is usually given when two or more MdLs share the same family name,
    this is actually the city where they got elected (Wahlkreis) and is used
    to distinguish between MdLs. From Wahlperiode 14 this will be accomplished
    by their first names.
    Returns True or False
    """

    cities = _make_list_of_cities()
    is_it_a_city = _low_cap_all(field)

    if is_it_a_city in cities:
        return True
    return False
Beispiel #3
0
def _align_with_wiki(legislature, last_name, first_name, party, electoral_ward,\
        mdls_wiki, line):

    exceptions = {
        '10': {
            'MÜLLER': {
                'DÜREN': 'HELMUT',
                'MÜLHEIM': 'GERD',
                'MENDEN': 'HAGEN'
            },
            'HEINEMANN': {
                'DORTMUND': 'HERMANN',
                'ENGER': 'MANFRED',
                'ESSEN': 'PETER'
            },
            'SCHUMACHER': {
                'KALL': 'WERNER',
                'REMSCHEID': 'ROBERT'
            },
            'ALT-KÜPPERS': {
                'ew': 'HANS'
            }
        },
        '11': {
            'SCHUMACHER': {
                'KALL': 'WERNER'
            },
            'PAUS': {
                'BIELEFELD': 'MARIANNE',
                'DETMOLD': 'HEINZ'
            },
            'BOULBOULLE': {
                'ew': 'CARLA'
            },
            'MEYER-SCHIFFER': {
                'ew': 'GISELA'
            },
            'ALT-KÜPPERS': {
                'ew': 'HANS'
            }
        },
        '12': {
            'KRUSE': {
                'BOCHOLT': 'HEINRICH',
                'OLPE': 'THEODOR'
            },
            'SCHULTE': {
                'MENDEN': 'HUBERT',
                'LÜDENSCHEID': 'BERND'
            },
            'LEY': {
                'KÖLN': 'MARIE-THERES',
                'LEICHLINGEN': 'GISELA'
            },
            'WALSKEN VORMALS MEYER-SCHIFFER': {
                'ew': 'GISELA'
            }
        },
        '13': {
            'SCHULTE': {
                'MENDEN': 'HUBERT',
                'LÜDENSCHEID': 'BERND',
                'GELSENKIRCHEN': 'GERD'
            },
            'KRUSE': {
                'BOCHOLT': 'HEINRICH',
                'OLPE': 'THEODOR'
            },
            'WIRTZ': {
                'BOCHUM': 'HEINZ',
                'STOLBERG': 'AXEL'
            },
            'BISCHOFF': {
                'MONHEIM': 'WERNER',
                'DUISBURG': 'RAINER'
            },
            'LEY': {
                'KÖLN': 'MARIE-THERES',
                'LEICHLINGEN': 'GISELA'
            },
            'KRAFT': {
                'MÜLHEIM': 'HANNELORE',
                'RATINGEN': 'HANS'
            },
            'SCHMIDT': {
                'ew': 'ULRICH'
            }
        }
    }

    try:
        first_name = exceptions[legislature][last_name][electoral_ward]
        return first_name
    except KeyError:
        pass

    last_name = last_name.replace('Ä', 'A')
    last_name = last_name.replace('Ö', 'O')
    last_name = last_name.replace('Ü', 'U')
    last_name = last_name.replace('ß', 'SS')

    if last_name == 'ALT-KÜPPERS':
        last_name = 'ALT-KÜPERS'
    elif last_name == 'ROBELS':
        last_name = 'ROBELS-FRÖHLICH'
    elif last_name == 'SAURE':
        last_name = 'KNOTT'

    if party == 'F.D.P.':
        party = 'FDP'
    elif party == 'DIE GRÜNEN':
        party = 'GRÜNE'

    for mdl_wiki in mdls_wiki:
        if _low_cap_all(last_name) == mdl_wiki[0].split(',')[0]:
            if electoral_ward != 'ew' and len(mdl_wiki) == 3:
                if electoral_ward == mdl_wiki[1].upper():
                    first_name = mdl_wiki[0].split(',')[-1].upper().strip()
                    return first_name
            else:
                try:
                    if party.upper() == mdl_wiki[-1].upper():
                        first_name = mdl_wiki[0].split(',')[-1]
                        first_name = first_name.upper().strip()
                        return first_name
                except TypeError:
                    print('party', party)
                    print('mdl_wiki', mdl_wiki)
                    raise Exception
                except AttributeError:
                    print('last_name, first_name', last_name, first_name)
                    print(line)
                    print('party', party)
                    print('mdl_wiki', mdl_wiki)
                    raise Exception

    return first_name
Beispiel #4
0
def _find_MdL_in_lineup(mdl, sessions, wp):
    legislature = wp.wahlperiode
    sittings = list()
    session_merger = defaultdict()
    mdl_key = mdl.key
    last_name = _low_cap_all(mdl_key.split('_')[0])
    first_name = _low_cap_all(mdl_key.split('_')[1])

    if mdl_key.split('_')[2] != 'ew':
        ward = _low_cap_all(mdl_key.split('_')[2])
    else:
        ward = 'ew'
    mdl = (last_name, first_name, ward)
    counter = 1

    for session in sessions:
        if session not in sittings:
            sittings.append(session)
    #print(f'MdL {mdl_key} attended {len(sittings)} sessions')

    for key_tuple, session in wp.sessions.items():
        #print('key_tuple', key_tuple)
        #print('session', session)
        #print()
        session_nr = session.protocol_nr.split(' ')[-1]
        mdls = wp.sessions[key_tuple].speakers
        lineup = None
        if session_nr in sittings:
            if session_nr not in session_merger:
                session_merger[session_nr] = dict()
            for _, MdL in mdls.items():
                if int(legislature) < 14:
                    if MdL.ward and MdL.ward != 'ew':
                        if MdL.name == last_name:
                            start = key_tuple.start
                            end = key_tuple.end
                            if end:
                                start_end = start + ', ' + end
                            else:
                                start_end = start
                            session_merger[session_nr][start_end] = mdls
                    elif MdL.name == last_name:
                        start = key_tuple.start
                        end = key_tuple.end
                        if end:
                            start_end = start + ', ' + end
                        else:
                            start_end = start
                        session_merger[session_nr][start_end] = mdls
                elif int(legislature) >= 14:
                    name = first_name + ' ' + last_name
                    if MdL.name == name:
                        start = key_tuple.start
                        end = key_tuple.end
                        if end:
                            start_end = start + ', ' + end
                        else:
                            start_end = start
                        session_merger[session_nr][start_end] = mdls

    contris = dict()
    for session_nr, sessions in session_merger.items():
        for start_end, speakers in sessions.items():
            #_printout_lineup(session_nr, start_end, speakers)
            contri = _collect_mdl_contributions(contris, session_nr, mdl,\
                    start_end, speakers, legislature)

    return contris