stevecondylios / dictionaRy

An R interface to the English Dictionary
Other
6 stars 0 forks source link

Definition of word not found, HTTP 404 #8

Open AshvinR12 opened 5 months ago

AshvinR12 commented 5 months ago

Hi, I have been running into this error for a number of words and wanted to know if this is something wrong with the way I'm implementing the code or whether the definition isn't in this package. Is there a way to see the number of words that have definitions in this package?

If it isn't would you be aware of how I can obtain these definitions?

library(dictionaRy)
#> Loading required package: jsonlite
#> Loading required package: tibble
define("talar")
#> Warning in open.connection(con, "rb"): cannot open URL
#> 'https://api.dictionaryapi.dev/api/v2/entries/en/talar': HTTP status was '404
#> Not Found'
#> Error in open.connection(con, "rb"): cannot open the connection to 'https://api.dictionaryapi.dev/api/v2/entries/en/talar'

Created on 2024-04-27 with reprex v2.1.0

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.2 (2023-10-31 ucrt) #> os Windows 11 x64 (build 22631) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_Australia.utf8 #> ctype English_Australia.utf8 #> tz Australia/Sydney #> date 2024-04-27 #> pandoc 3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.2) #> dictionaRy * 0.1.2 2024-04-27 [1] Github (stevecondylios/dictionaRy@7a37b1b) #> digest 0.6.34 2024-01-11 [1] CRAN (R 4.3.2) #> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.2) #> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.2) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.2) #> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.2) #> glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.2) #> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.2) #> jsonlite * 1.8.8 2023-12-04 [1] CRAN (R 4.3.2) #> knitr 1.45 2023-10-30 [1] CRAN (R 4.3.2) #> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.2) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.2) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.2) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.2) #> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.2) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.3) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.3) #> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.3.3) #> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.3.3) #> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.3.2) #> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.2) #> rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.2) #> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.2) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.2) #> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.3) #> tibble * 3.2.1 2023-03-20 [1] CRAN (R 4.3.2) #> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.2) #> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.2) #> withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.2) #> xfun 0.42 2024-02-08 [1] CRAN (R 4.3.2) #> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.2) #> #> [1] C:/Users/ashvi/AppData/Local/R/win-library/4.3 #> [2] C:/Program Files/R/R-4.3.2/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

Thank you for your consideration.

stevecondylios commented 5 months ago

Interesting. Sadly, it looks like the dictionary that dictionaRy uses doesn't have that word:

image

But the word can be seen in other dictionaries, e.g. thefreedictionary.com:

image

Since dictionaRy is based on https://dictionaryapi.dev, and it's an open source project, you should be able to get all the info on the internals here: https://github.com/meetDeveloper/freeDictionaryAPI

That should let you figure out the number of words/definitions (I haven't checked, but let me know how you go).

As for how to get the definitions of words not contained in the https://dictionaryapi.dev dictionary, thinking off the top of my head here, but you could try scraping https://www.thefreedictionary.com/talar that might be the easiest / most pragmatic way.

e.g. your code could do something like try dictionaRy, if that errors, try thefreedictionary.com.