add add_s
trinker opened this issue · 1 comments
trinker commented
add_s <- function (x, keep.original = TRUE) {
ends <- qdapRegex::pastex(c("s$", "x$", "ch$", "sh$"))
pluralify <- ifelse(grepl(ends, x), "es", "s")
c(if (keep.original) {
x
}, gsub("ys$", "ies", paste0(x, pluralify)))
}
trinker commented
Add handling for irregular nouns http://www.esldesk.com/vocabulary/irregular-nouns and http://www.ef.edu/english-resources/english-grammar/singular-and-plural-nouns/
#' Make Plural (or Verb to Singular) Versions of Words
#'
#' Add -s, -es, or -ies to words.
#'
#' @param x A vector of words to make plural.
#' @param keep.original logical. If \code{TRUE} the original words are kept in
#' the return vector.
#' @return Returns a vector of plural words.
#' @keywords plural
#' @export
#' @examples
#'
x <- c('fox', 'sky', 'dog', 'church', 'fish', 'miss', 'mitch')
make_plural(x)
make_plural <- function (x, keep.original = FALSE) {
ends <- "(sh?|x|z|ch)$"
pluralify <- ifelse(grepl(ends, x), "es", "s")
c(if (keep.original) {
x
}, gsub("ys$", "ies", paste0(x, pluralify)))
}