

def _plenum_parsePara(txt, t, titles):
    if (titles is None):
        titles = []
        if (t == 'speaker'):
            titles.append({
                't': '',
                'c': [{
                    't': txt,
                    'c': [],
                    's': 1,
                }],
            })
        elif (t == 'title'):
            titles.append({
                't': txt,
                'c': [],
            })
        else:
            titles.append({
                't': '',
                'c': [{
                    't': txt,
                    's': 0,
                }],
            })
    elif (t == 'title'):
        titles.append({
            't': txt,
            'c': [],
        })
    else:
        title = titles[(len(titles) - 1)]
        children = title['c']
        if (t == 'speaker'):
            children.append({
                't': txt,
                'c': [],
                's': 1,
            })
        elif (len(children) == 0):
            children.append({
                't': txt,
                's': 0,
            })
        elif (children[(len(children) - 1)]['s'] == 1):
            children[(len(children) - 1)]['c'].append({
                't': txt,
            })
        else:
            children.append({
                't': txt,
                's': 0,
            })
    return titles

dataset/ETHPy150Open ofri/Open-Knesset/plenum/create_protocol_parts.py _plenum_parsePara/original