Usage
parse_ref(
input,
output_dir = NULL,
format = c("json", "bib", "csl", "xml"),
parser_model = NULL,
overwrite = FALSE
)Arguments
- input
Either a character vector of references (one reference per element), or paths to text files holding one reference per line.
inputis taken as files when all its elements are paths of existing files.- output_dir
Directory where anystyle writes the output (one file per input file, named after it;
references.<format>wheninputholds references). IfNULL(the default), the output is returned.- format
Output format:
"json"(the default),"bib","csl"or"xml"(anystyle's tagged XML, the format used to train models).- parser_model
Path to a custom anystyle parser model, or
NULLfor the model shipped with anystyle.- overwrite
Logical. Overwrite existing files in
output_dir? DefaultFALSE.
Value
If output_dir is NULL, a character vector with one element per
input file (named after it), or a single string when input holds
references. Otherwise, invisibly, the paths of the written files.
Details
Runs anystyle parse, which splits each reference into its fields (authors,
date, title, journal, volume, pages...). anystyle reads one reference per
line. Use parse_ref_to_df() to get a tidy data frame directly.
Line breaks inside a reference are replaced by spaces and empty references are dropped before parsing: otherwise anystyle would read them as several references, or skip them, and the output would not match the input. Note that anystyle replaces a ditto mark (e.g. "———" for "same author") with the authors of the previous line: keep the references of a document together and in order.
Examples
if (FALSE) { # \dontrun{
parse_ref("Doe, J. (2020). Title of the article. Journal Name, 13(2), 123-456.")
txt <- system.file("extdata", "example_doc_1.txt", package = "anystyleR")
parse_ref(txt, format = "bib")
} # }
