Learn R Programming

quanteda (version 0.9.2-0)

toLower: Convert texts to lower case

Description

Convert texts or tokens to lower case

Usage

toLower(x, keepAcronyms = FALSE, ...)

## S3 method for class 'character': toLower(x, keepAcronyms = FALSE, ...)

## S3 method for class 'NULL': toLower(x, ...)

## S3 method for class 'tokenizedTexts': toLower(x, keepAcronyms = FALSE, ...)

## S3 method for class 'corpus': toLower(x, keepAcronyms = FALSE, ...)

Arguments

x
texts to be lower-cased
keepAcronyms
if TRUE, do not lowercase any all-uppercase words
...
additional arguments passed to stringi functions, (e.g. stri_trans_tolower), such as locale

Value

  • Texts tranformed into their lowercased versions. If x is a character vector or a corpus, return a lowercased character vector. If x is a list of tokenized texts, then return a list of lower-cased tokenized texts.

Examples

Run this code
test1 <- c(text1 = "England and France are members of NATO and UNESCO", 
           text2 = "NASA sent a rocket into space.")
toLower(test1)
toLower(test1, keepAcronyms = TRUE)

test2 <- tokenize(test1, removePunct=TRUE)
toLower(test2)
toLower(test2, keepAcronyms = TRUE)

Run the code above in your browser using DataLab