anystyleR (development version)
Changes compared with anystyleR 0.0.999. There are breaking changes in the arguments and in the columns of the results.
Renaming and infrastructure
- The package is renamed from Ranystyle to anystyleR. Its repository and website move to Codeberg (https://agoutsmedt.codeberg.page/anystyler/).
- The package now needs R >= 4.1 and no longer imports magrittr, purrr and tidyr (it imports stringi). It has tests (testthat), run with or without anystyle installed.
- The vignette is replaced by two articles on the website: a workflow guide, From documents to references, and How good is the parsing?, which measures anystyle and the cleaning rules against Scopus references.
Running anystyle
- New
anystyle_path()andcheck_anystyle(): theanystyleexecutable is looked for in the optionanystyleR.anystyle, the environment variableANYSTYLE_PATH, thePATHand the user gem directories. Functions fail early with an informative message when it is missing. - anystyle is now run without a shell: paths with spaces or quotes work. Its errors, including those it reports with a success exit status, stop the function with anystyle’s message. Commands are no longer printed.
- Nothing is written in the working directory any more: temporary files go to a temporary directory and are removed.
-
install_anystyle()installs the gems in the user’s directory by default (user_install = TRUE, no administrator rights needed), reports where the executable is, and checks forpdftotext. - Messages, warnings and errors use cli.
find_ref() and parse_ref()
- Arguments renamed:
pathbecomesoutput_dir(NULL, the default, returns the output instead of writing files),output_formatbecomesformat(default"json", validated withrlang::arg_match()instead of a warning),no_layoutbecomeslayout(defaultTRUE). - New arguments
finder_modelandparser_modelto use custom anystyle models, andsoloinfind_ref()to keep references outside reference sections. -
find_ref()accepts text files as well as PDFs, and the"csl","txt"and"ttx"formats ("ttx"shows the label given to each line, to see why a bibliography was missed). It shows a progress bar. - The output is a named character vector (one element per document) instead of a list or a single element depending on the number of documents.
-
parse_ref()takes input as files only when all elements are existing files (previously, any element without.txtmade the whole input references). Line breaks inside a reference are replaced by spaces and empty references dropped, so that the output matches the input. - Existing output files are checked before anything runs.
find_ref_to_df() and parse_ref_to_df()
- All the references of a call are parsed in one run of anystyle, in chunks of 1,000, instead of one run per document: much faster on many documents. A reference that makes anystyle fail no longer stops the run: it is isolated, returned empty and flagged
anystyle_failed. -
full_refis now aligned with the parsed fields by construction (previously, the two were joined by position and could be shifted). - New
docargument inparse_ref_to_df(): the document each reference comes from, to number references within documents. - New column
ref_order(position of the reference in its document).id_docis the position of the document ininput. - Argument
clean_refrenamedclean;no_layoutreplaced bylayout; new argumentssolo,finder_modelandparser_model. - With
clean = FALSE, the result has a stable structure: one list-column per anystyle field (a tibble of name parts for names), instead of columns unnested or not depending on the data. - A ditto mark opening a document no longer takes the authors of the last reference of the previous document.
- Before parsing, a space is added after a closing quotation mark glued to the next word and after an initial glued to a family name (“H.Genberg”);
full_refkeeps the original text.
clean_ref()
clean_ref() is rewritten. It returns flat columns (first_author, n_authors, authors, et_al, year, year_suffix, date, title, container_title, volume, issue, number, pages, first_page, last_page, editors, doi…; field names use _ instead of -), and a flag column listing the rules that changed each reference. One-value fields keep the first value anystyle found; further titles and dates go to other_title and other_date (separated by " | " instead of line breaks). It is vectorised and much faster. New rules, each checked against Scopus fields or central bank bibliographies:
- Names written “Family I.” without comma, read by anystyle with the initials as family name, are swapped.
- Given names in capitals split into initials by anystyle (“D.O.N.A.L.D.”) are restored; acronyms alone (“ECB”) become institutions.
- Institutions read as persons (“Bank of England”) or as titles (“Committee on the Global Financial System (2012)”) become one literal name.
- Ditto marks (“_.”, “–”) are filled with the authors of the previous reference of the same document; “et al.” becomes
et_al. - The first editor stands for the author of an edited book without author in
first_author. - Years are read from the reference when anystyle finds no date (in brackets, or the only year of the reference); the letter of “1985a” is kept in
year_suffix; a title made only of a year is dropped. - Pages are split into
first_pageandlast_page, abbreviated ranges (“1145-64”) expanded. - “Vol.” and “No.” are removed (no longer the “No” of “November”), anystyle’s “ue 2” (from “Issue 2”) is repaired, glued volume and issue (“47 2”) split, roman volumes converted.
- Working papers and other report series are typed
report, with their number innumber; speeches, remarks and testimonies are typedspeech. - The DOI is taken from the
doifield, the URL or the reference, without resolver and trailing punctuation. - Quotation marks and unbalanced brackets around fields are removed (previously, all leading and trailing punctuation of every column, including closing brackets and question marks).
- Lines that are probably not references are flagged
not_a_reference.
Flattened bibliographies
- New
split_ref()cuts a block of text holding a whole bibliography without line breaks (OCR, databases) into references, with rules on where a reference starts. On Scopus bibliographies joined into one block, 92% of cuts are right and 78% of true boundaries are found. -
parse_ref_to_df()gainssplit = TRUEto split blocks before parsing.
Word bibliographies
-
find_ref_to_word_bibliography()andparse_ref_to_word_bibliography()call pandoc directly instead of rendering an R Markdown document, and share their code. - Argument
csl_pathrenamedcsl;no_layoutreplaced bylayout; new argumentoverwrite. - The default output is in the working directory instead of the home directory, and only
.docxis accepted. The path is returned invisibly.
anystyleR 0.0.999
- First version, as Ranystyle:
install_anystyle(),find_ref(),parse_ref(),find_ref_to_df(),parse_ref_to_df(),clean_ref(),find_ref_to_word_bibliography()andparse_ref_to_word_bibliography().
