Enhance Zotero Records with External Metadata via Zotero Lookups
Source:R/zotero_enhancer.R
ZoteroEnhancer.Rd
This function iterates over a data frame (or tibble) of Zotero records and attempts to enhance
each record by retrieving additional metadata from external sources. It uses DOI or ISBN information,
via the c2z
package, to fetch external metadata and then merges these updates into the original
Zotero record. Special handling is provided for records representing book sections.
Usage
ZoteroEnhancer(
zotero.data,
external.data = NULL,
use.doi = TRUE,
use.semantic = TRUE,
use.isbn = TRUE
)
Arguments
- zotero.data
A data frame (or tibble) containing Zotero records. Each row represents a record that may include fields such as
abstractNote
,DOI
,url
,ISBN
,key
,itemType
,pages
, andcreators
.- external.data
Optional. A data frame or list containing pre-fetched external metadata. If provided and non-empty, the function will use this external metadata to update the Zotero records instead of querying the external APIs. Defaults to
NULL
.- use.doi
Logical; if
TRUE
(default), the function will attempt to retrieve external metadata using DOI information. Defaults toTRUE
.- use.semantic
Logical; if
TRUE
(default), the function will attempt to retrieve external metadata from Semantic Scholar using DOI information. Defaults toTRUE
.- use.isbn
Logical; if
TRUE
(default), the function will attempt to retrieve external metadata using ISBN information when DOI retrieval is not successful. Defaults toTRUE
.
Value
A data frame containing the enhanced Zotero records with external metadata merged into the original records.
Details
For each record in zotero.data
, the function performs the following steps:
If
external.data
is provided and non-empty, that data is used to update the record.Otherwise, the function skips processing the record if an abstract already exists.
It then attempts to extract a DOI from the
DOI
field, or if missing, from theurl
field.The
ISBN
field is processed by removing spaces and extracting the first value (in case of comma separation).If a valid DOI is found and
use.doi
isTRUE
, external metadata is retrieved usingc2z::ZoteroDoi()
. Otherwise, if an ISBN is available anduse.isbn
isTRUE
, metadata is retrieved usingc2z::ZoteroIsbn()
.Once external metadata is successfully retrieved, an internal helper function
UpdateTibble
is called. This helper function merges the external metadata into the original record. For book sections, additional adjustments are made to handle creator information, pages, and edition fields.Finally, the enhanced record is merged back into the original data frame using
UpdateInsert()
.