R/has_endmark.R

Defines functions has_endmark

Documented in has_endmark

#' Test for Incomplete Sentences
#' 
#' A logical test of missing sentence ending punctuation.
#' 
#' @param x A character vector.
#' @param endmarks The potential ending punctuation marks,
#' @param \dots ignored.
#' @return Returns a logical vector.
#' @keywords incomplete
#' @export
#' @examples
#' x <- c(
#'     "I like it.", 
#'     "Et tu?",  
#'     "Not so much", 
#'     "Oh, I understand.",  
#'     "At 3 p.m., we go",
#'     NA
#' )
#' has_endmark(x)
has_endmark <- function(x, endmarks = c('?', '.', '!'), ...){
    !is.na(x) & grepl(
        sprintf('[%s]\\s*$', paste(endmarks, collapse = "")), 
        x, perl = TRUE, 
        ...
    )
}
trinker/textclean documentation built on Nov. 3, 2021, 7:20 p.m.