@@ -33,7 +33,7 @@ def get_ontology_annotations(config, ontology_id, text):
33
33
34
34
response .raise_for_status ()
35
35
response_data = response .json ()
36
- print (f"Response from { ontology_id } ontology: { response_data } " )
36
+ # print(f"Response from {ontology_id} ontology: {response_data}")
37
37
38
38
if 'matches' in response_data and isinstance (response_data ['matches' ], list ):
39
39
text_with_spans = wrap_terms_in_span (text , response_data ['matches' ])
@@ -49,7 +49,7 @@ def get_ontology_annotations(config, ontology_id, text):
49
49
50
50
def wrap_terms_in_span (text , matches ):
51
51
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 ]
53
53
sorted_matches = sorted (cleaner_matches , key = lambda m : (- len (m ['matched_term' ]), - m ['start' ]))
54
54
55
55
modified_positions = set ()
@@ -80,8 +80,8 @@ def wrap_terms_in_span(text, matches):
80
80
81
81
for match in modifications :
82
82
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' ]
85
85
86
86
result += text [last_end :]
87
87
0 commit comments