Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping Key Error when all word results below the min_score #61

Closed
KennyWu opened this issue Jul 19, 2024 · 1 comment
Closed

Mapping Key Error when all word results below the min_score #61

KennyWu opened this issue Jul 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@KennyWu
Copy link

KennyWu commented Jul 19, 2024

I noticed an issue when experimenting with the map_terms() functions. When I attempt to map a single term, and the results do not have any words that are above the min score, I get a key error message. Here is my input:

dfl = text2term.map_terms(source_terms=["dengue virus infection"], max_mappings=3, min_score = 0.9,
                          `target_ontology="ncit")

And my error output:

KeyError Traceback (most recent call last)
/tmp/ipykernel_706701/365619315.py in
----> 1 dfl = text2term.map_terms(source_terms=["dengue virus infection"], max_mappings=3, min_score = 0.9,
2 target_ontology="ncit")
3 dfl

~/.local/lib/python3.10/site-packages/text2term/t2t.py in map_terms(source_terms, target_ontology, base_iris, csv_columns, excl_deprecated, max_mappings, min_score, mapper, output_file, save_graphs, save_mappings, source_terms_ids, separator, use_cache, term_type, incl_unmapped)
103 mappings_df = _do_mapping(source_terms, source_terms_ids, target_terms, mapper, max_mappings, min_score, tags,
104 incl_unmapped)
--> 105 mappings_df["Mapping Score"] = mappings_df["Mapping Score"].astype(float).round(decimals=3)
106 if save_mappings:
107 _save_mappings(mappings_df, output_file, min_score, mapper, target_ontology, base_iris,

~/.local/lib/python3.10/site-packages/pandas/core/frame.py in getitem(self, key)
4100 if self.columns.nlevels > 1:
4101 return self._getitem_multilevel(key)
-> 4102 indexer = self.columns.get_loc(key)
4103 if is_integer(indexer):
4104 indexer = [indexer]

~/.local/lib/python3.10/site-packages/pandas/core/indexes/range.py in get_loc(self, key)
415 raise KeyError(key) from err
416 if isinstance(key, Hashable):
--> 417 raise KeyError(key)
418 self._check_indexing_error(key)
419 raise KeyError(key)

KeyError: 'Mapping Score'

@rsgoncalves rsgoncalves added the bug Something isn't working label Jul 20, 2024
@rsgoncalves
Copy link
Contributor

Thanks for reporting this bug. It will be fixed in upcoming release.

rsgoncalves added a commit that referenced this issue Jul 21, 2024
Add BioPortal API key parameter + Minor fixes (closes #61)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants