From 68d98dd99d87939881c73927ba5fd2490f4a3823 Mon Sep 17 00:00:00 2001 From: Santosh Mutyala Date: Wed, 4 Jun 2025 13:22:12 +0200 Subject: [PATCH] fix: wrap matched terms with links instead of replacing text; fix anchor whitespace bug; ci: update GitHub Pages to trigger on main branch instead of develop --- .github/workflows/deploy.yml | 4 ++-- hooks.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4706186..7aad087 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,10 +3,10 @@ name: Deploy MkDocs to GitHub Pages on: push: branches: - - develop-mkdocs # Trigger this workflow on push to the develop branch + - main pull_request: branches: - - develop-mkdocs # Also trigger on pull requests to the develop branch + - main jobs: deploy: diff --git a/hooks.py b/hooks.py index f250943..8f4cc89 100644 --- a/hooks.py +++ b/hooks.py @@ -33,7 +33,7 @@ def get_ontology_annotations(config, ontology_id, text): response.raise_for_status() response_data = response.json() - print(f"Response from {ontology_id} ontology: {response_data}") + # print(f"Response from {ontology_id} ontology: {response_data}") if 'matches' in response_data and isinstance(response_data['matches'], list): text_with_spans = wrap_terms_in_span(text, response_data['matches']) @@ -49,7 +49,7 @@ def get_ontology_annotations(config, ontology_id, text): def wrap_terms_in_span(text, matches): - cleaner_matches = [{'matched_term': m['matched_term'], 'start': m['start'], 'end': m['end'], 'iri': m['iri']} for m in matches] + cleaner_matches = [{'term': m['token'],'matched_term': m['matched_term'], 'start': m['start'], 'end': m['end'], 'iri': m['iri']} for m in matches] sorted_matches = sorted(cleaner_matches, key=lambda m: (-len(m['matched_term']), -m['start'])) modified_positions = set() @@ -80,8 +80,8 @@ def wrap_terms_in_span(text, matches): for match in modifications: result += text[last_end:match['start']] - result += f"{match['matched_term']} " - last_end = match['end'] + 1 + result += f"{match['term']}" + last_end = match['end'] result += text[last_end:]