semantic web - RDF - Distributing rdf:type to all items in the list -
consider following rdf:
semapi:baseclass rdfs:class; rdfs:subclassof rdfs:class . semapi:haschainto rdf:property; rdfs:domain semapi:baseclass; rdfs:range semapi:baseclass . semapi:derivedclass rdfs:class; rdfs:subclassof semapi:baseclass . instances:instance1 semapi:derivedclass; semapi:haschainto ( [ semapi:derivedclass; semapi:haschainto ( [c1] [c2] ) ] )
if semapi:haschainto rdfs:range semapi:baseclass
implies the list rdf:type semapi:baseclass
.
what mean each item in list rdf:type
(ei. [c1] rdf:type semapi:baseclass
, [c2] rdf:type semapi:baseclass
, ...)
how can this? need owl (preferably not)?
depending on how want this, have few options. think you're trying stick non-owl reasoning, we'll make sure include such solution, want touch on owl solution too, since similar situations, works well.
using owl , custom objectlist
if do have option of using owl reasoner, nice case in can create own list vocabulary , use property chains. idea introduce class list
individual nil
, , properties first
, rest
. you're copying vocabulary in own namespace. lets define 2 properties
likes
: relates individual x individual y; "x likes y".likeslist
: relates individual x list (not rdf list, though) of individuals x likes.
then can introduce 2 property chain axioms
likeslist subpropertychain likeslist o rest
: if x likeslist (_ ...), x likeslist (...).
this way, x likes (a b c)
x likes (a b c)
, x likes (b c)
, x likes (c)
, , x likes nil
.
likes subpropertychain likeslist o first
: if x likeslist (a ...), x likes a.
then, inferred statements above, x likes a
, x likes b
, , x likes c
.
in turtle, looks like:
@prefix : <http://www.example.org/distributing#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xsd: <http://www.w3.org/2001/xmlschema#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . <http://www.example.org/distributing> owl:ontology . :list owl:class . :nil :list , owl:namedindividual . :first owl:objectproperty . :rest owl:objectproperty . :likes owl:objectproperty ; owl:propertychainaxiom (:likeslist :first) . [] owl:axiom ; rdfs:comment "if x likeslist (a ...), x likes a." ; owl:annotatedproperty owl:propertychainaxiom ; owl:annotatedsource :likes ; owl:annotatedtarget (:likeslist :first) . :likeslist owl:objectproperty ; rdfs:comment "relates individual i1 objectlist of individuals i1 likes." ; owl:propertychainaxiom (:likeslist :rest) . [] owl:axiom ; rdfs:comment "if x likeslist (a b c), since (b c) rest of (a b c), x likeslist (b c), too." ; owl:annotatedproperty owl:propertychainaxiom ; owl:annotatedsource :likeslist ; owl:annotatedtarget (:likeslist :rest) .
this gets bit inconvenient if have write rdf manually, since have
x :likeslist [ :first ; :rest [ :first b ; :rest [ :first c ; :rest nil ] ] ] .
and can't use nice (...)
syntax turtle includes. doesn't case you've got, since owl classes aren't individuals, can't object of object properties, , rdf:type
isn't object property. wanted include because it's nice way object property distribute on (non-rdf) list of individuals, , because approach makes following solutions clearer.
using sparql queries
given data like:
@prefix : <urn:ex:> . :x :plist (:a :b :c :d) .
a sparql query
prefix : <http://example.org/> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> construct { ?x :p ?y } { ?x :plist/rdf:rest*/rdf:first ?y }
produces
@prefix : <http://example.org/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . :x :p :a ; :p :c ; :p :b ; :p :d .
in imitation of the owl based approach above, used 2 properties plist
, p
, same, in case p
"distributed" on list.
with datastore somewhere, should able sparql update using insert/where
:
prefix : <http://example.org/> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> insert { ?x :p ?y } { ?x :plist/rdf:rest*/rdf:first ?y }
to add data store.
using prolog syntax
if want reasoning performed reasoner, you'll in domain of reasoner specific stuff. however, lots of reasoners support prolog-like query language, , can write these rules there, too. don't know allegograph's rdfs++ syntax, general structure include definitions like:
?x p ?y :- ?x plist ?list, ?list rdf:first ?y ?x plist ?l :- ?x plist ?list, ?list rdf:rest ?l
Comments
Post a Comment