Overview

I had the opportunity to learn how to use DTS (Distributed Text Services), and this is a memo of that experience.

API Used

We will use Alpheios, which is introduced at the following page.

https://github.com/distributed-text-services/specifications/?tab=readme-ov-file#known-corpora-accessible-via-the-dts-api

Top

https://texts.alpheios.net/api/dts

We can see that collections, documents, and navigation are available.

{
	"navigation": "/api/dts/navigation",
	"@id": "/api/dts",
	"@type": "EntryPoint",
	"collections": "/api/dts/collections",
	"@context": "dts/EntryPoint.jsonld",
	"documents": "/api/dts/document"
}

Collection Endpoint

collections

https://texts.alpheios.net/api/dts/collections

We can see that it contains 2 sub-collections.

{
	"totalItems": 2,
	"member": [
		{
			"@id": "urn:alpheios:latinLit",
			"@type": "Collection",
			"totalItems": 3,
			"title": "Classical Latin"
		},
		{
			"@id": "urn:alpheios:greekLit",
			"@type": "Collection",
			"totalItems": 4,
			"title": "Ancient Greek"
		}
	],
	"title": "None",
	"@id": "default",
	"@type": "Collection",
	"@context": {
		"dts": "https://w3id.org/dts/api#",
		"@vocab": "https://www.w3.org/ns/hydra/core#"
	}
}

Classical Latin

Specifying the id urn:alpheios:latinLit to narrow the collection to Classical Latin.

https://texts.alpheios.net/api/dts/collections?id=urn:alpheios:latinLit

We can see that it contains 3 sub-collections.

{
	"totalItems": 3,
	"member": [
		{
			"@id": "urn:cts:latinLit:phi0472",
			"@type": "Collection",
			"totalItems": 1,
			"title": "Catullus"
		},
		{
			"@id": "urn:cts:latinLit:phi0620",
			"@type": "Collection",
			"totalItems": 1,
			"title": "Propertius, Sextus"
		},
		{
			"@id": "urn:cts:latinLit:phi0959",
			"@type": "Collection",
			"totalItems": 1,
			"title": "Ovid"
		}
	],
	"title": "Classical Latin",
	"@id": "urn:alpheios:latinLit",
	"@type": "Collection",
	"@context": {
		"dts": "https://w3id.org/dts/api#",
		"@vocab": "https://www.w3.org/ns/hydra/core#",
		"ns1": "http://www.w3.org/2004/02/skos/core#"
	},
	"dts:extensions": {
		"ns1:prefLabel": [
			{
				"@value": "Classical Latin",
				"@language": "eng"
			}
		]
	}
}

Catullus

Specifying the id urn:cts:latinLit:phi0472 to narrow the collection to Catullus.

https://texts.alpheios.net/api/dts/collections?id=urn:cts:latinLit:phi0472

We can see that it contains 1 sub-collection.

{
	"totalItems": 1,
	"member": [
		{
			"@id": "urn:cts:latinLit:phi0472.phi001",
			"@type": "Collection",
			"totalItems": 1,
			"title": "Carmina"
		}
	],
	"title": "Catullus",
	"@id": "urn:cts:latinLit:phi0472",
	"@type": "Collection",
	"@context": {
		"dts": "https://w3id.org/dts/api#",
		"cts": "http://chs.harvard.edu/xmlns/cts/",
		"ns1": "http://www.w3.org/2004/02/skos/core#",
		"@vocab": "https://www.w3.org/ns/hydra/core#"
	},
	"dts:extensions": {
		"cts:groupname": [
			{
				"@value": "Catullus",
				"@language": "eng"
			}
		],
		"ns1:prefLabel": [
			{
				"@value": "Catullus",
				"@language": "eng"
			}
		]
	}
}

Carmina

Specifying the id urn:cts:latinLit:phi0472.phi001 to narrow the collection to Carmina.

https://texts.alpheios.net/api/dts/collections?id=urn:cts:latinLit:phi0472.phi001

Unlike previous results, we can see that member contains data of Resource type.

{
	"totalItems": 1,
	"member": [
		{
			"totalItems": 0,
			"dts:citeStructure": {
				"dts:citeType": "poem",
				"dts:citeStructure": [
					{
						"dts:citeType": "line"
					}
				]
			},
			"dts:extensions": {
				"cts:label": [
					{
						"@value": "Carmina",
						"@language": "lat"
					}
				],
				"ns2:language": "lat",
				"ns1:prefLabel": [
					{
						"@value": "Carmina",
						"@language": "lat"
					}
				],
				"cts:description": [
					{
						"@value": "Catullus, Gaius Valerius, creator; Merrill, Elmer Truesdell, 1860-1936, editor",
						"@language": "eng"
					}
				]
			},
			"dts:passage": "/api/dts/document?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1",
			"title": "Carmina",
			"@id": "urn:cts:latinLit:phi0472.phi001.alpheios-text-lat1",
			"@type": "Resource",
			"dts:references": "/api/dts/navigation?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1",
			"dts:citeDepth": 2
		}
	],
	"title": "Carmina",
	"@id": "urn:cts:latinLit:phi0472.phi001",
	"@type": "Collection",
	"@context": {
		"dts": "https://w3id.org/dts/api#",
		"cts": "http://chs.harvard.edu/xmlns/cts/",
		"ns1": "http://www.w3.org/2004/02/skos/core#",
		"@vocab": "https://www.w3.org/ns/hydra/core#",
		"ns2": "http://purl.org/dc/elements/1.1/"
	},
	"dts:extensions": {
		"cts:title": [
			{
				"@value": "Carmina",
				"@language": "lat"
			}
		],
		"ns2:language": "lat",
		"ns1:prefLabel": [
			{
				"@value": "Carmina",
				"@language": "lat"
			}
		]
	}
}

Also, the URL to the Document Endpoint can be found in dts:passage, and the URL to the Navigation Endpoint can be found in dts:references.

Top

Access the Navigation Endpoint URL obtained earlier.

https://texts.alpheios.net/api/dts/navigation?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1

{
	"passage": "/api/dts/document?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1{&ref}{&start}{&end}",
	"level": 1,
	"citeType": "poem",
	"@id": "/api/dts/navigation?level=1&id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1&groupBy=1",
	"citeDepth": 2,
	"@context": {
		"hydra": "https://www.w3.org/ns/hydra/core#",
		"@vocab": "https://w3id.org/dts/api#"
	},
	"hydra:member": [
		{
			"ref": "1"
		},
		{
			"ref": "2"
		},
		{
			"ref": "3"
		},
		{
			"ref": "4"
		},
		{
			"ref": "5"
		},
		{
			"ref": "6"
		},
		{
			"ref": "7"
		},
		{
			"ref": "8"
		},
		{
			"ref": "9"
		},
		{
			"ref": "10"
		},
		{
			"ref": "11"
		},
		{
			"ref": "12"
		},
		{
			"ref": "13"
		},
		{
			"ref": "14"
		},
		{
			"ref": "14b"
		},
		{
			"ref": "15"
		},
		{
			"ref": "16"
		},
		{
			"ref": "17"
		},
		{
			"ref": "21"
		},
		{
			"ref": "22"
		},
		{
			"ref": "23"
		},
		{
			"ref": "24"
		},
		{
			"ref": "25"
		},
		{
			"ref": "26"
		},
		{
			"ref": "27"
		},
		{
			"ref": "28"
		},
		{
			"ref": "29"
		},
		{
			"ref": "30"
		},
		{
			"ref": "31"
		},
		{
			"ref": "32"
		},
		{
			"ref": "33"
		},
		{
			"ref": "34"
		},
		{
			"ref": "35"
		},
		{
			"ref": "36"
		},
		{
			"ref": "37"
		},
		{
			"ref": "38"
		},
		{
			"ref": "39"
		},
		{
			"ref": "40"
		},
		{
			"ref": "41"
		},
		{
			"ref": "42"
		},
		{
			"ref": "43"
		},
		{
			"ref": "44"
		},
		{
			"ref": "45"
		},
		{
			"ref": "46"
		},
		{
			"ref": "47"
		},
		{
			"ref": "48"
		},
		{
			"ref": "49"
		},
		{
			"ref": "50"
		},
		{
			"ref": "51"
		},
		{
			"ref": "52"
		},
		{
			"ref": "53"
		},
		{
			"ref": "54"
		},
		{
			"ref": "55"
		},
		{
			"ref": "56"
		},
		{
			"ref": "57"
		},
		{
			"ref": "58"
		},
		{
			"ref": "58b"
		},
		{
			"ref": "59"
		},
		{
			"ref": "60"
		},
		{
			"ref": "61"
		},
		{
			"ref": "62"
		},
		{
			"ref": "63"
		},
		{
			"ref": "64"
		},
		{
			"ref": "65"
		},
		{
			"ref": "66"
		},
		{
			"ref": "67"
		},
		{
			"ref": "68a"
		},
		{
			"ref": "68b"
		},
		{
			"ref": "69"
		},
		{
			"ref": "70"
		},
		{
			"ref": "71"
		},
		{
			"ref": "72"
		},
		{
			"ref": "73"
		},
		{
			"ref": "74"
		},
		{
			"ref": "75"
		},
		{
			"ref": "76"
		},
		{
			"ref": "77"
		},
		{
			"ref": "78"
		},
		{
			"ref": "78b"
		},
		{
			"ref": "79"
		},
		{
			"ref": "80"
		},
		{
			"ref": "81"
		},
		{
			"ref": "82"
		},
		{
			"ref": "83"
		},
		{
			"ref": "84"
		},
		{
			"ref": "85"
		},
		{
			"ref": "86"
		},
		{
			"ref": "87"
		},
		{
			"ref": "88"
		},
		{
			"ref": "89"
		},
		{
			"ref": "90"
		},
		{
			"ref": "91"
		},
		{
			"ref": "92"
		},
		{
			"ref": "93"
		},
		{
			"ref": "94"
		},
		{
			"ref": "95"
		},
		{
			"ref": "96"
		},
		{
			"ref": "97"
		},
		{
			"ref": "98"
		},
		{
			"ref": "99"
		},
		{
			"ref": "100"
		},
		{
			"ref": "101"
		},
		{
			"ref": "102"
		},
		{
			"ref": "103"
		},
		{
			"ref": "104"
		},
		{
			"ref": "105"
		},
		{
			"ref": "106"
		},
		{
			"ref": "107"
		},
		{
			"ref": "108"
		},
		{
			"ref": "109"
		},
		{
			"ref": "110"
		},
		{
			"ref": "111"
		},
		{
			"ref": "112"
		},
		{
			"ref": "113"
		},
		{
			"ref": "114"
		},
		{
			"ref": "115"
		},
		{
			"ref": "116"
		}
	]
}

Specifying the ref Parameter

Based on the results obtained, let’s try adding &ref=1 as follows.

https://texts.alpheios.net/api/dts/navigation?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1&ref=1

The following result was obtained.

{
	"passage": "/api/dts/document?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1{&ref}{&start}{&end}",
	"level": 2,
	"citeType": "line",
	"@id": "/api/dts/navigation?ref=1&level=1&id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1&groupBy=1",
	"citeDepth": 2,
	"@context": {
		"hydra": "https://www.w3.org/ns/hydra/core#",
		"@vocab": "https://w3id.org/dts/api#"
	},
	"hydra:member": [
		{
			"ref": "1.1"
		},
		{
			"ref": "1.2"
		},
		{
			"ref": "1.3"
		},
		{
			"ref": "1.4"
		},
		{
			"ref": "1.5"
		},
		{
			"ref": "1.6"
		},
		{
			"ref": "1.7"
		},
		{
			"ref": "1.8"
		},
		{
			"ref": "1.9"
		},
		{
			"ref": "1.10"
		}
	]
}

InvalidLevel

Since citeDepth is 2, it should not be possible to navigate further down the hierarchy.

To confirm, let’s access the following.

https://texts.alpheios.net/api/dts/navigation?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1&ref=1.1

As a result, the following error was returned.

{
	"statusCode": 404,
	"@type": "Status",
	"@context": "http://www.w3.org/ns/hydra/context.jsonld",
	"description": " Invalid value for level parameter in Navigation Endpoint request ",
	"title": "InvalidLevel"
}

Document Endpoint

Top

Let’s access the following URL obtained from the Collection Endpoint.

https://texts.alpheios.net/api/dts/document?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1

As a result, the entire TEI/XML was retrieved.

<TEI xmlns="http://www.tei-c.org/ns/1.0">
  <script />
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>Carmina</title>
        <title type="sub">Machine readable text</title>
        <author>C. Valerius Catullus</author>
        <editor role="editor">E. T. Merrill</editor>
        <sponsor>Perseus Project, Tufts University</sponsor>
        <principal>Gregory Crane</principal>
        <respStmt>
          <resp>Prepared under the supervision of</resp>
          <name>Bridget Almas</name>
          <name>Lisa Cerrato</name>
          <name>William Merrill</name>
          <name>David Smith</name>
        </respStmt>
        <funder n="org:NEH">The National Endowment for the Humanities</funder>
      </titleStmt>
      <extent>about 112Kb</extent>
      <publicationStmt>
        <publisher>Trustees of Tufts University</publisher>
        <pubPlace>Medford, MA</pubPlace>
        <authority>Perseus Project</authority>
        <date type="release">1997-10-28</date>
      </publicationStmt>
      <sourceDesc>
        <biblStruct>
          <monogr>
            <author>Catullus</author>
            <title>Catullus</title>
            <editor role="editor">Elmer Truesdell Merrill</editor>
            <imprint>
              <pubPlace>Boston</pubPlace>
              <publisher>Ginn and Company</publisher>
              <date>1893</date>
            </imprint>
          </monogr>
        </biblStruct>
      </sourceDesc>
    </fileDesc>
    <encodingDesc>
      <refsDecl n="TEI.2">
        <refState unit="poem" />
        <refState unit="line" />
      </refsDecl>
      <refsDecl n="CTS">
        <cRefPattern n="line" matchPattern="(\w+).(\w+)" replacementPattern="#xpath(/tei:TEI/tei:text/tei:body/tei:div/tei:div/tei:div[@n='$1']//tei:l[@n='$2'])">
          <p>This pointer pattern extracts poem and line</p>
        </cRefPattern>
        <cRefPattern n="poem" matchPattern="(\w+)" replacementPattern="#xpath(/tei:TEI/tei:text/tei:body/tei:div/tei:div/tei:div[@n='$1'])">
          <p>This pointer pattern extracts poem</p>
        </cRefPattern>
      </refsDecl>
    </encodingDesc>
    <profileDesc>
      <langUsage>
        <language ident="lat">Latin </language>
        <language ident="eng">English </language>
      </langUsage>
    </profileDesc>
    <revisionDesc>
      <change when="2018-04-04" who="Thibault Clerice">Removing duplicates</change>
      <change when="2014-11-06" who="Thibault Clerice">Moving to Epidoc with new URN</change>
      <change when="2013-09-13" who="balmas01">moving Greg's work-in-progress on CTS-izing greco-roman collection texts to a Work directory</change>
        ...
    </revisionDesc>
  </teiHeader>
  <text>
    <body>
      <div type="edition" xml:lang="lat" n="urn:cts:latinLit:phi0472.phi001.perseus-lat2">
        <div type="textpart" subtype="Lyrics">
          <div type="textpart" subtype="poem" n="1">
            <milestone unit="meter" n="Phalaecean" />
            <head xml:lang="eng" rend="newlevel">1</head>
            <l n="1">Cui dono lepidum novum libellum</l>
            <l n="2">arido modo pumice expolitum?</l>
            <l n="3">Corneli, tibi; namque tu solebas</l>
            <l n="4">meas esse aliquid putare nugas,</l>
            <l n="5">iam tum cum ausus es unus Italorum</l>
            <l n="6">omne aevum tribus explicare chartis,</l>
            <l n="7">doctis, Iuppiter, et laboriosis!</l>
            <l n="8">quare habe tibi quidquid hoc libelli</l>
            <l n="9">qualecumque, quod, o patrona virgo,</l>
            <l n="10">plus uno maneat perenne saeclo.</l>
          </div>
          <div type="textpart" subtype="poem" n="2">
            <milestone unit="meter" n="Phalaecean" />
            <head xml:lang="eng" rend="newlevel">2</head>
            <l n="1">Passer, deliciae meae puellae,</l>
            <l n="2">quicum ludere, quem in sinu tenere,</l>
            <l n="3">cui primum digitum dare adpetenti</l>
            <l n="4">et acris solet incitare morsus,</l>
            ...
          </div>
        </div>
      </div>
    </body>
  </text>
</TEI>

Specifying the ref Parameter

Using the ref 1 obtained from the Navigation Endpoint, let’s access the following.

https://texts.alpheios.net/api/dts/document?id=urn%3Acts%3AlatinLit%3Aphi0472.phi001.alpheios-text-lat1&ref=1

As a result, the following was obtained. A partial text with subtype poem and n 1 was retrieved. For partial texts, it appears that <dts:fragment xmlns:dts="https://w3id.org/dts/api#"> is used.

<TEI xmlns="http://www.tei-c.org/ns/1.0" xmlns:py="http://codespeak.net/lxml/objectify/pytype" py:pytype="TREE">
  <dts:fragment xmlns:dts="https://w3id.org/dts/api#">
    <text>
      <body>
        <div type="edition" xml:lang="lat" n="urn:cts:latinLit:phi0472.phi001.perseus-lat2">
          <div type="textpart" subtype="Lyrics">
            <div type="textpart" subtype="poem" n="1">
              <milestone unit="meter" n="Phalaecean" />
              <head xml:lang="eng" rend="newlevel">1</head>
              <l n="1">Cui dono lepidum novum libellum</l>
              <l n="2">arido modo pumice expolitum?</l>
              <l n="3">Corneli, tibi; namque tu solebas</l>
              <l n="4">meas esse aliquid putare nugas,</l>
              <l n="5">iam tum cum ausus es unus Italorum</l>
              <l n="6">omne aevum tribus explicare chartis,</l>
              <l n="7">doctis, Iuppiter, et laboriosis!</l>
              <l n="8">quare habe tibi quidquid hoc libelli</l>
              <l n="9">qualecumque, quod, o patrona virgo,</l>
              <l n="10">plus uno maneat perenne saeclo.</l>
            </div>
          </div>
        </div>
      </body>
    </text>
  </dts:fragment>
</TEI>

Summary

I confirmed an example of how to use the various DTS endpoints. I hope this serves as a helpful reference for understanding DTS.