R/helper_get.sentence.with.pattern.R

Defines functions get.sentence.with.pattern

Documented in get.sentence.with.pattern

#' get.sentence.with.pattern
#'
#' Returns lines with search term patterns.
#' @param x sentence vector to process.
#' @param patterns search terms.
#' @param tolower Logical. If TRUE converts search terms and text to lower case.
#' @return Character. Vector with sentences, that contain search pattern.
#' @keywords internal
#' @export
#' @examples
#' text<-c("This demo", "demonstrates how", "get.sentence.with.pattern works.")
#' get.sentence.with.pattern(text,c("Demo","example","work"))
#' get.sentence.with.pattern(text,c("Demo","example","work"),tolower=FALSE)

get.sentence.with.pattern<-function(x,patterns=c(""),tolower=TRUE){
pat<-paste(patterns,collapse="|")
x<-as.character(x)
if(tolower==T) temp<-x[grep(tolower(pat),tolower(x))]
if(tolower!=T) temp<-x[grep(pat,x)]
return(temp)
}

Try the JATSdecoder package in your browser

Any scripts or data that you put into this service are public.

JATSdecoder documentation built on Oct. 12, 2023, 5:13 p.m.