knitr::opts_chunk$set(echo = TRUE)
Retrieve the dictionary definition of English words in tidy format, along with their phonetics, audio pronunciation, parts of speech, origins, examples, synonyms, and antonyms.
Installation via GitHub devtools::install_github("stevecondylios/dictionaRy")
# install.packages("devtools") devtools::install_github("stevecondylios/dictionaRy")
Future: Installation via CRAN install.packages("dictionaRy")
install.packages("dictionaRy")
Load library
library(dictionaRy) library(tidyverse)
Get information for the word "hello":
word <- "hello" (word_info <- define(word))
word_info %>% select(part_of_speech, definition)
word_info %>% select(origin)
word_info %>% select(example)
View the word's phonetics as expressed in the International Phonetic Alphabet.
word_info %>% select(phonetic)
Visit the urls to hear the word spoken.
word_info %>% select(audio)
each combination of meaning and part of speech will have one or more definitions.
Example: the word bark has 4 meanings. Take the first meaning:
a dog's bark. This meaning has 2 parts of speech (noun and verb).
The noun has 1 definition the sharp explosive cry of a dog, fox, or seal
.
The verb has 2 definitions (of a dog, fox, or seal) give a bark
and
utter (a command or question) abruptly or aggressively
. So we have a total
of 3 definitions just for the first of four meanings of 'bark' (and more for
the second, third, and fourth).
If a word cannot be found in the English dictionary a 0-row tibble will be
returned, and message to that effect printed to the console (e.g.
define("sdlkfjsldkjf")
).
"hello"
define("hello")
"bark"
define("bark")
"set" (..is said to have more meanings than any other English word!)
define("set")
"lead" is an example of a heteronym (a word that has a different pronunciation and meaning from another word but the same spelling)
define("lead") %>% group_by(meaning_number) %>% slice(1)
Visit the audio links for the first and second meanings of "lead":
Iterate over many words
words <- c("hello", "bark", "set", "lead") purrr::map_df(words, ~ define(.x))
Note that words which aren't found in the English dictionary will return 0 row tibbles, and hence will have no affect on the resulting tibble
words <- c("paint", "sldkfjlsdjkf") purrr::map_df(words, ~ define(.x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.