Skip to content

Commit

Permalink
Fixes None bug
Browse files Browse the repository at this point in the history
Fixes a bug that prevents adding tags when the current tag variable is just None
  • Loading branch information
paynejason committed Aug 9, 2023
1 parent e7adade commit 7ecae8b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/simple-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion text2term/config.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "3.0.0"
VERSION = "3.0.1"
4 changes: 3 additions & 1 deletion text2term/t2t.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "":
Expand Down

0 comments on commit 7ecae8b

Please sign in to comment.