R/premises.R

Defines functions premises

Documented in premises

#' return matches of premises based on Hurley's (2003) Logic
#'
#' @param path of document
#' @return list of vectors with matches printed, or "character(0)" with unmatched.
#' @export


premises <- function(x){

  a <- readtext::readtext(x)
  b <- a$text
  d <- gsub("[\r\n]"," ", b)

  e <- grepl("Revised and Edited for Student Use", d)
  g <- ifelse(e == TRUE, gsub("^.*Use[\n]"," ", d), gsub("^.*Grade\\s[[:digit:]]"," ", d))

  e <- strsplit(d, "[\\.] ")
  f <- unlist(e)


  premises <- list("character") # return this

  for(i in seq_along(f)){
    premi <- "since| in that| seeing that| as indicated by| may be inferred from| for the reason that| because| as inasmuch as| for| given that| owing to"
    premises[[i]] <- grep(premi, f[[i]], value = TRUE)
  }

  return(premises)

}
cownr10r/teachr documentation built on Nov. 4, 2019, 9:14 a.m.