Learn R Programming

quanteda (version 0.99)

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, ...)

# S3 method for tokens applyDictionary(x, ...)

# S3 method for tokenizedTexts applyDictionary(x, ...)

# S3 method for dfm 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

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
# NOT RUN {
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