Usage
find_ref(
input,
output_dir = NULL,
format = c("json", "ref", "bib", "csl", "xml", "txt", "ttx"),
layout = TRUE,
solo = FALSE,
finder_model = NULL,
parser_model = NULL,
overwrite = FALSE
)Arguments
- input
Character vector of paths to PDF (
.pdf) or text (.txt) documents.- output_dir
Directory where anystyle writes one file per document (named after the document, with the extension of
format). IfNULL(the default), nothing is written and the output is returned.- format
Output format:
"json"(CSL-like JSON, the default),"ref"(one reference per line, as printed),"bib"(BibTeX),"csl"(CSL-JSON),"xml"(anystyle's tagged XML),"txt"(the extracted text) or"ttx"(the text with the label given by the finder to each line: useful to see why a reference section was missed).- layout
Logical. If
TRUE(the default), the text of PDFs is extracted with its layout (pdftotext -layout). Set it toFALSEfor documents in several columns, whose lines are otherwise interleaved.- solo
Logical. If
TRUE, anystyle also returns references found outside reference sections (e.g. in footnotes). DefaultFALSE.- finder_model, parser_model
Paths to custom anystyle models (
.modfiles created withanystyle train), orNULLfor the models shipped with anystyle.- overwrite
Logical. Overwrite existing files in
output_dir? DefaultFALSE, in which case existing files make the function fail before anything is run.
Value
If output_dir is NULL, a named character vector with one element
per document (named after the file), holding the whole output of anystyle
(an empty string when no reference is found). Otherwise, invisibly, the
paths of the written files.
Details
Runs anystyle find on PDF or text documents: anystyle locates the
bibliography (and, optionally, references outside it), segments it into
references and parses them. Use find_ref_to_df() to get a tidy data frame
directly.
Examples
if (FALSE) { # \dontrun{
pdf <- system.file("extdata", "example_doc_1.pdf", package = "anystyleR")
# The references, as printed, one per line
refs <- find_ref(pdf, format = "ref")
cat(refs)
# Why was a line (not) taken as a reference?
cat(find_ref(pdf, format = "ttx"))
# Write BibTeX files for a folder of PDFs
find_ref(list.files("my_pdfs", full.names = TRUE), output_dir = "bib", format = "bib")
} # }
