Hi David, If you want to represent each diagnosis as a class and not have a corresponding prototypical instance of the class then your best bet is to treat the class a "class of people with that diagnosis" rather than a class of diagnoses. So you would have something like:
:SET1 owl:unionOf (B1 C1) . :p1 a B1 . :p2 a C1 . :PatientSubset1 rdfs:subClassOf :Patient, :SET1 . If you want to have a :diagnosis property to relate an individual :Patient to a diagnosis then the each instance of the :diagnosis relation must be an individual (i.e. and instance of the diagnosis class). An expression like: :p1 :diagnosis :C1 . is not legal in OWL 1 DL (it puts you into OWL/full which is OK for jena but doesn't give the entailments you are after). It is legal in OWL 2 DL thanks to punning but again the punning means you don't get the entailments you want. If you *really* want a :diagnosis relation (rather than using the rdf:type relation between individual patients and the diagnosis class) and *really* don't want to use individuals like c1 in: :c1 a C1 . :p1 :diagnosis :c1 . Then I can think of only two options. One is to do exactly that but use bNodes to avoid having to predefine the prototypical instances: :p1 :diagnosis [a :C1] . The other is to do your reasoning through custom rules. Dave On Tue, 2011-08-30 at 17:24 +0000, David Jordan wrote: > 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. > > > > >
