Intro to rhymer

Noah Landesberg

2022-12-25

Welcome to rhymer, an R package for getting rhyming and other related words through the Datamuse API. I highly recommend reading through the Datamuse API website before getting started.

Main functions

rhymer has 4 main functions that allow you to get data on related words through the Datamuse API.

They are:

There is also a more flexible function get_other_related() that allows you to use the API to get data on other related words using a series of ‘codes’ described on the Datamuse API website.

Each function is default limited to return a maximum of 10 results, but can return more. Functions also default to return a dataframe with a row for each word, and an associated score. Different functions will return slightly different additional columns if returning a dataframe.

library(rhymer)

get_rhyme()

This function was the initial inspiration behind this package. It makes the work of finding rhyming words easy. In the background, it is referencing the CMU Pronouncing Dictionary. At it’s simplest, you can pass in a word and get_rhyme() will return a dataframe of rhyming words. For example:

get_rhyme("test")
##        word score numSyllables
## 1  manifest  2995            3
## 2      best  2743            1
## 3      rest  2366            1
## 4   request  2328            2
## 5   suggest  1987            2
## 6     quest  1818            1
## 7    attest  1754            2
## 8     crest  1732            1
## 9      nest  1661            1
## 10     lest  1632            1

The function has some additional arguments that you can use to specify the rhyme.

You can specify the number of syllables returned using num_syl:

get_rhyme("test", num_syl = 2)
##       word score numSyllables
## 4  request  2328            2
## 5  suggest  1987            2
## 7   attest  1754            2
## 11 contest  1596            2
## 15  behest  1456            2
## 16  arrest  1441            2
## 18 abreast  1302            2
## 19 protest  1243            2
## 21  invest  1216            2
## 22  divest  1194            2

You can specify the type of data returned using return_type:

# "df" returns a single dataframe (which is the default behavior).
get_rhyme("test", return_type = "df")
##        word score numSyllables
## 1  manifest  2995            3
## 2      best  2743            1
## 3      rest  2366            1
## 4   request  2328            2
## 5   suggest  1987            2
## 6     quest  1818            1
## 7    attest  1754            2
## 8     crest  1732            1
## 9      nest  1661            1
## 10     lest  1632            1
# "word" returns the type rhyme in the form of a single word vector.
get_rhyme("test", return_type = "word")
## [1] "manifest"
# "random_word" or "rand" returns a single, random word.
get_rhyme("test", return_type = "random_word")
## [1] "attest"
# "vector" returns a vector of words.
get_rhyme("test", return_type = "vector")
##  [1] "manifest" "best"     "rest"     "request"  "suggest"  "quest"   
##  [7] "attest"   "crest"    "nest"     "lest"

You can also specify the number of words returned (defaults to 10 so as to not kill the API) using limit:

get_rhyme("test", limit = 5)
##       word score numSyllables
## 1 manifest  2995            3
## 2     best  2743            1
## 3     rest  2366            1
## 4  request  2328            2
## 5  suggest  1987            2

get_means_like()

In the background, this function works by referencing WordNet and other online dictionaries. It has the same arguments as get_rhyme() for limiting the number of results (limit) and for what data structure to return (return_type). It also returns additional information about the part of speech returned.

get_means_like("test")
##            word    score                             tags
## 1       try out 30045872 syn, n, results_type:primary_rel
## 2       examine 30045525                           syn, v
## 3         trial 30044021                      syn, adj, v
## 4  experimental 30043762                           syn, n
## 5   examination 30043350                           syn, n
## 6         prove 30039620                           syn, n
## 7         assay 30039378                           syn, n
## 8           try 30036965                         syn, adj
## 9          quiz 30036178                           syn, n
## 10        essay 30023695                           syn, n

get_sounds_like()

In the background, this function works by referencing referencing the CMU Pronouncing Dictionary. It has the same arguments as get_rhyme() for limiting the number of results (limit), for what data structure to return (return_type), and for the number of syllables to limit to (num_syl).

get_sounds_like("test", num_syl = 2)
##      word score numSyllables
## 19 attest    90            2
## 20  testy    90            2
## 21 tester    90            2
## 22  tessa    90            2
## 25 testes    90            2
## 29  testa    90            2
## 33 tessie    90            2
## 34 testee    90            2
## 36  testi    90            2
## 38  testo    90            2

get_spelled_like()

This function has the same arguments as get_rhyme() for limiting the number of results (limit) and for what data structure to return (return_type).

get_spelled_like("test")
##   word score
## 1 test  7468