- From: Phil Archer <parcher@icra.org>
- Date: Mon, 26 Nov 2007 15:45:27 +0000
- To: Public POWDER <public-powderwg@w3.org>
Following on from the discussion on this list today, I thought I'd try and do some more due diligence by running some tests against some sample data. I've created a data instance at [1] which, for those like me who prefer graphs to angle brackets, is graphed at [2] (and generating this graph is evidence that it's valid RDF!). For good measure, I put the data into Protégé - no problem there, it loads OK [3]. However, the (Pellet) reasoner, didn't return a result. It got as far as warning that it didn't understand foaf:Document (which isn't in my test data but is in the FOAF vocabulary) and got no further. I wanted to see whether it would infer at least that the properties of 'ResourceSafeForChildren' were inherited by 'ResourceOnExampleDotOrg' - well, not this time. I wondered about possible reasons for this - and the truth is I don't know why, especially as earlier experiments with Protégé worked fine - but my guess is that it's tied up with the fact that in the earlier experiments I defined the datatype property wdr:includeHost within the Protégé project. I need to play with this some more. After loading Protégé I did make one change to the data instance though. I think the 'ResourceOnExampleDotOrg' class should be defined using 'necessary and sufficient' structures rather than just necessary. The data in [1] says that any instance of the class will be available from the example.org host. However, it doesn't say that anything on that host is an instance of the class which is what we actually want it to say so you have to add a bit of extra code to make this true - I call this example3a [4], graphed at [5]. Note the 'equivalent Class' property in the revised ResourceOnExampleDotOrg class: <owl:Class rdf:ID="ResourceOnExampleDotOrg"> <owl:equivalentClass> <owl:Class> <rdfs:subClassOf> <owl:Restriction> <owl:onProperty rdf:resource="http://www.w3.org/2007/05/powder#includeHost" /> <owl:hasValue>example.org</owl:hasValue> </owl:Restriction> </rdfs:subClassOf> </owl:Class> </owl:equivalentClass> </owl:Class> OK, let's try and get some data out of this. I'm hoping that Andrea and Stasinos will be able to write some rules that can use the data but my approach is to use SPARQL to get the data out and then I can process it using Boolean logic. Using [4] as my data source... Query 1 ======= PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX wdr: <http://www.w3.org/2007/05/powder#> SELECT DISTINCT ?x WHERE { ?x rdfs:subClassOf <http://www.fosi.org/archive/powder/example3a.owl#ResourceSafeForChildren> . } This assumes I know that I'm looking for all the sub classes of a known class, in this case 'resourceSafeForChildren'. Unsurprisingly, it returns the single result: http://www.fosi.org/archive/powder/example3a.owl#ResourceOnExampleDotOrg (see [6]). I could then parse the ResourceOnExampleDotOrg to see what it meant. Query 2 ======= Let's assume I know a little less. I know the structure of a DR (of course) and I can assume that the 'Resource Set' has necessary and sufficient conditions and therefore we need to take into account the equivalent class construct. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX wdr: <http://www.w3.org/2007/05/powder#> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT DISTINCT ?x ?description ?prop ?value WHERE { ?x owl:equivalentClass ?y . ?y rdfs:subClassOf ?restriction . ?restriction owl:onProperty ?prop . ?restriction owl:hasValue ?value . ?x rdfs:subClassOf ?description } Run against example 3a we get this: x: http://www.fosi.org/archive/powder/example3a.owl#ResourceOnExampleDotOrg description: http://www.fosi.org/archive/powder/example3a.owl#ResourceSafeForChildren prop: http://www.w3.org/2007/05/powder#includeHost value: example.org So far so good, but this is a very simple example. What if we make like a little more complicated? Example 3b [7, graphed at 8] is the same as 3a but with a slightly extended Resource Set thus: <owl:Class rdf:ID="ResourceOnExampleDotOrg"> <owl:equivalentClass> <owl:Class> <owl:intersectionOf rdf:parseType="Collection"> <owl:Restriction> <owl:onProperty rdf:resource="http://www.w3.org/2007/05/powder#includeHost" /> <owl:hasValue>example.org</owl:hasValue> </owl:Restriction> <owl:Restriction> <owl:onProperty rdf:resource="http://www.w3.org/2007/05/powder#pathStartsWith" /> <owl:hasValue>foo</owl:hasValue> </owl:Restriction> </owl:intersectionOf> </owl:Class> </owl:equivalentClass> </owl:Class> That is, everything on example.com with a path starting with foo. Query 2 yields no information at all since now the includeHost and pathStartsWith data is a level down due to the Collection. We need to keep what we've got on an optional query and see what else we can do. Query 3 ======= PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX wdr: <http://www.w3.org/2007/05/powder#> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT DISTINCT ?x ?prop ?value ?description WHERE { ?x owl:equivalentClass ?y . ?y owl:intersectionOf ?bn . ?bn rdf:first ?restriction . ?restriction ?prop ?value . ?x rdfs:subClassOf ?description } This is the query needed to run against a Resource Set that has a Collection. It yields some of the information needed - it tells us that: 1. We have a Collection that is an intersection 2. The first property/value pair is includeHost/example.org We now need to run a second query Query 3A ======== PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX wdr: <http://www.w3.org/2007/05/powder#> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT DISTINCT ?x ?prop ?value ?description WHERE { ?x owl:equivalentClass ?y . ?y owl:intersectionOf ?bn . ?bn rdf:rest ?bn2 ?bn2 rdf:first ?restriction . ?restriction ?prop ?value . ?x rdfs:subClassOf ?description } Notice that an extra line has been inserted (?bn rdf:rest ?bn2). We'd need to iterate this kind of query until we got a null result telling us we'd reached the end of the Collection. It's a bit of a pain but it's the way SPARQL works. There may be smarter way?? Processing-wise I think you'd have to start with query 3. If you got data, do 3A and iterate until you got no more data. If you got no data from query 3, do query 2. We'll need to do more such tests but that's a start... Phil. [1] http://www.fosi.org/archive/powder/example3.owl [2] http://www.w3.org/RDF/Validator/ARPServlet.tmp/servlet_5895.png [3] http://www.fosi.org/archive/powder/example3.png [4] http://www.fosi.org/archive/powder/example3a.owl [5] http://www.w3.org/RDF/Validator/ARPServlet.tmp/servlet_5907.png [6] http://librdf.org/query?uri=http%3A%2F%2Fwww.fosi.org%2Farchive%2Fpowder%2Fexample3a.owl&query=PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0D%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0D%0APREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0APREFIX+wdr%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2007%2F05%2Fpowder%23%3E%0D%0ASELECT+DISTINCT+%3Fx%0D%0AWHERE+%7B%0D%0A++%3Fx+rdfs%3AsubClassOf+%3Chttp%3A%2F%2Fwww.fosi.org%2Farchive%2Fpowder%2Fexample3a.owl%23ResourceSafeForChildren%3E+.%0D%0A%7D%0D%0A%0D%0A&language=sparql&Run+Query=Run+Query&.cgifields=language&.cgifields=json&.cgifields=raw [7] http://www.fosi.org/archive/powder/example3b.owl [8] http://www.w3.org/RDF/Validator/ARPServlet.tmp/servlet_6063.png
Received on Monday, 26 November 2007 15:45:57 UTC