| 23 | |
| 24 | |
| 25 | def et_text2role(schema, et_list, text): |
| 26 | et_rt_dict = schema.type_role_dict |
| 27 | source_list = [] |
| 28 | target_list = [] |
| 29 | # 遍历event |
| 30 | for event_type in et_list: |
| 31 | for role_type in et_rt_dict[event_type]: |
| 32 | source_text = event_type + " </s> " + role_type + " </s> " + text |
| 33 | target_text = "" |
| 34 | |
| 35 | source_list.append(source_text) |
| 36 | target_list.append(target_text) |
| 37 | |
| 38 | # 在所有的target 上统一加上起始位置 |
| 39 | for i in range(len(target_list)): |
| 40 | target_list[i] = f'{type_start} ' + target_list[i] + f' {type_end}' |
| 41 | |
| 42 | return source_list, target_list |
| 43 | |
| 44 | def et_text2tri(et_list, text): |
| 45 | source_list = [] |