R/clean_letters.R

Defines functions clean_letters

Documented in clean_letters

#' @name clean_letters
#' @title Simplify string
#' @author Nicolas Mangin
#' @description Simplify the text to only lower case letters
#' @param text  Character string. String to be simplified
#' @return A simplified string.
#' @importFrom dplyr %>%
#' @importFrom stringr str_remove_all
#' @export

clean_letters <- function(text) {
  text %>%
    tolower() %>%
    stringr::str_remove_all("[,:!;?]") %>%
    stringr::str_remove_all("[0-9]") %>%
    stringr::str_remove_all("\\.") %>%
    stringr::str_remove_all(lexR::dat_symbols) %>%
    stringr::str_remove_all("'") %>%
    stringr::str_remove_all('"') %>%
    stringr::str_remove_all("\\(") %>%
    stringr::str_remove_all("\\)") %>%
    stringr::str_remove_all("\\[") %>%
    stringr::str_remove_all("\\]") %>%
    stringr::str_remove_all("\\{") %>%
    stringr::str_remove_all("\\}")
}
NicolasJBM/lexR documentation built on Feb. 4, 2021, 6:43 p.m.