R/num_tokenz.R

Defines functions num_tokenz

Documented in num_tokenz

#' How many tokens are in the strings?
#'
#' @param s vector of strings
#'
#' @return a number
#' @export
#'
#' @examples
#' num_tokenz(c("a bad wolf", "stole my", "oranges"))
num_tokenz <- function(s){
  t <- data.frame(s)
  t2 <- tidytext::unnest_tokens(tbl = t, input = "s", output = "tokenz")
  return(length(t2$tokenz))
}
rammkripa/trialpackage documentation built on Jan. 12, 2021, 12:38 a.m.