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.
#> Warning: Argument toLower not used.
mydfm
#> Document-feature matrix of: 2 documents, 3 features (16.7% sparse). #> 2 x 3 sparse Matrix of class "dfm" #> 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 "dfm" #> 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 "dfm" #> 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") myfcm
#> Feature co-occurrence matrix of: 7 by 7 features. #> 7 x 7 sparse Matrix of class "fcm" #> features #> features b A d C a B e #> b 0 2 1 2 1 1 1 #> A 0 1 2 0 0 0 0 #> d 0 0 0 0 0 0 0 #> C 0 0 0 1 2 2 2 #> a 0 0 0 0 0 1 1 #> B 0 0 0 0 0 0 1 #> e 0 0 0 0 0 0 0
fcm_tolower(myfcm)
#> Feature co-occurrence matrix of: 5 by 5 features. #> 5 x 5 sparse Matrix of class "fcm" #> features #> features b a d c e #> b 1 3 1 2 2 #> a 1 1 2 0 1 #> d 0 0 0 0 0 #> c 2 2 0 1 2 #> e 0 0 0 0 0
fcm_toupper(myfcm)
#> Feature co-occurrence matrix of: 5 by 5 features. #> 5 x 5 sparse Matrix of class "fcm" #> features #> features B A D C E #> B 1 3 1 2 2 #> A 1 1 2 0 1 #> D 0 0 0 0 0 #> C 2 2 0 1 2 #> E 0 0 0 0 0