Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/njtierney/syn
syn - the thesaurus
https://github.com/njtierney/syn
antonyms ozunconf18 r r-package rstats synonyms text-processing thesaurus unconf
Last synced: 11 days ago
JSON representation
syn - the thesaurus
- Host: GitHub
- URL: https://github.com/njtierney/syn
- Owner: njtierney
- Created: 2018-03-29T06:15:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-12T10:40:24.000Z (10 months ago)
- Last Synced: 2024-06-11T18:31:30.753Z (5 months ago)
- Topics: antonyms, ozunconf18, r, r-package, rstats, synonyms, text-processing, thesaurus, unconf
- Language: R
- Homepage: http://syn.njtierney.com/
- Size: 7.46 MB
- Stars: 51
- Watchers: 6
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - njtierney/syn - syn - the thesaurus (R)
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```# syn
[![R-CMD-check](https://github.com/njtierney/syn/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/njtierney/syn/actions/workflows/R-CMD-check.yaml)
[![Coverage status](https://codecov.io/gh/ropenscilabs/syn/branch/master/graph/badge.svg)](https://app.codecov.io/github/ropenscilabs/syn?branch=master)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/syn)](https://cran.r-project.org/package=syn)
[![CRAN Logs](http://cranlogs.r-pkg.org/badges/syn)](https://CRAN.R-project.org/package=syn)`syn` is a **zero dependency** R package that lists synonyms and antonyms.
There are two main functions:
- `syn("great")` Returns synonyms of "great"
- `ant("great")` Returns antonyms of "great".`syn` and `ant` take one word as input. To return synonyms for many words, use the plural form: `syn`**s**, and `ant`**s**
- `syns(c("great", "excellent")` Returns named list of synonyms of "great", and "excellent"
- `ants(c("great", "excellent")` Returns named list of antonyms of "great", and "excellent"## Example: Synonyms for "cool"
The `syn` function returns all synonyms for a given word:
Let's look at synonyms for "cool":
```{r example, message = FALSE, warnings = FALSE}
library(syn)syn_cool <- syn("cool")
head(syn_cool)
tail(syn_cool)
```Wow, there are a lot! How many are there?
```{r length-syn-cool}
length(syn_cool)
```Wow! There are `r length(syn_cool)` synonyms for cool. That's...`r syn("cool", 1)`, I guess.
You can also provide it a number of words to return with the `n_words` argument, which will randomly select the number of words given
```{r syn-awesome-one}
syn("awesome", 1)
syn("awesome", 2)
syn("awesome", 5)
```## Example: Creating a sentence
OK cool, let's use these in a sentence, using the `glue` package. Which of these better?
```{r example-syn-glue}
glue::glue("This is really cool!")
glue::glue("This is really {syn('cool', 1)}!")
glue::glue("This is really {syn('cool', 10)}!")
```## Using multiple words with `syns`
You can generate synonyms for multiple words with the `syns` function. This takes a vector of words, returning a named list
```{r example-syns}
syns_good_evil <- syns(c("good", "evil"))
str(syns_good_evil)
```You can also provide `n_words` for `syns`, and it will return a random selection of the words of that number.
```{r syns-n-words}
syns(c("good", "evil"),
n_words = 10)
```## Example: Antonyms (under development)
To create antonyms, use `ant` and `ants`, which have the same inputs as `syn`. However, at this stage, the number of antonyms available for use by `ant` is small.
```{r ant-n-words}
ant("good")
ant("good",1)ant("strong")
``````{r ants-n-words}
ants(c("good", "evil"))ants(c("good", "evil"), n_words = 5)
ants(c("strong", "weak"))
```## Example: Filtering by the number of words in a synonym
Let's say that you want to filter something down to those synonyms that only contain one word. You can use the `n_words` argument, which calculates the number of words for each
```{r one-word-only}
syn_end <- syn("end")n_words(syn_end)
syn_end_l1 <- syn_end[n_words(syn_end) <= 1]
syn_end_l1
```## Code of Conduct
Please note that the syn project is released with a [Contributor Code of Conduct](http://syn.njtierney.com/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.