def financial_extract_result_process()

in utils/compute_score.py [0:0]


def financial_extract_result_process(sub_df):
    '''处理模型输出的结果'''
    contents_adj = []
    for i in range(sub_df.shape[0]):
        content = sub_df.iloc[i].predict.lstrip().rstrip()
        content = content.replace(':', ':').replace(',', ',').replace(' ', '').replace(';', ';').replace('。',
                                                                                                         '.').replace(
            ',\n', '\n')
        result = {}
        if 'value' in content:
            find_list = re.findall('(key\d):(.*)\s*(value\d?):?\s*(.*)', content)
            bad_res = False
            for find_res in find_list:
                if len(find_res) != 4:
                    bad_res = True
                    break
                result[strip(find_res[1])] = strip(find_res[3])
            if bad_res:
                result = {}
        else:
            find_list = re.findall('(.*):(.*)', content)
            for find_res in find_list:
                if len(find_res) != 2:
                    break
                if 'key' in find_res[0]:
                    break
                result[strip(find_res[0])] = strip(find_res[1])
        contents_adj.append(result)
    return contents_adj