From dc504960f28d6555de6ab2d0208fab6d6630af0b Mon Sep 17 00:00:00 2001 From: Rafael Goncalves Date: Tue, 2 Jan 2024 15:40:41 -0500 Subject: [PATCH 1/4] Fix imports in onto_cache --- text2term/onto_cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/text2term/onto_cache.py b/text2term/onto_cache.py index 614f912..204dcb0 100644 --- a/text2term/onto_cache.py +++ b/text2term/onto_cache.py @@ -3,8 +3,8 @@ import text2term import owlready2 import pandas as pd -from .term import OntologyTermType -from .mapper import Mapper +from text2term.term import OntologyTermType +from text2term.mapper import Mapper from shutil import rmtree CACHE_FOLDER = "cache" From 32485122ff1de55d0fec22151b5d5ea531854ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Gon=C3=A7alves?= Date: Wed, 7 Feb 2024 13:40:35 -0500 Subject: [PATCH 2/4] Update python-app.yml --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index f81e0c2..2e42b70 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -26,7 +26,7 @@ jobs: - name: show python path run: | python -c "import sys; print('\n'.join(sys.path))" - PYTHONPATH + echo $PYTHONPATH - name: Install dependencies run: | python -m pip install --upgrade pip From 07f22981b40dbc636dfb9a35152e4671570f6c54 Mon Sep 17 00:00:00 2001 From: Rafael Goncalves Date: Tue, 13 Feb 2024 18:25:32 -0500 Subject: [PATCH 3/4] Fix typo in variable name, likely due to refactoring --- text2term/term_collector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text2term/term_collector.py b/text2term/term_collector.py index 3d9671a..109d349 100644 --- a/text2term/term_collector.py +++ b/text2term/term_collector.py @@ -48,7 +48,7 @@ def get_ontology_terms(self, base_iris=(), exclude_deprecated=False, term_type=O return ontology_terms def filter_terms(self, onto_terms, iris=(), excl_deprecated=False, term_type=OntologyTermType.ANY): - return filter_terms(onto_terms, iris, exclude_deprecated, term_type) + return filter_terms(onto_terms, iris, excl_deprecated, term_type) def _get_ontology_signature(self, ontology): signature = list(ontology.classes()) From d8c7132ea8dcff14c2ab5f4a2ef7952592e0bce6 Mon Sep 17 00:00:00 2001 From: Jason Payne Date: Thu, 29 Feb 2024 10:24:44 -0500 Subject: [PATCH 4/4] Optimized filter mappings Changed the t2t._filter_mappings function to use vectorization instead of loops, thus making it faster. --- .github/workflows/python-app.yml | 1 - text2term/t2t.py | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 2e42b70..96f008a 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -26,7 +26,6 @@ jobs: - name: show python path run: | python -c "import sys; print('\n'.join(sys.path))" - echo $PYTHONPATH - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/text2term/t2t.py b/text2term/t2t.py index fa247fc..ca89c34 100644 --- a/text2term/t2t.py +++ b/text2term/t2t.py @@ -265,13 +265,11 @@ def _add_tags_to_df(df, tags): def _filter_mappings(mappings_df, min_score): - new_df = pd.DataFrame(columns=mappings_df.columns) - for index, row in mappings_df.iterrows(): - if row['Mapping Score'] >= min_score: - new_df.loc[len(new_df.index)] = row + if mappings_df.empty: + return mappings_df + new_df = mappings_df.loc[mappings_df["Mapping Score"] >= min_score] return new_df - def _add_unmapped_terms(mappings_df, tags, source_terms, source_terms_ids): if mappings_df.size == 0: mapped = []