R/retrieve_sentence.R

Defines functions retrieve_sentence

#' @importFrom stringr str_replace_all
NULL

retrieve_sentence = function(doc_i, sentence_i, tok_obj){
  sent = paste0(subset(tok_obj, tok_obj$doc_id == doc_i & tok_obj$sentence == sentence_i)$token, collapse = " ")
  sent = str_replace_all(sent, " (?=[,.;'])", "")
  str_replace_all(sent, " {2,}", " ")
}

Try the semgram package in your browser

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

semgram documentation built on May 31, 2022, 5:06 p.m.