Skip to contents

Search the text of a paper or list of paper objects. Also works on the table results of a search_text() call.

Usage

search_text(
  paper,
  pattern = ".*",
  section = NULL,
  return = c("sentence", "paragraph", "section", "match"),
  ignore.case = TRUE,
  ...
)

Arguments

paper

a paper object or a list of paper objects

pattern

the regex pattern to search for

section

the section(s) to search in

return

the kind of text to return, the full sentence, paragraph, or section that the text is in, or just the (regex) match

ignore.case

whether to ignore case when text searching

...

additional arguments to pass to grep() and regexpr(), such as fixed = TRUE

Value

a data frame of matches

Examples

filename <- demoxml()
paper <- read_grobid(filename)

search_text(paper, "p\\s*(=|<)\\s*[0-9\\.]+", return = "match")
#> # A tibble: 2 × 7
#>   text       section header    div     p     s id                 
#>   <chr>      <chr>   <chr>   <dbl> <dbl> <int> <chr>              
#> 1 p = 0.005. results Results     3     1     2 to_err_is_human.xml
#> 2 p = 0.152. results Results     3     2     1 to_err_is_human.xml