-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
81 lines (60 loc) · 3.08 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
suppressMessages(library(rhymer))
```
# rhymer
[![Build Status](https://travis-ci.org/landesbergn/rhymer.svg?branch=master)](https://travis-ci.org/landesbergn/rhymer)
[![Coverage Status](https://img.shields.io/codecov/c/github/landesbergn/rhymer/master.svg)](https://codecov.io/github/landesbergn/rhymer?branch=master)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/rhymer)](https://cran.r-project.org/package=rhymer)
[![](https://cranlogs.r-pkg.org/badges/grand-total/rhymer)](https://cran.rstudio.com/web/packages/rhymer/index.html)
### Overview
The goal of `rhymer` is to get rhyming and other related words through the [Datamuse API](https://www.datamuse.com/api/). This package includes basic functions to get rhymes and other similar words based on meaning, spelling, or sound.
## Installation
```{r gh-installation, eval = FALSE}
install.packages("rhymer")
# Or the the development version from GitHub:
# install.packages("devtools")
devtools::install_github("landesbergn/rhymer")
```
## Example
They say nothing rhymes with _orange_...
```{r example1}
get_rhyme("orange", return_type = "word")
```
Feeling down? How about this cloud of words with similar meaning to _happy_:
```{r example2}
word_data <- get_means_like("happy", return_type = "df")
wordcloud::wordcloud(words = word_data$word,
freq = word_data$score,
colors = c("lightsteelblue1","lightsteelblue2","lightsteelblue3","lightsteelblue"))
```
Eminem wrote the classic rap song ['Lose Yourself'](https://genius.com/Eminem-lose-yourself-lyrics), but could it be better with `rhymer`?
```{r}
glue::glue("
His palms are sweaty
Knees weak arms are {get_rhyme('sweaty', return_type = 'word', num_syl = 2)}
There's vomit on his sweater already
Mom's {get_rhyme('already', return_type = 'word', num_syl = 3)}
")
```
## Main functions
`rhymer` has 4 main functions that allow you to get data on related words through the Datamuse API.
They are:
- `get_rhyme()` - a function to get rhyming words
- `get_means_like()` - a function to get words with similar meaning
- `get_sounds_like()` - a function to get words that sound similar
- `get_spelled_like()` - a function to get words that are spelled similarly
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](https://www.datamuse.com/api/).
Each function takes the basic arguments of:
- `word` the word to base results on
- `return_type` what type of data return (options are _df_ for a data frame, _vector_ for a vector, _word_ for a single word, and _random\_word_ for a random word)
- `limit` max number of related words to return
`get_rhyme()` and `get_sounds_like()` also have special helpers for the number of syllables to return called `num_syl`.