Skip to content

Commit

Permalink
adding ARAX condition for inferred
Browse files Browse the repository at this point in the history
  • Loading branch information
kvnthomas98 committed Aug 15, 2023
1 parent 88e0261 commit 94632e4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions code/ARAX/ARAXQuery/ARAX_expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def get_parameter_info_dict():
return parameter_info_dict

def apply(self, response, input_parameters, mode: str = "ARAX"):
force_local = False # Flip this to make your machine act as the KG2 'API' (do not commit! for local use only)
force_local = True # Flip this to make your machine act as the KG2 'API' (do not commit! for local use only)
message = response.envelope.message
# Initiate an empty knowledge graph if one doesn't already exist
if message.knowledge_graph is None:
Expand Down Expand Up @@ -441,9 +441,10 @@ def apply(self, response, input_parameters, mode: str = "ARAX"):
# Expand any specified edges
if qedge_keys_to_expand:
query_sub_graph = self._extract_query_subgraph(qedge_keys_to_expand, query_graph, log)
if inferred_qedge_keys and len(query_graph.edges) == 1:
for edge in query_sub_graph.edges.keys():
query_sub_graph.edges[edge].knowledge_type = 'lookup'
if mode != "RTXKG2":
if inferred_qedge_keys and len(query_graph.edges) == 1:
for edge in query_sub_graph.edges.keys():
query_sub_graph.edges[edge].knowledge_type = 'lookup'
if log.status != 'OK':
return response
log.debug(f"Query graph for this Expand() call is: {query_sub_graph.to_dict()}")
Expand Down Expand Up @@ -479,9 +480,10 @@ def apply(self, response, input_parameters, mode: str = "ARAX"):

# Create a query graph for this edge (that uses curies found in prior steps)
one_hop_qg = self._get_query_graph_for_edge(qedge_key, query_graph, overarching_kg, log)
if inferred_qedge_keys and len(query_graph.edges) == 1:
for edge in one_hop_qg.edges.keys():
one_hop_qg.edges[edge].knowledge_type = 'lookup'
if mode != "RTXKG2":
if inferred_qedge_keys and len(query_graph.edges) == 1:
for edge in one_hop_qg.edges.keys():
one_hop_qg.edges[edge].knowledge_type = 'lookup'
# Figure out the prune threshold (use what user provided or otherwise do something intelligent)
if parameters.get("prune_threshold"):
pre_prune_threshold = parameters["prune_threshold"]
Expand Down

0 comments on commit 94632e4

Please sign in to comment.