Skip to content

Instantly share code, notes, and snippets.

@e-maud
Last active April 7, 2017 07:51
Show Gist options
  • Save e-maud/955c6747ee22a733eb1ee20843047b56 to your computer and use it in GitHub Desktop.
Save e-maud/955c6747ee22a733eb1ee20843047b56 to your computer and use it in GitHub Desktop.

1. Given a person (uri of person), get its mentions in various documents/images

SELECT ?mention ?contract STR(?boxNumber)AS ?box STR(?regNumber) AS ?reg ?pageNumber ?pageSide ?iiif ?viewer
WHERE
{
  <http://localhost:8080/garzoni-data/Zuan_Antonio_Bertan_30435> ^grz-owl:refers_to/grz-owl:is_entityLink_of ?mention .
  ?mention grz-owl:introduced_in ?contract.
  ?contract grz-owl:appears_on ?page .
  ?page grz-owl:number ?pageNumber.
  ?page grz-owl:pageSide ?pageSide .
  ?page grz-owl:imaged_By ?image .
  ?image grz-owl:iiif ?iiif.
  ?image grz-owl:viewer ?viewer.
  ?contract grz-owl:signature ?signature .
  ?signature grz-owl:hasArchiveComponent ?box, ?reg.
  ?box a grz-owl:Box .
  ?box grz-owl:number ?boxNumber.
  ?reg a grz-owl:Register .
  ?reg grz-owl:number ?regNumber.
}

2. Select person entities within time windows

SELECT ?p ?label
WHERE 
{
  ?p a grz-owl:Person . 
  ?p rdfs:label ?label .
  ?p ^grz-owl:refers_to/grz-owl:is_entityLink_of/grz-owl:introduced_in/sem:hasTimeStamp ?date.
  FILTER (year(?date) > 1600 AND year(?date) < 1625)
}

3. Select location mentions - this gives all existing "labels" of place mentions

(only mentions for now. from workshop locations, charge locations, residences and geoOrigins)

SELECT ?place STR(?wf) ?par ?ses
WHERE 
{
  ?place a grz-owl:PlaceMention . 
  ?place grz-owl:introduced_in/sem:hasTimeStamp ?date .
  OPTIONAL {?place grz-owl:writtenForm ?wf .}
  OPTIONAL {?place grz-owl:parish ?par .}
  OPTIONAL {?place grz-owl:sestriere ?ses .}
  FILTER (year(?date) > 1600 AND year(?date) < 1625)
  }

4. SOLR : Export transcriptions GRZ for Solr

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX grz-owl: <http://localhost:8080/garzoni/ontology#>
PREFIX sem: <http://semanticweb.cs.vu.nl/2009/11/sem/>

SELECT  ?uuid
?number_reg
?start_year
?start_month
?start_day
?end_year
?end_month
?end_day
?page ?page_number ?page_side (group_concat(?label;separator=" | ") as ?labels)

WHERE
{
?page a grz-owl:Page .
?page ^grz-owl:appears_on ?contract .
?page grz-owl:number ?page_number.
?page grz-owl:pageSide ?page_side .

?page grz-owl:in_Register ?reg .
?reg grz-owl:number ?nbReg .
?reg grz-owl:uuid ?uid .
?reg sem:hasBeginTimeStamp ?dateStart .
?reg sem:hasEndTimeStamp ?dateEnd .

?contract a grz-owl:Contract .
?contract grz-owl:introduces ?pm .
?pm a grz-owl:PersonMention .
?pm grz-owl:name/rdfs:label ?label .

BIND (STR(?uid) AS ?uuid)
BIND (year(?dateStart) AS ?start_year)
BIND (month(?dateStart) AS ?start_month)
BIND (day(?dateStart) AS ?start_day)

BIND (year(?dateEnd) AS ?end_year)
BIND (month(?dateEnd) AS ?end_month)
BIND (day(?dateEnd) AS ?end_day)
BIND (STR(?nbReg) AS ?number_reg)
}

GROUP BY ?page ?page_number ?page_side ?dateStart ?dateEnd ?number_reg ?uuid ?start_year ?start_month ?start_day  ?end_year ?end_month ?end_day
ORDER BY ?number_reg ?page_number

5. SOLR : get uuid of registers

SELECT ?reg STR(?nbReg) AS ?reg_number STR(?uuid) AS ?reg_uuid
WHERE
{
  ?reg a grz-owl:Register .
  ?reg grz-owl:number ?nbReg .
  ?reg grz-owl:uuid ?uuid .
}

6. Given a reg uuid and a page (nb and side), get iif and viewer infos

SELECT ?reg ?viewer ?iiif
WHERE
{
  ?reg a grz-owl:Register.
  ?reg grz-owl:uuid "63bd9c32-34ae-4d1f-8903-ffbeb513e50a"^^xsd:string .
  ?reg grz-owl:has_folia ?page .
  ?page grz-owl:number '023' .
  ?page grz-owl:pageSide 'r' .
  ?page grz-owl:imaged_By/grz-owl:iiif ?iiif .
  ?page grz-owl:imaged_By/grz-owl:viewer ?viewer .
}

7. SOLR: Export transcriptions Xsavi for solr

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX grz-owl: <http://onto.archives.world/garzoni#>
PREFIX sem: <http://semanticweb.cs.vu.nl/2009/11/sem/>
PREFIX dhc: <http://onto.archives.world/dhcanvas#>
PREFIX vtm-owl: <http://onto.archives.world/vtm#>
PREFIX oa: <http://www.w3.org/ns/oa#>
PREFIX xsavi: <http://localhost:8080/xsavi-data/>

SELECT (group_concat(?trans;separator=" | ") as ?transcription) ?id_canvas ?manifest_uuid ?manifest_number ?manifest_subnumber ?start_date ?end_date
WHERE
{
	?pm a vtm-owl:PersonMention .
	?pm rdfs:label ?trans .
	?pm vtm-owl:segment ?segment .
	?segment dhc:on ?canvas .
	?segment dhc:bounding_box ?bounding_box .
	?canvas dhc:canvas_id ?canvas_id .
	?canvas dhc:in ?manifest .
	?manifest dhc:uuid ?manifest_uuid .
	?manifest vtm-owl:unit_number ?number .
	?manifest vtm-owl:unit_subNumber ?subnumber .
	OPTIONAL {?manifest vtm-owl:start_date ?start . BIND (STR(?start) AS ?start_date)}
	OPTIONAL {?manifest vtm-owl:start_date ?end . BIND (STR(?end) AS ?end_date)}
	BIND (STR(?canvas_id) AS ?id_canvas)
	BIND (STR(?number) AS ?manifest_number)
	BIND (STR(?subnumber) AS ?manifest_subnumber)
}
GROUP BY ?id_canvas  ?start_date ?end_date ?manifest_uuid ?manifest_number ?manifest_subnumber
ORDER BY ?manifest_number ?manifest_subnumber ?id_canvas

8. SOLR Given a person transcription and a manifest uuid, get the bouding box

SELECT ?bounding_box
WHERE
{
    ?pm a vtm-owl:PersonMention .
    ?pm rdfs:label "ser Antonio Valmarana" .
    ?pm vtm-owl:segment ?segment .
    ?segment dhc:on ?canvas .
    ?segment dhc:bounding_box ?bounding_box .
    ?canvas dhc:canvas_id ?canvas_id .
    ?canvas dhc:in ?manifest .
    ?manifest dhc:uuid "06824801-5ad2-4fcf-90d4-ad0ce5c39f35" .
}

9. SOLR Get all canvas (or pages) of a manifest (or doc) in page number order

SELECT ?manifest ?canvas ?sn
WHERE
{
	?manifest a sc:Manifest .
	?manifest dhc:uuid "e400dfaa-888a-4c25-b7ac-6b084abd510d" .
	?manifest dhc:canvas ?canvas .
	?canvas dhc:sequence_number ?sn.
}
ORDER BY (?sn)

10. Query Sofia pour transcriptions, boxes, canvas and manifest uuid

SELECT ?segment ?uuid STR(?canvasID) AS ?canvasID  ?box ?transcription
WHERE
{
    ?annotation a oa:Annotation .
    ?annotation oa:hasBody ?body .
    ?body a  <http://www.w3.org/ns/oa#TextualBody> .
    ?body oa:text ?transcription .
    ?annotation oa:hasTarget ?segment .
    ?annotation oa:motivatedBy "sc:painting"  .
    ?segment a dhc:CanvasSegment .
    ?segment dhc:bounding_box ?box .
    ?segment dhc:on ?canvas .
    ?canvas dhc:canvas_id ?canvasID .
    ?canvas a dhc:Canvas .
    ?canvas dhc:uuid ?uuid .
}
LIMIT 50

11. Query Sofia pour récupérer toutes les transcriptions étant donnés un document et des pages spécifiques

SELECT str(?canvasID) AS ?canvasID  (group_concat(?transcription;separator=" | ") as ?trans)
WHERE
{
    ?manifest a <http://www.shared-canvas.org/ns/Manifest>  .
    ?manifest dhc:uuid "d4035d23-561d-410f-a629-7f3e51a9896f" .
    ?manifest dhc:canvas ?canvas .
    ?canvas dhc:canvas_id ?canvasID.
    ?canvas ^dhc:on ?segment .
    ?segment a dhc:CanvasSegment .
    ?segment ^oa:hasTarget ?anno.
    ?anno oa:hasBody ?body .
    ?body a  <http://www.w3.org/ns/oa#TextualBody> .
    ?body oa:text ?transcription .
    ?anno oa:motivatedBy "sc:painting"  .
    VALUES (?canvasID) {  (10)}  
}
GROUP BY ?canvasID ?manifest ?canvas

12. Query point on Catastici data

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX grz-owl: <http://onto.archives.world/garzoni#>
PREFIX sem: <http://semanticweb.cs.vu.nl/2009/11/sem/>
PREFIX dhc: <http://onto.archives.world/dhcanvas#>
PREFIX vtm-owl: <http://onto.archives.world/vtm#>
PREFIX oa: <http://www.w3.org/ns/oa#>
PREFIX xsavi: <http://localhost:8080/xsavi-data/>

SELECT ?au 
WHERE
{
?au a vtm-owl:ArchivalUnit .
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment