Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ToG/freebase_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def replace_entities_prefix(entities):


def id2entity_name_or_type(entity_id):
sparql = sparql_id % (entity_id, entity_id)
entity_id = sparql_id % (entity_id, entity_id)
sparql = SPARQLWrapper(SPARQLPATH)
sparql.setQuery(sparql)
sparql.setQuery(entity_id)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
if len(results["results"]["bindings"])==0:
Expand Down
2 changes: 1 addition & 1 deletion ToG/main_freebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
flag_printed = True
else:
print("depth %d still not find the answer." % depth)
topic_entity = {entity: id2entity_name_or_type[entity] for entity in entities_id}
topic_entity = {entity: id2entity_name_or_type(entity) for entity in entities_id}
continue
else:
half_stop(question, cluster_chain_of_entities, args)
Expand Down
2 changes: 1 addition & 1 deletion ToG/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def relation_search_prune(entity_id, entity_name, pre_relations, pre_head, quest


if len(pre_relations) != 0 and pre_head !=-1:
tail_relations = [rel for rel in tail_relations if not pre head or rel not in pre_relations]
tail_relations = [rel for rel in tail_relations if not pre_head or rel not in pre_relations]
head_relations = [rel for rel in head_relations if pre_head or rel not in pre_relations]

head_relations = list(set(head_relations))
Expand Down