@@ -33,7 +33,7 @@ def get_ontology_annotations(config, ontology_id, text):
3333
3434 response .raise_for_status ()
3535 response_data = response .json ()
36- print (f"Response from { ontology_id } ontology: { response_data } " )
36+ # print(f"Response from {ontology_id} ontology: {response_data}")
3737
3838 if 'matches' in response_data and isinstance (response_data ['matches' ], list ):
3939 text_with_spans = wrap_terms_in_span (text , response_data ['matches' ])
@@ -49,7 +49,7 @@ def get_ontology_annotations(config, ontology_id, text):
4949
5050def wrap_terms_in_span (text , matches ):
5151
52- cleaner_matches = [{'matched_term' : m ['matched_term' ], 'start' : m ['start' ], 'end' : m ['end' ], 'iri' : m ['iri' ]} for m in matches ]
52+ cleaner_matches = [{'term' : m [ 'token' ], ' matched_term' : m ['matched_term' ], 'start' : m ['start' ], 'end' : m ['end' ], 'iri' : m ['iri' ]} for m in matches ]
5353 sorted_matches = sorted (cleaner_matches , key = lambda m : (- len (m ['matched_term' ]), - m ['start' ]))
5454
5555 modified_positions = set ()
@@ -80,8 +80,8 @@ def wrap_terms_in_span(text, matches):
8080
8181 for match in modifications :
8282 result += text [last_end :match ['start' ]]
83- result += f"<a href={ match ['iri' ]} style='border-bottom: 1px dotted #666; text-decoration: none;'>{ match ['matched_term ' ]} </a> "
84- last_end = match ['end' ] + 1
83+ result += f"<a href={ match ['iri' ]} style='border-bottom: 1px dotted #666; text-decoration: none;'>{ match ['term ' ]} </a>"
84+ last_end = match ['end' ]
8585
8686 result += text [last_end :]
8787
0 commit comments