(topn_relations, topn_scores, entity_id, head_relations)
| 85 | |
| 86 | |
| 87 | def clean_relations_bm25_sent(topn_relations, topn_scores, entity_id, head_relations): |
| 88 | relations = [] |
| 89 | if if_all_zero(topn_scores): |
| 90 | topn_scores = [float(1/len(topn_scores))] * len(topn_scores) |
| 91 | i=0 |
| 92 | for relation in topn_relations: |
| 93 | if relation in head_relations: |
| 94 | relations.append({"entity": entity_id, "relation": relation, "score": topn_scores[i], "head": True}) |
| 95 | else: |
| 96 | relations.append({"entity": entity_id, "relation": relation, "score": topn_scores[i], "head": False}) |
| 97 | i+=1 |
| 98 | return True, relations |
| 99 | |
| 100 | |
| 101 | def construct_relation_prune_prompt(question, entity_name, total_relations, args): |
no test coverage detected