anystyleR turns the bibliographies of documents into research data. Citation indexes such as the Web of Science or Scopus give the references of journal articles, but many of the texts that matter for the history and sociology of a discipline are outside them: books, theses, older journals, working papers, central bank and international organisation reports, speeches, policy documents. Their bibliographies are only available as printed text. To ask who central bankers cite in their speeches, how the literature mobilised by policy reports changed over time, or how a research field built on grey literature, you first need to turn these printed lists into a table with one row per reference and its authors, year, title and journal.
The package does this with anystyle, an open source tool that finds the reference section of a PDF or text document, segments it into references and splits each reference into its fields with a machine learning model (a conditional random field). anystyleR runs anystyle from R, returns tidy data frames, and adds a layer of cleaning rules that correct the errors anystyle makes most often. Each rule was written by comparing anystyle’s output with the fields that Scopus gives for thousands of references, and with the bibliographies of central bank documents, and was kept only when it improved the result (see how good is the parsing?).
Installation
Install the package from Codeberg:
# install.packages("pak")
pak::pak("git::https://codeberg.org/agoutsmedt/anystyleR.git")anystyle is a Ruby program. Install Ruby first (with its development headers and a C compiler, e.g. ruby-devel and gcc on Fedora, ruby-dev and build-essential on Debian or Ubuntu), and Poppler’s pdftotext to read PDFs. Then install anystyle from R:
anystyleR::install_anystyle()
anystyleR::check_anystyle()install_anystyle() installs the gems in your user directory; if the anystyle executable is not found afterwards, give its path with options(anystyleR.anystyle = "/path/to/anystyle") (see ?anystyle_path).
A first look
The package ships three articles as examples. find_ref_to_df() finds their references and returns one row per reference:
library(anystyleR)
pdfs <- list.files(system.file("extdata", package = "anystyleR"), "\\.pdf$", full.names = TRUE)
references <- find_ref_to_df(pdfs)
references |>
dplyr::select(doc, first_author, year, title, container_title, type)
#> # A tibble: 266 × 6
#> doc first_author year title container_title type
#> <chr> <chr> <int> <chr> <chr> <chr>
#> 1 example_doc_1.pdf Arnold 2023 ECB must do more to tackle … Financial Times arti…
#> 2 example_doc_1.pdf Barro 1983 Rules, discretion and reput… Journal of Mon… arti…
#> 3 example_doc_1.pdf Béland 2009 Ideas, institutions, and po… Journal of Eur… arti…
#> 4 example_doc_1.pdf Berger 1999 A state within the state? A… Scottish Journ… arti…
#> 5 example_doc_1.pdf Best 2018 Technocratic exceptionalism… International … arti…
#> 6 example_doc_1.pdf Blei 2003 Latent Dirichlet Allocation Journal of Mac… arti…
#> 7 example_doc_1.pdf Braun 2022 Planning Laissez-Faire: Sup… Zeitschrift Fü… arti…
#> 8 example_doc_1.pdf Carpenter 2010 Reputation and power: Organ… <NA> book
#> 9 example_doc_1.pdf Constâncio 2016 The challenge of low real i… At the Macroec… pape…
#> 10 example_doc_1.pdf Constâncio 2017 Effectiveness of monetary u… At the EUROFI … pape…
#> # ℹ 256 more rowsYou can also parse references you already have, for instance a column of a data frame, keeping track of the document each reference comes from:
parsed <- parse_ref_to_df(
c(
"Bank of England (2015) ‘The Financial Policy Committee’s powers over housing tools’, Policy Statement, July 2015",
"Mody, A. and Sandri, D. (2011), “The Eurozone Crisis: How Banks and Sovereigns Came to be Joined at the Hip”, IMF Working Papers, WP/11/269.",
"Brainard W.C., Tobin J. On the internationalization of portfolios. Oxford Economic Papers. 44:1992;433-565."
),
doc = c("speech_1", "speech_1", "article_2")
)
parsed |>
dplyr::select(doc, authors, year, title, container_title, number, type, flag)
#> # A tibble: 3 × 8
#> doc authors year title container_title number type flag
#> <chr> <chr> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 speech_1 Bank of England 2015 The Financi… Policy Stateme… <NA> arti… inst…
#> 2 speech_1 Mody, A.; Sandri, D. 2011 The Eurozon… IMF Working Pa… WP/11… repo… repo…
#> 3 article_2 Brainard, W.C.; Tobin, J 1992 On the inte… Oxford Economi… <NA> arti… fami…The flag column says which cleaning rules changed a reference: here, an institution read by anystyle as a person named “England, Bank”, a working paper typed as a journal article, and names written “Family I.” without a comma, whose initials anystyle took for the family name.
What is in the package
-
find_ref_to_df()andparse_ref_to_df(): from documents or reference strings to a tidy data frame, with the reference as printed (full_ref) and its cleaned fields. -
clean_ref(): the cleaning rules (names, institutions, ditto marks, years, pages, volumes, DOIs, working papers, speeches), each recorded in aflagcolumn so that you can check what was changed. -
split_ref(): cuts a flattened bibliography (OCR text with no line breaks) into references, which anystyle needs. -
find_ref()andparse_ref(): anystyle itself, with all its output formats (JSON, BibTeX, CSL-JSON, tagged XML for training a model). -
find_ref_to_word_bibliography()andparse_ref_to_word_bibliography(): a formatted Word bibliography in any citation style.
The guide From documents to references walks through a complete workflow, from a folder of PDFs to a citation dataset.
What comes next
Two developments are planned. The cleaning rules will keep growing, tested on new kinds of documents. And anystyle’s model will be retrained on references generated from known bibliographic records, rendered in many citation styles, to improve the parsing of grey literature and of non-English references, which the model shipped with anystyle handles less well.
Citation
Goutsmedt A (2026). _anystyleR: Find, Parse and Clean Bibliographic References
with anystyle_. R package version 0.0.999.9000,
<https://codeberg.org/agoutsmedt/anystyleR>.Please also cite anystyle, by Sylvester Keil: https://anystyle.io/.
