dfm_tolower and dfm_toupper convert the features of the dfm or fcm to lower and upper case, respectively, and then recombine the counts.

dfm_tolower(x, keep_acronyms = FALSE, ...)

dfm_toupper(x, ...)

fcm_tolower(x, keep_acronyms = FALSE, ...)

fcm_toupper(x, ...)

Arguments

x

the input object whose character/tokens/feature elements will be case-converted

keep_acronyms

logical; if TRUE, do not lowercase any all-uppercase words (applies only to *_tolower functions)

...

additional arguments passed to stringi functions, (e.g. stri_trans_tolower), such as locale

Details

fcm_tolower and fcm_toupper convert both dimensions of the fcm to lower and upper case, respectively, and then recombine the counts. This works only on fcm objects created with context = "document".

Examples

# for a document-feature matrix mydfm <- dfm(c("b A A", "C C a b B"), toLower = FALSE, verbose = FALSE)
#> Warning: Argument toLower not used.
mydfm
#> Document-feature matrix of: 2 documents, 3 features (16.7% sparse). #> 2 x 3 sparse Matrix of class "dfmSparse" #> features #> docs b a c #> text1 1 2 0 #> text2 2 1 2
dfm_tolower(mydfm)
#> Document-feature matrix of: 2 documents, 3 features (16.7% sparse). #> 2 x 3 sparse Matrix of class "dfmSparse" #> features #> docs b a c #> text1 1 2 0 #> text2 2 1 2
dfm_toupper(mydfm)
#> Document-feature matrix of: 2 documents, 3 features (16.7% sparse). #> 2 x 3 sparse Matrix of class "dfmSparse" #> features #> docs B A C #> text1 1 2 0 #> text2 2 1 2
# for a feature co-occurrence matrix myfcm <- fcm(tokens(c("b A A d", "C C a b B e")), context = "document")
#> Error in get(".SigLength", envir = env): object '.SigLength' not found
myfcm
#> Error in eval(expr, envir, enclos): object 'myfcm' not found
fcm_tolower(myfcm)
#> Error in fcm_tolower(myfcm): object 'myfcm' not found
fcm_toupper(myfcm)
#> Error in fcm_toupper(myfcm): object 'myfcm' not found