Skip to content
Snippets Groups Projects
Commit 2dfcfc90 authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Add property inheritance to simplify st:module template

parent b4a729a7
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
### http://www.semanticweb.org/eliott/ontologies/2024/4/macao/contientSousPartie ### http://www.semanticweb.org/eliott/ontologies/2024/4/macao/contientSousPartie
:contientSousPartie rdf:type owl:ObjectProperty ; :contientSousPartie rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf :contient ; rdfs:subPropertyOf :contientModule ;
rdfs:domain :Module ; rdfs:domain :Module ;
rdfs:range :SousPartie . rdfs:range :SousPartie .
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
### http://www.semanticweb.org/eliott/ontologies/2024/4/macao/SousPartie ### http://www.semanticweb.org/eliott/ontologies/2024/4/macao/SousPartie
:SousPartie rdf:type owl:Class ; :SousPartie rdf:type owl:Class ;
rdfs:subClassOf :MacaoContenu . rdfs:subClassOf :Module .
################################################################# #################################################################
......
This diff is collapsed.
...@@ -51,6 +51,7 @@ def main(): ...@@ -51,6 +51,7 @@ def main():
""" """
construct_while(graph, q_transitive_subclass) construct_while(graph, q_transitive_subclass)
# Apply type inheritance (rdfs:subClassOf)
log.info("Adding supertypes...") log.info("Adding supertypes...")
construct_while( construct_while(
graph, graph,
...@@ -64,6 +65,21 @@ def main(): ...@@ -64,6 +65,21 @@ def main():
""", """,
) )
# Apply property inheritance (rdfs:subPropertyOf)
log.info("Adding super-properties...")
construct_while(
graph,
"""
CONSTRUCT {
?subj ?superprop ?obj
} WHERE {
?subj ?prop ?obj .
?prop rdfs:subPropertyOf ?superprop .
FILTER(?superprop != owl:topDataProperty)
}
""",
)
# ==> Save # ==> Save
# Remove dependency on previous ontologies # Remove dependency on previous ontologies
for ontology in graph.subjects(RDF.type, OWL.Ontology): for ontology in graph.subjects(RDF.type, OWL.Ontology):
......
...@@ -2,6 +2,8 @@ PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/> ...@@ -2,6 +2,8 @@ PREFIX : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/>
PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/> PREFIX mt: <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/template/>
PREFIX st: <http://ns.inria.fr/sparql-template/> PREFIX st: <http://ns.inria.fr/sparql-template/>
# Recursive template for Modules and SousParties (because SousParties are just
# leaf-level modules)
template mt:module(?mod) { template mt:module(?mod) {
mt:start_marker(?mod) "/_index.md" st:nl() mt:start_marker(?mod) "/_index.md" st:nl()
...@@ -12,13 +14,12 @@ template mt:module(?mod) { ...@@ -12,13 +14,12 @@ template mt:module(?mod) {
st:call-template(mt:activite, ?child_act) ; separator='' st:call-template(mt:activite, ?child_act) ; separator=''
} }
} where { } where {
{ ?mod a :Module } union { ?mod a :SousPartie } . ?mod a :Module
?mod :titre ?title .
optional { optional {
{ ?mod :contientModule ?child } union { ?mod :contientSousPartie ?child } ?mod :contientModule ?child
} }
optional { optional {
?mod a :SousPartie .
?mod :contientActivite ?child_act ?mod :contientActivite ?child_act
} }
} }
...@@ -9,7 +9,7 @@ template mt:path(?obj) { ...@@ -9,7 +9,7 @@ template mt:path(?obj) {
?obj a :MacaoContenu . ?obj a :MacaoContenu .
?obj :id ?id ?obj :id ?id
optional { optional {
{ ?parent :contientActivite ?obj } union {?parent :contientModule ?obj} union {?parent :contientSousPartie ?obj}. { ?parent :contientActivite ?obj } union {?parent :contientModule ?obj} .
bind(st:call-template(mt:path, ?parent) as ?rec) bind(st:call-template(mt:path, ?parent) as ?rec)
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment