Skip to content

SKOS view and query improvements #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions demo/skos/admin/model/collection-template.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@prefix : <#> .
@prefix ldh: <https://w3id.org/atomgraph/linkeddatahub#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sp: <http://spinrdf.org/sp#> .
@prefix spin: <http://spinrdf.org/spin#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

skos:Collection ldh:template <../../../ns#CollectionMembers>.

<../../../ns#CollectionMembers> a ldh:View ;
dct:title "Collection members" ;
spin:query <../../../ns#SelectCollectionMembers> ;
rdfs:isDefinedBy <../../../ns#> .

<../../../ns#SelectCollectionMembers> a sp:Select ;
rdfs:label "Select collection members" ;
sp:text """
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?member
WHERE
{ GRAPH ?graph
{ $about skos:member ?member .
GRAPH ?memberGraph
{
?member skos:prefLabel ?prefLabel .
FILTER (langMatches(lang(?prefLabel), "en"))
}
}
}
ORDER BY ?prefLabel
""" ;
rdfs:isDefinedBy <../../../ns#> .
31 changes: 31 additions & 0 deletions demo/skos/admin/model/concept-scheme-template.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@prefix : <#> .
@prefix ldh: <https://w3id.org/atomgraph/linkeddatahub#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sp: <http://spinrdf.org/sp#> .
@prefix spin: <http://spinrdf.org/spin#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

skos:ConceptScheme ldh:template <../../../ns#ConceptsInScheme>.

<../../../ns#ConceptsInScheme> a ldh:View ;
dct:title "Concepts in scheme" ;
spin:query <../../../ns#SelectConceptsInScheme> ;
rdfs:isDefinedBy <../../../ns#> .

<../../../ns#SelectConceptsInScheme> a sp:Select ;
rdfs:label "Select concepts in scheme" ;
sp:text """
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?concept
WHERE
{ GRAPH ?graph
{ ?concept skos:inScheme $about ;
skos:prefLabel ?prefLabel .
FILTER (langMatches(lang(?prefLabel), "en"))
}
}
ORDER BY ?prefLabel
""" ;
rdfs:isDefinedBy <../../../ns#> .
24 changes: 19 additions & 5 deletions demo/skos/admin/model/concept-template.ttl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@prefix : <#> .
@prefix ldh: <https://w3id.org/atomgraph/linkeddatahub#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sp: <http://spinrdf.org/sp#> .
@prefix sp: <http://spinrdf.org/sp#> .
@prefix spin: <http://spinrdf.org/spin#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
Expand All @@ -22,9 +22,16 @@ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?narrower
WHERE
{ GRAPH ?narrowerGraph
{ $about skos:narrower ?narrower }
{ GRAPH ?graph
{ $about skos:narrower ?narrower .
GRAPH ?narrowerGraph
{
?narrower skos:prefLabel ?prefLabel .
FILTER (langMatches(lang(?prefLabel), "en"))
}
}
}
ORDER BY ?prefLabel
""" ;
rdfs:isDefinedBy <../../../ns#> .

Expand All @@ -44,9 +51,16 @@ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT DISTINCT ?broader
WHERE
{ GRAPH ?broaderGraph
{ $about skos:broader ?broader }
{ GRAPH ?graph
{ $about skos:broader ?broader .
GRAPH ?broaderGraph
{
?broader skos:prefLabel ?prefLabel .
FILTER (langMatches(lang(?prefLabel), "en"))
}
}
}
ORDER BY ?prefLabel
""" ;
rdfs:isDefinedBy <../../../ns#> .

19 changes: 19 additions & 0 deletions demo/skos/admin/model/patch-ontology.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

DELETE {
?s ?p ?o
}
WHERE {
?s ?p ?o
# Exclude triples about the main resource itself
MINUS {
<> ?p ?o
BIND(<> AS ?s)
}
# Exclude triples about the foaf:primaryTopic resource
MINUS {
<> foaf:primaryTopic ?primaryTopic .
?primaryTopic ?p ?o
BIND(?primaryTopic AS ?s)
}
}
23 changes: 23 additions & 0 deletions demo/skos/admin/model/post-class-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,33 @@ else
proxy="$base"
fi

# clear the old contents of the namespace ontology

{ echo "BASE <${base}admin/ontologies/namespace/>"; cat patch-ontology.ru; } | patch.sh \
-f "$cert_pem_file" \
-p "$cert_password" \
--proxy "$proxy" \
"${base}admin/ontologies/namespace/"

# append the new class templates to the namespace ontology

cat concept-template.ttl | post.sh \
-f "$cert_pem_file" \
-p "$cert_password" \
--proxy "$proxy" \
--content-type "text/turtle" \
"${base}admin/ontologies/namespace/"

cat collection-template.ttl | post.sh \
-f "$cert_pem_file" \
-p "$cert_password" \
--proxy "$proxy" \
--content-type "text/turtle" \
"${base}admin/ontologies/namespace/"

cat concept-scheme-template.ttl | post.sh \
-f "$cert_pem_file" \
-p "$cert_password" \
--proxy "$proxy" \
--content-type "text/turtle" \
"${base}admin/ontologies/namespace/"
5 changes: 3 additions & 2 deletions demo/skos/queries/select-collections.rq
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?concept ?doc
SELECT DISTINCT ?collection ?doc
WHERE
{ GRAPH ?doc
{ ?concept
{ ?collection
a skos:Collection ;
skos:prefLabel ?prefLabel
FILTER (langMatches(lang(?prefLabel), "en"))
}
}
ORDER BY ?prefLabel
1 change: 1 addition & 0 deletions demo/skos/queries/select-concepts.rq
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ WHERE
{ ?concept
a skos:Concept ;
skos:prefLabel ?prefLabel
FILTER (langMatches(lang(?prefLabel), "en"))
}
}
ORDER BY ?prefLabel
1 change: 1 addition & 0 deletions demo/skos/queries/skos-import.rq
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ WHERE
BIND(URI(concat(str(?subjItem), "#this")) AS ?newSubj)

?s ?p ?o
FILTER (?p != skos:hasTopConcept) # we'll display these relations using a view

OPTIONAL
{
Expand Down