ropensci / rotl

Interface to Open Tree of Life API
https://docs.ropensci.org/rotl
Other
39 stars 18 forks source link

do_approximate_matching= TRUE not working on tnrs_match_names using multiple inputs #134

Closed LunaSare closed 3 years ago

LunaSare commented 3 years ago

Hi @fmichonneau!

I am getting different results when running the tnrs_match_names with a single vector input and a multiple element vector input.

When running it with a single taxa, it works as expected

> rotl::tnrs_match_names(names = "amphibians", do_approximate_matching = TRUE)

  search_string unique_name approximate_match ott_id is_synonym
1    amphibians    Amphibia              TRUE 544595      FALSE
  flags number_matches
1                    6

But when running it with a character vector of multiple taxa, it seems to ignore approximate matching:

> rotl::tnrs_match_names(names = c("amphibians", "canis"), do_approximate_matching = TRUE)

  search_string unique_name approximate_match ott_id is_synonym
1    amphibians        <NA>                NA     NA         NA
2         canis       Canis             FALSE 372706      FALSE
  flags number_matches
1  <NA>             NA
2                    2

Warning message:
amphibians are not matched 
fmichonneau commented 3 years ago

Hi @LunaSare!

It looks like it's a bug that comes from OpenTree of life rather than from rotl. If I call the API directly with your example, I get the same results:

$   curl -X POST https://api.opentreeoflife.org/v3/tnrs/match_names \
-H "content-type:application/json" -d \
'{"names":["Amphibians","Canis"], "do_approximate_matching":true}'
Output ```json { "context": "Mammals", "governing_code": "ICZN", "includes_approximate_matches": true, "includes_deprecated_taxa": false, "includes_suppressed_names": false, "matched_names": [ "Canis" ], "results": [ { "matches": [], "name": "Amphibians" }, { "matches": [ { "is_approximate_match": false, "is_synonym": false, "matched_name": "Canis", "nomenclature_code": "ICZN", "score": 1.0, "search_string": "canis", "taxon": { "flags": [], "is_suppressed": false, "is_suppressed_from_synth": false, "name": "Canis", "ott_id": 372706, "rank": "genus", "source": "ott3.3draft1", "synonyms": [ "Aenocyon", "Alopedon", "Alopsis", "Canix", "Chaon", "Dasycyon", "Dieba", "Dimenia", "Jacalius", "Lupulella", "Lupulus", "Lupus", "Lyciscus", "Mamcanisus", "Neocyon", "Oreocyon", "Oxygonus", "Oxygous", "Sacalius", "Schaeffia", "Simenia", "Thos", "Vulpicanis" ], "tax_sources": [ "ncbi:9611", "gbif:5219142", "irmng:1282727" ], "unique_name": "Canis" } }, { "is_approximate_match": false, "is_synonym": true, "matched_name": "Canis", "nomenclature_code": "ICZN", "score": 1.0, "search_string": "canis", "taxon": { "flags": [], "is_suppressed": false, "is_suppressed_from_synth": false, "name": "Atelocynus", "ott_id": 621180, "rank": "genus", "source": "ott3.3draft1", "synonyms": [ "Canis" ], "tax_sources": [ "ncbi:68721", "gbif:2434453", "irmng:1025378" ], "unique_name": "Atelocynus" } } ], "name": "Canis" } ], "taxonomy": { "author": "open tree of life project", "name": "ott", "source": "ott3.3draft1", "version": "3.3", "weburl": "https://tree.opentreeoflife.org/about/taxonomy-version/ott3.3" }, "unambiguous_names": [ "Canis" ], "unmatched_names": [ "Amphibians" ] } ```

Maybe try to report the issue in their tracker: https://github.com/OpenTreeOfLife/feedback

Thanks!

LunaSare commented 3 years ago

Thanks so much for looking into this @fmichonneau!

I reported it to Open Tree here https://github.com/OpenTreeOfLife/feedback/issues/528