A text catalog entry
A CatalogedText
identifies a concrete version of a text by CTS URN, and records labels for its citation pattern and work hierarchy. You can create a CatalogedText
with the entry
function.
using CitableCorpus
using CitableText
hay_urn = CtsUrn("urn:cts:citedemo:gburg.hay.v2:")
catentry = entry(hay_urn, "section", "Gettysburg Address", "Text of John Hay", "second HC digital edition")
<urn:cts:citedemo:gburg.hay.v2:> Gettysburg Address, Text of John Hay, second HC digital edition
Notice that the entry
function has supplied default values for the exemplar
, online
and lang
fields. You can override those defaults with optional parameters.
Access values of the cataloged entry with these functions:
citation(catentry)
"section"
textgroup(catentry)
"Gettysburg Address"
work(catentry)
"Text of John Hay"
version(catentry)
"second HC digital edition"
exemplar(catentry) |> isnothing
true
lang(catentry)
"eng"
A citable object
A CatalogedText
follows CtsBase
's definition of a citable object. It therefore implements three traits defining behavior for (1) citation, (2) comparison based on URN logic, and (3) serialization to/from CEX format. You can verify that with the following functions from CitableBase
.
using CitableBase
citable(catentry)
true
urncomparable(catentry)
true
cexserializable(catentry)
true
Citation
The urntype
, label
and urn
functions are available for citable objects.
urntype(catentry)
CitableText.CtsUrn
label(catentry)
"<urn:cts:citedemo:gburg.hay.v2:> Gettysburg Address, Text of John Hay, second HC digital edition"
urn(catentry)
urn:cts:citedemo:gburg.hay.v2:
URN comparison
CatalogedText
s can be compared to URNs using URN logic for equality, containment and similarity. Note that in each function, the first parameter is the catalog entry, and the second a URN to compare the text to.
urnequals(catentry, hay_urn)
true
allgburg = CtsUrn("urn:cts:citedemo:gburg:")
urncontains(catentry, allgburg)
true
urnsimilar(catentry, allgburg)
true
CEX serialization
CitablePassage
s can be lossly roundtripped to and from objects and delimited-text strings in CEX format using the cex
and fromcex
functions of CitableBase
.
cex(catentry)
"urn:cts:citedemo:gburg.hay.v2:|section|Gettysburg Address|Text of John Hay|second HC digital edition|nothing|true|eng"
fromcex(cex(catentry), CatalogedText) == catentry
true