有時候用endnote導入文獻后顯示的是期刊全稱,而用到縮寫時候就需要去一些網站上一個個搜索,比如CASSI, LetPub、Pubumed等網站,或者Y叔公號里直接回復,而逛Github時候突然發現abbrevr這小R包中可以很快批量實現這個需求,在此記錄一下。
List of Title Word Abbreviations (LTWA)
安裝
# 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] "Interme?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
)
image-20221207150254677
附當前版本說明:
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”)