MCPcopy Create free account
hub / github.com/DataArcTech/ToG / clean_relations_bm25_sent

Function clean_relations_bm25_sent

ToG/freebase_func.py:87–98  ·  view source on GitHub ↗
(topn_relations, topn_scores, entity_id, head_relations)

Source from the content-addressed store, hash-verified

85
86
87def 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
101def construct_relation_prune_prompt(question, entity_name, total_relations, args):

Callers 1

relation_search_pruneFunction · 0.70

Calls 1

if_all_zeroFunction · 0.70

Tested by

no test coverage detected