Text catalog

A TextCatalogCollection is a wrapper around a Vector of CatalogedTexts. You can construct one from a Vector of CatalogedTexts.

using CitableCorpus
using CitableText

hay_urn = CtsUrn("urn:cts:citedemo:gburg.hay.v2:")
hay = entry(hay_urn, "section", "Gettysburg Address", "Text of John Hay", "second HC digital edition")
everett_urn = CtsUrn("urn:cts:citedemo:gburg.everett.v2:")
everett = entry(everett_urn, "section", "Gettysburg Address", "Text of Edward Everett", "second HC digital edition")
catalog = TextCatalogCollection([hay, everett])
TextCatalogCollection with 2 entries

The TextCatalogCollection implements the CitableCollectionTrait, which implies that it also implements URN comparison and CEX serialization

using CitableBase
citablecollection(catalog)
true
using CitableBase
urntype(catalog)
CitableText.CtsUrn
cexserializable(catalog)
true
urncomparable(catalog)
true

In addition, it implements Julia's Iterators behavior, as we'll see below.

Urn comparison and filtering

urnequals(hay_urn, catalog)
TextCatalogCollection with 1 entry
allgburg = CtsUrn("urn:cts:citedemo:gburg:")
urncontains(allgburg, catalog)
TextCatalogCollection with 2 entries
urnsimilar(allgburg, catalog)
TextCatalogCollection with 2 entries

CEX serialization

catcex = cex(catalog)
"#!ctscatalog\nurn|citationScheme|groupName|workTitle|versionLabel|exemplarLabel|online|language\nurn:cts:citedemo:gburg.hay.v2:|section|Gettysburg Address|Text of John Hay|second HC digital edition|nothing|true|eng\nurn:cts:citedemo:gburg.everett.v2:|section|Gettysburg Address|Text of Edward Everett|second HC digital edition|nothing|true|eng"
fromcex(catcex, TextCatalogCollection) == catalog
true

Iteration

length(catalog)
2
eltype(catalog)
CatalogedText
collect(catalog)
2-element Vector{CatalogedText}:
 <urn:cts:citedemo:gburg.hay.v2:> Gettysburg Address, Text of John Hay, second HC digital edition
 <urn:cts:citedemo:gburg.everett.v2:> Gettysburg Address, Text of Edward Everett, second HC digital edition
for entry in catalog
    println(entry)
end
<urn:cts:citedemo:gburg.hay.v2:> Gettysburg Address, Text of John Hay, second HC digital edition
<urn:cts:citedemo:gburg.everett.v2:> Gettysburg Address, Text of Edward Everett, second HC digital edition