(total_entities_id, total_relations, total_candidates, total_topic_entities, total_head, total_scores, args)
| 225 | |
| 226 | |
| 227 | def entity_prune(total_entities_id, total_relations, total_candidates, total_topic_entities, total_head, total_scores, args): |
| 228 | zipped = list(zip(total_entities_id, total_relations, total_candidates, total_topic_entities, total_head, total_scores)) |
| 229 | sorted_zipped = sorted(zipped, key=lambda x: x[5], reverse=True) |
| 230 | sorted_entities_id, sorted_relations, sorted_candidates, sorted_topic_entities, sorted_head, sorted_scores = [x[0] for x in sorted_zipped], [x[1] for x in sorted_zipped], [x[2] for x in sorted_zipped], [x[3] for x in sorted_zipped], [x[4] for x in sorted_zipped], [x[5] for x in sorted_zipped] |
| 231 | |
| 232 | entities_id, relations, candidates, topics, heads, scores = sorted_entities_id[:args.width], sorted_relations[:args.width], sorted_candidates[:args.width], sorted_topic_entities[:args.width], sorted_head[:args.width], sorted_scores[:args.width] |
| 233 | merged_list = list(zip(entities_id, relations, candidates, topics, heads, scores)) |
| 234 | filtered_list = [(id, rel, ent, top, hea, score) for id, rel, ent, top, hea, score in merged_list if score != 0] |
| 235 | if len(filtered_list) ==0: |
| 236 | return False, [], [], [], [] |
| 237 | entities_id, relations, candidates, tops, heads, scores = map(list, zip(*filtered_list)) |
| 238 | |
| 239 | tops = [id2entity_name_or_type(entity_id) for entity_id in tops] |
| 240 | cluster_chain_of_entities = [[(tops[i], relations[i], candidates[i]) for i in range(len(candidates))]] |
| 241 | return True, cluster_chain_of_entities, entities_id, relations, heads |
| 242 | |
| 243 | |
| 244 | def reasoning(question, cluster_chain_of_entities, args): |
nothing calls this directly
no test coverage detected