-
Notifications
You must be signed in to change notification settings - Fork 2
/
searchDocumentBySubConceptAgrovoc.sparql
44 lines (40 loc) · 2.13 KB
/
searchDocumentBySubConceptAgrovoc.sparql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
PREFIX agron: <http://aims.fao.org/aos/agrontology#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dce: <http://purl.org/dc/elements/1.1/>
PREFIX oa: <http://www.w3.org/ns/oa#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX schema: <http://schema.org/>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>
# This query retrieves the documents that are annotated with Agrovoc concept {id} or any of its sub-concepts.
# It keeps track of the actual concepts matched (concatenated in ?matchedEntities), these may contain either {id} itself of its sub-concepts.
SELECT ?document ?title ?date ?publisher ?lang ?linkPDF (group_concat(distinct ?author, "$") as ?authors) (group_concat(distinct ?matchedEntity, "$$") as ?matchedEntities)
FROM <http://data-issa.cirad.fr/graph/documents>
FROM <http://data-issa.cirad.fr/graph/thematic-descriptors> # annotations about the Agrovoc descriptors
FROM <http://data-issa.cirad.fr/graph/annif-descriptors> # annotations about the Agrovoc descriptors
FROM <http://agrovoc.fao.org/graph> # Agrovoc graph itself
WHERE {
?document a prov:Entity.
OPTIONAL { ?document dct:title ?title.}
OPTIONAL { ?document dce:creator ?author.}
OPTIONAL { ?document dct:issued ?date.}
OPTIONAL { ?document schema:publication ?publisher.}
OPTIONAL { ?document dce:language ?lang.}
OPTIONAL { ?document schema:downloadUrl ?linkPDF. }
{ # Match of {id} isfelf
?document ^oa:hasTarget [ oa:hasBody <{id}> ].
<{id}>
skosxl:prefLabel/skosxl:literalForm ?entityLabel.
FILTER langMatches(lang(?entityLabel), "en")
BIND(concat("{id}", "$", ?entityLabel, "$", "Agrovoc") as ?matchedEntity)
}
UNION
{ # Match of a descendant of {id}
?document ^oa:hasTarget [ oa:hasBody ?entityUri ].
?entityUri
(skos:broader|^agron:includes)+ <{id}>;
skosxl:prefLabel/skosxl:literalForm ?entityLabel.
FILTER langMatches(lang(?entityLabel), "en")
BIND(concat(?entityUri, "$", ?entityLabel, "$", "Agrovoc") as ?matchedEntity)
}
} group by ?document ?title ?date ?publisher ?lang ?linkPDF
limit 20000