AtlasOfLivingAustralia / ALA4R

Access data and resources hosted by the Atlas of Living Australia (ALA)
https://atlasoflivingaustralia.github.io/ALA4R/
42 stars 8 forks source link

search_names encoding #15

Closed johnbaums closed 8 years ago

johnbaums commented 8 years ago

Just noticed that encoding seems wrong in some cases for the result of search_names.

E.g. see the matched name of the following:

search_names('Simoselaps fasciolatus')

#                searchTerm                                    name                                            commonName    rank
#  1 Simoselaps fasciolatus Simoselaps fasciolatus (Günther, 1872) Narrow-banded Shovel-nosed Snake, Narrow-banded Snake species
#                                                                           guid
#  1 urn:lsid:biodiversity.org.au:afd.taxon:96c7acad-0e7d-436e-acb1-a069afd581db
raymondben commented 8 years ago

What platform are you on? Works for me on Linux/RStudio (but I might be running old versions of some packages):

search_names('Simoselaps fasciolatus')
              searchTerm                                   name                                            commonName    rank
1 Simoselaps fasciolatus Simoselaps fasciolatus (Günther, 1872) Narrow-banded Shovel-nosed Snake, Narrow-banded Snake species
                                                                         guid
1 urn:lsid:biodiversity.org.au:afd.taxon:96c7acad-0e7d-436e-acb1-a069afd581db

sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C               LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8     LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8   
 [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ALA4R_1.23

loaded via a namespace (and not attached):
 [1] Rcpp_0.11.5       lattice_0.20-33   digest_0.6.8      assertthat_0.1    bitops_1.0-6      grid_3.2.3        R6_2.0.1          plyr_1.8.2        jsonlite_0.9.16  
[10] magrittr_1.5      httr_1.0.0        stringi_0.5-5     rstudioapi_0.3.1  sp_1.0-17         tools_3.2.3       stringr_1.0.0     RCurl_1.95-4.5    rstudio_0.98.1103
raymondben commented 8 years ago

Aha, maybe it's a locale issue - under Windows I get:

search_names('Simoselaps fasciolatus')
              searchTerm                                    name
1 Simoselaps fasciolatus Simoselaps fasciolatus (Günther, 1872)
                                             commonName    rank
1 Narrow-banded Shovel-nosed Snake, Narrow-banded Snake species
                                                                         guid
1 urn:lsid:biodiversity.org.au:afd.taxon:96c7acad-0e7d-436e-acb1-a069afd581db
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    
raymondben commented 8 years ago

OK, fixed, I think - subtleties around encoding when parsing JSON. I've tested on Linux and Windows, but if you have time to test before I merge this into master that would be great:

devtools::install_github("AtlasOfLivingAustralia/ALA4R",ref="encoding")
search_names("Simoselaps fasciolatus")$name ## uses POST under the hood

[1] "Simoselaps fasciolatus (Günther, 1872)"

species_info("Simoselaps fasciolatus")$taxonConcept$author ## uses GET under the hood

[1] "(Günther, 1872)"
raymondben commented 8 years ago

Tested OK on both Linux and Windows, so assuming is OK (ALA4R v1.24)

johnbaums commented 8 years ago

Thanks @raymondben - works fine. Sorry for the slow reply. (And yes, I'm on Windows)