(entity, relation, wiki_client, head)
| 101 | |
| 102 | |
| 103 | def entity_search(entity, relation, wiki_client, head): |
| 104 | rid = wiki_client.query_all("label2pid", relation) |
| 105 | if not rid or rid == "Not Found!": |
| 106 | return [], [] |
| 107 | |
| 108 | rid_str = rid.pop() |
| 109 | |
| 110 | entities = wiki_client.query_all("get_tail_entities_given_head_and_relation", entity, rid_str) |
| 111 | |
| 112 | if head: |
| 113 | entities_set = entities['tail'] |
| 114 | else: |
| 115 | entities_set = entities['head'] |
| 116 | |
| 117 | if not entities_set: |
| 118 | values = wiki_client.query_all("get_tail_values_given_head_and_relation", entity, rid_str) |
| 119 | return [], list(values) |
| 120 | |
| 121 | id_list = [item['qid'] for item in entities_set] |
| 122 | name_list = [item['label'] if item['label'] != "N/A" else "Unname_Entity" for item in entities_set] |
| 123 | |
| 124 | return id_list, name_list |
| 125 | |
| 126 | |
| 127 | def entity_score(question, entity_candidates_id, entity_candidates, score, relation, args): |
no test coverage detected