Skip to content

Commit

Permalink
Add new "slim" output format that suppresses the concept graph, which…
Browse files Browse the repository at this point in the history
… can hurt browsers if too large.

Also fix the NaN supression code that did not handle None values well, and broke the tests
  • Loading branch information
edeutsch committed Nov 6, 2024
1 parent 8e80dd6 commit cfc270a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions code/ARAX/NodeSynonymizer/node_synonymizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,19 @@ def get_normalizer_results(self, entities: Optional[Union[str, Set[str], List[st
for dict_key in keys_to_delete:
del normalizer_info[dict_key]
# Otherwise add in cluster graphs
elif output_format == "slim":
pass
else:
for normalizer_info in results_dict.values():
if normalizer_info:
normalizer_info["knowledge_graph"] = self._get_cluster_graph(normalizer_info)

# Attempt to squash NaNs, which are not legal in JSON. Turn them into nulls
if 'knowledge_graph' in normalizer_info and 'edges' in normalizer_info["knowledge_graph"]:
if ( normalizer_info is not None and 'knowledge_graph' in normalizer_info and
normalizer_info["knowledge_graph"] is not None and 'edges' in normalizer_info["knowledge_graph"] and
isinstance(normalizer_info["knowledge_graph"]['edges'],dict) ):
for edge_name, edge_data in normalizer_info["knowledge_graph"]['edges'].items():
if 'attributes' in edge_data:
if 'attributes' in edge_data and isinstance(edge_data['attributes'], list):
for attribute in edge_data['attributes']:
try:
if 'value' in attribute and math.isnan(attribute['value']):
Expand Down

0 comments on commit cfc270a

Please sign in to comment.