Learn R Programming

qdap (version 1.3.5)

synonyms: Search For Synonyms

Description

synonyms - Search for synonyms that match term(s). synonyms_frame - Generate a synonym lookup environment for use with the synonym.frame argument in the synonym function.

Usage

synonyms(terms, return.list = TRUE, multiwords = TRUE, report.null = TRUE,
  synonym.frame = qdapDictionaries::env.syn)

syn(terms, return.list = TRUE, multiwords = TRUE, report.null = TRUE,
  synonym.frame = qdapDictionaries::env.syn)

synonyms_frame(synonym.list, envir = TRUE, prior.frame)

syn_frame(synonym.list, envir = TRUE, prior.frame)

Arguments

terms
The terms to find synonyms for.
return.list
logical. If TRUE returns the output for multiple synonyms as a list by search term rather than a vector.
multiwords
logical. IF TRUE retains vector elements that contain phrases (defined as having one or more spaces) rather than a single word.
report.null
logical. If TRUE reports the words that no match was found at the head of the output.
synonym.frame
A dataframe or environment containing a dataframe of positive/negative words and weights.
synonym.list
A named list of lists (or vectors) of synonyms.
envir
logical. If TRUE a lookup table (a dataframe within an environment) is produced rather than a data.frame.
prior.frame
A prior synonyms data.frame in the format produced by synonym_frame

Value

  • Returns a list of vectors or vector of possible words that match term(s).

References

The synonyms dictionary (see SYNONYM) was generated by web scraping the http://dictionary.reverso.net/english-synonyms/{Reverso Online Dictionary}. The word list fed to http://dictionary.reverso.net/english-synonyms/{Reverso} is the unique words from the combination of DICTIONARY and labMT.

Examples

Run this code
synonyms(c("the", "cat", "job", "environment", "read", "teach"))
head(syn(c("the", "cat", "job", "environment", "read", "teach"),
    return.list = FALSE), 30)
syn(c("the", "cat", "job", "environment", "read", "teach"), multiwords = FALSE)

## User defined synonym lookup
syn_dat <- list(
    like = list(c("want", "desire"), c("love", "care")),
    show = list(c("reveal"), c("movie", "opera")),
    R = c("old friend", "statistics language")
)

synonyms_frame(syn_dat)
synonyms_frame(syn_dat, envir=FALSE)
syn(c("R", "show"), synonym.frame = syn_frame(syn_dat))

syns.hash <- syn_frame(syn_dat, prior.frame = SYNONYM)
syn(c("R", "show", "like", "robot"), synonym.frame = syns.hash)

Run the code above in your browser using DataLab