Skip to contents

[Experimental]

Usage

split_ref(x, heading = TRUE, min_chars = 25)

Arguments

x

A character vector: each element is a block of text holding one or several references.

heading

Logical. Remove a leading heading ("References", "Bibliography", "Works cited"...)? Default TRUE.

min_chars

Integer. Segments shorter than this are glued back to the previous reference (a cut inside an author list, a page number...). Default 25.

Value

A list with one character vector of references per element of x.

Details

anystyle needs one reference per line. Text extracted from scanned journals (OCR), from databases or from some PDFs often holds a whole bibliography in one block, without line breaks, and anystyle find finds nothing in it. split_ref() cuts such a block into references with rules on where a reference starts.

A reference is taken to start, after the end of the previous one (a full stop, a digit, a closing bracket or quotation mark), with

  • an author written "Family, I." or "Family, Given" (also in capitals: "GRETHER, DAVID");

  • an author written "Family I." or "Family IJ" (Vancouver and some economics styles);

  • a ditto mark ("—–", "—.", "———") that stands for the author of the previous reference;

  • a number in square brackets, such as [12].

Rules like these are wrong when a publisher or a place looks like an author ("Cambridge, Mass.") and miss references that start with a title or an institution. They were checked on the references of Scopus articles joined into one block, where the true boundaries are known (see the article "How good is the parsing?"). Check the result before relying on it, and prefer one reference per line when you can get it.

See also

parse_ref_to_df(), whose split argument calls this function.

Examples

block <- paste(
  "References Barro, R. J. (1983). Rules, discretion and reputation.",
  "Journal of Monetary Economics, 12, 101-121. Friedman, M. (1968).",
  "The role of monetary policy. American Economic Review, 58(1), 1-17.",
  "---. (1970). A theoretical framework for monetary analysis."
)
split_ref(block)
#> [[1]]
#> [1] "Barro, R. J. (1983). Rules, discretion and reputation. Journal of Monetary Economics, 12, 101-121."
#> [2] "Friedman, M. (1968). The role of monetary policy. American Economic Review, 58(1), 1-17."          
#> [3] "---. (1970). A theoretical framework for monetary analysis."                                       
#>