Hi, thanks for the reply.
Try using hasSubclass(Resourse, true) and hasSubclass(Resourse, false) and
didnt get the right results.
Here is the example:
I'm using the mouse and human ontologies used in OAEI.
(...) files....bio1... bio2
OntModel model1 = ModelFactory.createOntologyModel(OntModelSpec.
OWL_MEM_TRANS_INF);
OntDocumentManager dmb1 = model1.getDocumentManager();
dmb1.addAltEntry("bio1",mouse);
dmb1.addAltEntry("bio2",mouse);
System.out.println("Loading Ontology (1) ...");
model1.read("bio1");
model1.read("bio2");
OntClass cl1 = model1.getOntClass("http://mouse.owl#MA_0001251");
OntClass cl2 = model1.getOntClass("http://human.owl#NCI_C49482");
cl1.addSubClass(cl2);
cl1.addSuperClass(cl2);
cl2.addSubClass(cl1);
cl2.addSuperClass(cl1);
OntClass cl3 = model1.getOntClass("http://mouse.owl#MA_0000011");
OntClass cl4 = model1.getOntClass("http://human.owl#NCI_C12374");
cl3.addSubClass(cl4);
cl3.addSuperClass(cl4);
cl4.addSubClass(cl3);
cl4.addSuperClass(cl3);
OntClass cl5 = model1.getOntClass("http://mouse.owl#MA_0000003");
OntClass cl6 = model1.getOntClass("http://human.owl#NCI_C12919");
cl5.addSubClass(cl6);
cl5.addSuperClass(cl6);
cl6.addSubClass(cl5);
cl6.addSuperClass(cl5);
OntClass clss1 = model1.getOntClass("http://mouse.owl#MA_0000011");
OntClass clss2 = model1.getOntClass("http://human.owl#NCI_C12919");
if(clss2.hasSubClass(clss1)){
System.out.println(clss2.toString() + " has subclasse " + clss1.toString()
);
}
OntClass clss3 = model1.getOntClass("http://human.owl#NCI_C21599");
if(clss3.hasSubClass(clss1)){
System.out.println(clss3.toString() + " has subclasse " + clss1.toString()
);
}
OntClass clss4 = model1.getOntClass("http://mouse.owl#MA_0001755");
if(clss1.hasSubClass(clss4)){
System.out.println(clss1.toString() + " has subclasse " + clss4.toString()
);
}
if(clss2.hasSubClass(clss4)){
System.out.println(clss2.toString() + " has subclasse " + clss4.toString()
);
}
if(clss3.hasSubClass(clss4)){
System.out.println(clss3.toString() + " has subclasse " + clss4.toString()
);
}else{
System.out.println(clss3.toString() + " doesnt have subclasse " +
clss4.toString() );
}
Result:
http://human.owl#NCI_C12919 has subclasse http://mouse.owl#MA_0000011
http://human.owl#NCI_C21599 has subclasse http://mouse.owl#MA_0000011
http://mouse.owl#MA_0000011 has subclasse http://mouse.owl#MA_0001755
http://human.owl#NCI_C12919 has subclasse http://mouse.owl#MA_0001755
http://human.owl#NCI_C21599 doesnt have subclasse
http://mouse.owl#MA_0001755
Where is the bug ? It could be a easy one.. I didn't sleep.. :)
Thanks!
On 19 February 2013 09:33, Ian Dickinson <[email protected]> wrote:
> Hi Emanuel,
> These kinds of questions are *much* easier to answer if you supply a
> complete minimal example - working code, including the data. The short
> answer is that the transitive reasoner should give you the answer you're
> expecting, so there's something wrong in the way you're querying the model,
> or something wrong in the data.
>
> Ian
>
>
> On 19/02/13 04:31, Emanuel Santos wrote:
>
>> Hi again,
>>
>> I have a ontology model created with "OntModelSpec.OWL_MEM_TRANS_**INF".
>>
>> Given the original ontology I added some new "subclass" relations
>> between some classes (using addSubClass and addSuperClass methods).
>>
>> Now I have a class A that is a subclass of B and C.
>> And another class D that is subclass of A.
>>
>> (these results are given by hasSubClass method)
>>
>>
>> Given this model I should get the result that D is a subclass of B and
>> C. But for some reason I'm not getting that result (again using
>> hasSubClass method)
>> Does this mean that the model does not fully update the new inferred
>> relations between classes ? What should I do?
>>
>> It is odd, because A is only a subclass (not direct one) of C after
>> the addition of the new relations, i.e. A subclass C is inferred.
>>
>> Any ideas ?!
>>
>> Thanks!
>>
>>
>
> --
> ______________________________**______________________________
> Ian Dickinson Epimorphics Ltd, Bristol, UK
> mailto:[email protected] http://www.epimorphics.com
> cell: +44-7786-850536 landline: +44-1275-399069
> ------------------------------**------------------------------
> Epimorphics Ltd. is a limited company registered in England
> (no. 7016688). Registered address: Court Lodge, 105 High St,
> Portishead, Bristol BS20 6PT, UK
>
>