Skip to contents

Every record of a text database is identified by doc_id = "<source>:<source_id>": the prefix keeps identifiers unique across sources and tells where a record comes from without a join.

  • make_doc_id() builds identifiers and refuses missing or empty parts;

  • split_doc_id() splits them back into source and identifier.

Usage

make_doc_id(source, source_id, sep = ":")

split_doc_id(doc_id, sep = ":")

Arguments

source

Character. Short name of the source ("ecb", "jstor"), recycled.

source_id

Character. Identifier of the record in the source.

sep

Character. Separator between source and identifier.

doc_id

Character. Identifiers built by make_doc_id().

Value

make_doc_id(): a character vector. split_doc_id(): a data.table with source and source_id.

Details

Identifiers are forever: once a record has an identifier, it keeps it, even when a better identifier is found later or the record turns out to duplicate another one (link duplicates with a duplicate_of column instead of merging identifiers). source_id must be derived from something stable in the source: a file token, a DOI, or a hash of the normalised URL (hash_id()), never the order of collection. When the source gives no identifier at all, keep the decision that two records are the same as data (who decided, when, why) rather than overwriting one of them: Lemercier and Zalc (2019, ch. 3) advise to change identifiers when two individuals turn out to be one, which a database read by other projects cannot do without breaking their joins.

See also

Other identifiers: hash_id(), make_slug(), pad_id()

Examples

make_doc_id("ecb", c("sp240327", "wp2350"))
#> [1] "ecb:sp240327" "ecb:wp2350"  
split_doc_id(c("ecb:sp240327", "bis_hub:3f2a91c0d4e5"))
#>     source    source_id
#>     <char>       <char>
#> 1:     ecb     sp240327
#> 2: bis_hub 3f2a91c0d4e5