From 7ecae8b2dbfe611d39e8e5f5be08f79193d9807a Mon Sep 17 00:00:00 2001 From: Jason Payne Date: Wed, 9 Aug 2023 11:08:02 -0400 Subject: [PATCH] Fixes None bug Fixes a bug that prevents adding tags when the current tag variable is just None --- test/simple-test.py | 2 +- text2term/config.py | 2 +- text2term/t2t.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/simple-test.py b/test/simple-test.py index 44577d0..be7ddaa 100644 --- a/test/simple-test.py +++ b/test/simple-test.py @@ -12,7 +12,7 @@ def main(): # caches = text2term.cache_ontology_set("text2term/resources/ontologies.csv") # df = text2term.map_terms(["asthma", "disease location", "obsolete food allergy"], "EFO", min_score=.8, mapper=text2term.Mapper.JARO_WINKLER, excl_deprecated=True, use_cache=True, term_type="classes") # df = text2term.map_terms(["contains", "asthma"], "EFO", term_type="classes") - df = text2term.map_terms({"asthma":"disease", "allergy":["ignore", "response"], "assdhfbswif":["sent"], "isdjfnsdfwd":""}, "EFO", excl_deprecated=True, use_cache=True, incl_unmapped=True) + df = text2term.map_terms({"asthma":"disease", "allergy":["ignore", "response"], "assdhfbswif":["sent"], "isdjfnsdfwd":None}, "EFO", excl_deprecated=True, use_cache=True, incl_unmapped=True) # taggedterms = text2term.preprocess_tagged_terms("test/simple_preprocess.txt") # df = text2term.map_terms(taggedterms, "EFO", excl_deprecated=True, use_cache=True, incl_unmapped=True) print(df.to_string()) diff --git a/text2term/config.py b/text2term/config.py index 91c27a9..2e42105 100644 --- a/text2term/config.py +++ b/text2term/config.py @@ -1 +1 @@ -VERSION = "3.0.0" \ No newline at end of file +VERSION = "3.0.1" \ No newline at end of file diff --git a/text2term/t2t.py b/text2term/t2t.py index cb7b18c..66f1233 100644 --- a/text2term/t2t.py +++ b/text2term/t2t.py @@ -238,7 +238,9 @@ def _add_unmapped_terms(mappings_df, tags, source_terms, source_terms_ids): def _add_tag(tags, term, to_add, ignore=False): if isinstance(tags, dict): new_tags = tags.get(term, []) - if not any(tag in IGNORE_TAGS for tag in new_tags): + if new_tags is None: + new_tags = [] + if not (ignore and any(tag in IGNORE_TAGS for tag in new_tags)): if isinstance(new_tags, list): new_tags.append(to_add) elif new_tags != "":