有时候用endnote导入文献后显示的是期刊全称,而用到缩写时候就需要去一些网站上一个个搜索,比如CASSI, LetPub、Pubumed等网站,或者Y叔公号里直接回复,而逛Github时候突然发现abbrevr这小R包中可以很快批量实现这个需求,在此记录一下。
安装
# install.packages("remotes")
remotes::install_github("patrickbarks/abbrevr")
查询期刊缩写
library(abbrevr)
AbbrevTitle("Transactions of the American Fisheries Society")
#> [1] "Trans. Am. Fish. Soc."
AbbrevTitle("Deutsche Medizinische Wochenschrift")
#> [1] "Dtsch. Med. Wochenschr."
AbbrevTitle("L'Intermédiaire des Mathématiciens")
#> [1] "Interméd. Math."
根据doi号批量获取
这里就需要结合另一个R包rcrossref, 这个包主要功能就是利用API接口根据doi号提取文献信息(具体原理可自行摸索),然后提取出文献全称再批量转化为缩写,一步到位,示例如下:
# load rcrossref
library(rcrossref)
# DOIs for a set of scientific publications
dois <- c(
"10.1577/T09-174.1",
"10.1371/journal.pone.0075858",
"10.1111/1365-2435.12359",
"10.1111/jeb.12823",
"10.1111/1365-2745.12937"
)
# use rcrossref::cr_cn() to get citation info for DOIs
citations <- rcrossref::cr_cn(dois, format = "citeproc-json")
# extract journal titles from citation info
titles <- sapply(citations, function(x) x$`container-title`, USE.NAMES = FALSE)
# use abbrevr::AbbrevTitle() to abbreviate titles
titles_short <- sapply(titles, abbrevr::AbbrevTitle, USE.NAMES = FALSE)
# print data.frame
data.frame(
doi = dois,
title = titles,
title_short = titles_short,
stringsAsFactors = FALSE
)
附当前版本说明:
The current version…
- only handles common articles, prepositions, and conjunctions in English, German, and French (ISO 4 dictates that these classes should generally be ommitted, with exceptions noted in the document linked above)
- omits all punctuation except for hyphens (ISO 4 dictates all punctuation except commas should be retained, but periods should be replaced with commas)
- does not omit generic identifiers such as “Section”, “Series”, or “Part” (ISO 4 dictates such generics should be ommitted unless required for identification)
- may not retain all diacritic marks (ISO 4 dictates that all diacritic marks should be retained)
Also beware of abbreviation rules that are difficult to implement algorithmically, e.g.:
- names of persons should not be abbreviated
- prepositions and articles should be retained if they are integral parts of proper names (e.g. “Los Alamos”) or locutions (e.g. “in vivo”)