Learn R Programming

quanteda (version 0.9.9-3)

applyDictionary: apply a dictionary or thesaurus to an object

Description

Convert features into equivalence classes defined by values of a dictionary object.

Usage

applyDictionary(x, dictionary, ...)
"applyDictionary"(x, dictionary, exclusive = TRUE, valuetype = c("glob", "regex", "fixed"), case_insensitive = TRUE, capkeys = !exclusive, verbose = TRUE, ...)
"applyDictionary"(x, dictionary, exclusive = TRUE, valuetype = c("glob", "regex", "fixed"), case_insensitive = TRUE, capkeys = !exclusive, verbose = TRUE, ...)
"applyDictionary"(x, ...)

Arguments

x
object to which dictionary or thesaurus will be supplied
dictionary
the dictionary-class object that will be applied to x
...
not used
exclusive
if TRUE, remove all features not in dictionary, otherwise, replace values in dictionary with keys while leaving other features unaffected
valuetype
how to interpret keyword expressions: "glob" for "glob"-style wildcard expressions; "regex" for regular expressions; or "fixed" for exact matching. See valuetype for details.
case_insensitive
ignore the case of dictionary values if TRUE
capkeys
if TRUE, convert dictionary keys to uppercase to distinguish them from other features
verbose
print status messages if TRUE

Value

an object of the type passed with the value-matching features replaced by dictionary keys

Details

applyDictionary.dfm is the deprecated function name for dfm_lookup.

Examples

Run this code
toks <- tokens(data_corpus_inaugural)
head(kwic(toks, "united states"))
dict <- dictionary(list(country = "united states"))
toks2 <- applyDictionary(toks, dict, valuetype = "fixed")
toks2

Run the code above in your browser using DataLab