In my application, there is an ontology defined with a hierarchy similar to the 
A, Bs, and Cs found in my original email (see below).
These happen to be ICD9 diagnosis codes, each represented by a CLASS, not an 
instance.
A Patient may have one or more associated diagnosis, so they would be 
associated with these diagnosis CLASSES.

Ideally, I can define one or more sets, which contain a list of particular 
diagnosis CLASSES.
Assume for discussion, I have one such set called :SET1.
For the patients, I want to see which patients have a diagnosis that is an 
element in SET1.

:PatientSubset1 rdfs:subClassOf :Patient ;
        owl:equivalentClass [
                a owl:Restriction ;
                owl:onProperty :diagnosis ;
                owl:someValuesFrom :SET1
        ] .

And I also want subclass relationships to apply, such that if SET1 has :B1, and 
:C1 rdf:subClass :B1
And  there is the triple
:p1 rdf:type Patient ;
        :diagnosis C1 .

Then since SET1 contains the class :B1, I would want :p1 to be in the result.

But I have been told that owl:someValuesFrom only works on instances, not 
classes.
But I need to restrict the set of Patients based on a property being a member 
of a set of classes.
Maybe there is some way of doing this with set intersection facilities, where 
the predicate asks whether the intersection of the patient's diagnosis and my 
particular set of diagnosis is empty or not, but that would not be as efficient 
as someValuesFrom, which can return true/false once the first match is found.

To summarize, I need to do this restriction on classes, but also have the 
classes take into account the subclass relationships.
Is there a way of doing this in OWL? In a way that will be efficient?


-----Original Message-----
From: Dave Reynolds [mailto:[email protected]] 
Sent: Monday, August 29, 2011 5:10 PM
To: [email protected]
Subject: Re: owl restriction question

On Mon, 2011-08-29 at 17:40 +0000, David Jordan wrote: 
> I have a question about accessing instances of a restriction class. Below I 
> have a simple ontology, followed by some Jena Java code. My issue is that the 
> class PatientSubset1 is reporting it has no instances. Can you see what I 
> have done wrong?

There are at least a couple of problems here ...

> @prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
> @prefix owl:  <http://www.w3.org/2002/07/owl#> .
> @prefix :     <http://example.org/ex1#> .
> 
> :A a owl:Class .
> 
> :B1 a owl:Class ;
>       rdfs:subClassOf :A .
> 
> :B2 a owl:Class ;
>       rdfs:subClassOf :A .
> 
> :C1 a owl:Class ;
>       rdfs:subClassOf :B1 .
> 
> :C2 a owl:Class ;
>       rdfs:subClassOf :B1 .
> 
> :C3 a owl:Class ;
>       rdfs:subClassOf :B2 .
> 
> :C4 a owl:Class ;
>       rdfs:subClassOf :B2 .
> 
> :b1 rdf:type :B1 .
> 
> :Set1 a owl:Class ;
>       owl:distinctMembers (:b1) .
> 
> :Patient a owl:Class ;
>       rdfs:label "Patient" .
> 
> :p1 rdf:type :Patient .
> :p2 rdf:type :Patient .
> :p3 rdf:type :Patient .
> 
> :p1 :diagnosis :B1 .
> :p2 :diagnosis :C1 .

The :diagnosis assertions should point to an instance, e.g. :b1, not the 
classes. 

> :PatientSubset1 rdfs:subClassOf :Patient ;
>       a [
>               a owl:Restriction ;
>               owl:onProperty :diagnosis ;
>               owl:someValuesFrom (:B1)
>       ] .
> 
> 
>               OntModel omodel = ModelFactory.createOntologyModel();

If you want OWL inference then you need to specify an appropriate configuration 
such as OntModelSpec.OWL_MEM_MICRO_RULE_INF 

Dave


>               InputStream in = FileManager.get().open(fileName);
>               omodel.read(in, baseName, "TURTLE");
>               String fulluri = baseName + className;
>               OntClass oclass = omodel.getOntClass(fulluri);
>               System.out.println("Class is " + oclass.getURI()); 
> System.out.flush();
>               ExtendedIterator<? extends OntResource> iter = 
> oclass.listInstances();
>               while( iter.hasNext() ){
>                       OntResource res = iter.next();
>                       String uri = res.getURI();
>                       System.out.println(uri);
>               }
> 
> Any ideas why this is not returning any instances? I would expect the 
> resulting instances to include :p1 and :p2.





Reply via email to