AW: Re: querying descendants

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

AW: Re: querying descendants

Rajverma
Thanx Olivier,

this is what I'm looking for... I cud successfully use this getDescendantClasses() method with the inferred model but I'm not able to do that same with asserted classes...

inferredDescendantClasses = reasoner.getDescendantClasses(Pizza, null);
for(Iterator it = inferredDescendantClasses.iterator(); it.hasNext();) {
        OWLNamedClass curClass = (OWLNamedClass) it.next();
        System.out.println(curClass.getName());
}

With the above piece of code it prints all the inferred descendants of the class Pizza, which are about 36, but when I try,

OWLNamedClass Pizza = model.getOWLNamedClass("Pizza");
Collection assertedDescendantClasses = Pizza.getDescendantClasses ();
for(Iterator it = assertedDescendantClasses.iterator(); it.hasNext();) {
   OWLNamedClass curClass = (OWLNamedClass) it.next();
   System.out.println(curClass.getName());
}

there is an error that says "This method getDescendantClasses() is undefined for the type OWLNamed class"... So does it mean that we can't use this method for retreiving descendants of asserted classes? If not, I mean if it is possible to retrieve descendants of asserted classes aswell then how to do it?

Cheers,
Raj




-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Olivier Dameron
Gesendet: Dienstag, 9. Mai 2006 18:31
An: [hidden email]
Betreff: [protege-owl] Re: querying sub-sub-sub-... classes

On Tue, 9 May 2006 18:16:45 +0200, "Mudunuri, Raj"
<[hidden email]> wrote:

> At
> http://protege.stanford.edu/plugins/owl/api/ReasonerAPIExamples.html
> it was shown that we can query the subclasses (asserted or inferred)
> with the statement like "Collection inferredSubclasses =
> reasoner.getSubclasses(vegetarianPizza, null);"... However, with this
> 'get.Subclasses' method it gives only the upper-level subclasses but
> not deep into the hierarchy... So, what I want to know is how can we
> get all the subclasses of a particular class, including the
> subclasses subsubclasses and so on...

I think that you are looking for the getDescendantClasses() method
http://protege-owl.sourceforge.net/javadoc/edu/stanford/smi/protegex/owl/inference/protegeowl/ProtegeOWLReasoner.html#getDescendantClasses(edu.stanford.smi.protegex.owl.model.OWLClass,%20edu.stanford.smi.protegex.owl.inference.protegeowl.task.ReasonerTaskListener)

Hope this helps,
Olivier
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: AW: Re: querying descendants

Matthew Horridge
Hi Raj,

You should just be able to do

getSubClasses(true)

Cheers,

Matthew

> this is what I'm looking for... I cud successfully use this  
> getDescendantClasses() method with the inferred model but I'm not  
> able to do that same with asserted classes...
>
> inferredDescendantClasses = reasoner.getDescendantClasses(Pizza,  
> null);
> for(Iterator it = inferredDescendantClasses.iterator(); it.hasNext
> ();) {
> OWLNamedClass curClass = (OWLNamedClass) it.next();
> System.out.println(curClass.getName());
> }
>
> With the above piece of code it prints all the inferred descendants  
> of the class Pizza, which are about 36, but when I try,
>
> OWLNamedClass Pizza = model.getOWLNamedClass("Pizza");
> Collection assertedDescendantClasses = Pizza.getDescendantClasses ();
> for(Iterator it = assertedDescendantClasses.iterator(); it.hasNext
> ();) {
>    OWLNamedClass curClass = (OWLNamedClass) it.next();
>    System.out.println(curClass.getName());
> }
>
> there is an error that says "This method getDescendantClasses() is  
> undefined for the type OWLNamed class"... So does it mean that we  
> can't use this method for retreiving descendants of asserted  
> classes? If not, I mean if it is possible to retrieve descendants  
> of asserted classes aswell then how to do it?
>
> Cheers,
> Raj
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:protege-owl-
> [hidden email]] Im Auftrag von Olivier Dameron
> Gesendet: Dienstag, 9. Mai 2006 18:31
> An: [hidden email]
> Betreff: [protege-owl] Re: querying sub-sub-sub-... classes
>
> On Tue, 9 May 2006 18:16:45 +0200, "Mudunuri, Raj"
> <[hidden email]> wrote:
>
>> At
>> http://protege.stanford.edu/plugins/owl/api/ReasonerAPIExamples.html
>> it was shown that we can query the subclasses (asserted or inferred)
>> with the statement like "Collection inferredSubclasses =
>> reasoner.getSubclasses(vegetarianPizza, null);"... However, with this
>> 'get.Subclasses' method it gives only the upper-level subclasses but
>> not deep into the hierarchy... So, what I want to know is how can we
>> get all the subclasses of a particular class, including the
>> subclasses subsubclasses and so on...
>
> I think that you are looking for the getDescendantClasses() method
> http://protege-owl.sourceforge.net/javadoc/edu/stanford/smi/ 
> protegex/owl/inference/protegeowl/
> ProtegeOWLReasoner.html#getDescendantClasses
> (edu.stanford.smi.protegex.owl.model.OWLClass,%
> 20edu.stanford.smi.protegex.owl.inference.protegeowl.task.ReasonerTask
> Listener)
>
> Hope this helps,
> Olivier
> ----------------------------------------------------------------------
> ---
> To unsubscribe go to http://protege.stanford.edu/community/ 
> subscribe.html
>
> ----------------------------------------------------------------------
> ---
> To unsubscribe go to http://protege.stanford.edu/community/ 
> subscribe.html
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: AW: Re: querying descendants

Rajverma
In reply to this post by Rajverma

Hi Matthew,

 

thanq for the suggestion, but it didn't solve my problem… I used the getSublcasses(true) method in the following way in the pizza example from [1]…

 

Collection assertedDescendantClasses = Pizza.getSubclasses(true);

System.out.println("Number of asserted Pizzas: " + assertedDescendantClasses.size());

for(Iterator it = assertedDescendantClasses.iterator(); it.hasNext();) {

      OWLNamedClass curClass = (OWLNamedClass) it.next();

      System.out.println(curClass.getName());

 

It gave the following error in my Eclipse console…

 

Number of asserted Pizzas: 44

java.lang.ClassCastException: edu.stanford.smi.protegex.owl.model.impl.DefaultOWLIntersectionClass

      at ReasonerExample.main(ReasonerExample.java:59)

CheeseyPizza

 

What I find strange is there are only 34 asserted subclasses of the class Pizza, but here it says there are 44 and then throws this error soon after it started to print them… what’s the problem?

 

I’m not so good at Java, so pls excuse me if I’m asking trivial questions…

 

[1] http://protege.stanford.edu/plugins/owl/api/ReasonerAPIExamples.html

 

Cheers,

Raj

 

 

 

 

 

-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Matthew Horridge
Gesendet: Mittwoch, 10. Mai 2006 15:50
An: [hidden email]
Betreff: [protege-owl] Re: AW: Re: querying descendants

 

Hi Raj,

 

You should just be able to do

 

getSubClasses(true)

 

Cheers,

 

Matthew

 

> this is what I'm looking for... I cud successfully use this 

> getDescendantClasses() method with the inferred model but I'm not 

> able to do that same with asserted classes...

> 

> inferredDescendantClasses = reasoner.getDescendantClasses(Pizza, 

> null);

> for(Iterator it = inferredDescendantClasses.iterator(); it.hasNext

> ();) {

>     OWLNamedClass curClass = (OWLNamedClass) it.next();

>     System.out.println(curClass.getName());

> }

> 

> With the above piece of code it prints all the inferred descendants 

> of the class Pizza, which are about 36, but when I try,

> 

> OWLNamedClass Pizza = model.getOWLNamedClass("Pizza");

> Collection assertedDescendantClasses = Pizza.getDescendantClasses ();

> for(Iterator it = assertedDescendantClasses.iterator(); it.hasNext

> ();) {

>    OWLNamedClass curClass = (OWLNamedClass) it.next();

>    System.out.println(curClass.getName());

> }

> 

> there is an error that says "This method getDescendantClasses() is 

> undefined for the type OWLNamed class"... So does it mean that we 

> can't use this method for retreiving descendants of asserted 

> classes? If not, I mean if it is possible to retrieve descendants 

> of asserted classes aswell then how to do it?

> 

> Cheers,

> Raj

> 

> 

> 

> 

> -----Ursprüngliche Nachricht-----

> Von: [hidden email] [mailto:protege-owl-

> [hidden email]] Im Auftrag von Olivier Dameron

> Gesendet: Dienstag, 9. Mai 2006 18:31

> An: [hidden email]

> Betreff: [protege-owl] Re: querying sub-sub-sub-... classes

> 

> On Tue, 9 May 2006 18:16:45 +0200, "Mudunuri, Raj"

> <[hidden email]> wrote:

> 

>> At

>> http://protege.stanford.edu/plugins/owl/api/ReasonerAPIExamples.html

>> it was shown that we can query the subclasses (asserted or inferred)

>> with the statement like "Collection inferredSubclasses =

>> reasoner.getSubclasses(vegetarianPizza, null);"... However, with this

>> 'get.Subclasses' method it gives only the upper-level subclasses but

>> not deep into the hierarchy... So, what I want to know is how can we

>> get all the subclasses of a particular class, including the

>> subclasses subsubclasses and so on...

> 

> I think that you are looking for the getDescendantClasses() method

> http://protege-owl.sourceforge.net/javadoc/edu/stanford/smi/

> protegex/owl/inference/protegeowl/

> ProtegeOWLReasoner.html#getDescendantClasses

> (edu.stanford.smi.protegex.owl.model.OWLClass,%

> 20edu.stanford.smi.protegex.owl.inference.protegeowl.task.ReasonerTask

> Listener)

> 

> Hope this helps,

> Olivier

> ----------------------------------------------------------------------

 

Reply | Threaded
Open this post in threaded view
|

Re: AW: Re: querying descendants

Matthew Horridge
Hi Raj,

Just us the toString method instead of casting.  This will enable you  
to see what's going on.  Unfortunately, for historical reasons, the  
current version of Protege-OWL stores subClassOf statements for  
equivalent classes, so if A==B then we have A subClassOf B and B  
subClassOf A.  I suspect that some equivalent classes (anonymous  
equivalent classes) are being returned.  This will be equivalent to  
things like VegetarianPizza.

You could either, check that the class is a named class, or, you  
could there should be some method like getNamedSubClasses

Cheers,

Matthew


On 10 May 2006, at 15:57, Mudunuri, Raj wrote:

> Hi Matthew,
>
>
>
> thanq for the suggestion, but it didn't solve my problem… I used  
> the getSublcasses(true) method in the following way in the pizza  
> example from [1]…
>
>
>
> Collection assertedDescendantClasses = Pizza.getSubclasses(true);
>
> System.out.println("Number of asserted Pizzas: " +  
> assertedDescendantClasses.size());
>
> for(Iterator it = assertedDescendantClasses.iterator(); it.hasNext
> ();) {
>
>       OWLNamedClass curClass = (OWLNamedClass) it.next();
>
>       System.out.println(curClass.getName());
>
> }
>
>
>
> It gave the following error in my Eclipse console…
>
>
>
> Number of asserted Pizzas: 44
>
> java.lang.ClassCastException:  
> edu.stanford.smi.protegex.owl.model.impl.DefaultOWLIntersectionClass
>
>       at ReasonerExample.main(ReasonerExample.java:59)
>
> CheeseyPizza
>
>
>
> What I find strange is there are only 34 asserted subclasses of the  
> class Pizza, but here it says there are 44 and then throws this  
> error soon after it started to print them… what’s the problem?
>
>
>
> I’m not so good at Java, so pls excuse me if I’m asking trivial  
> questions…
>
>
>
> [1] http://protege.stanford.edu/plugins/owl/api/ 
> ReasonerAPIExamples.html
>
>
>
> Cheers,
>
> Raj
>
>
>
>
>
>
>
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:protege-owl-
> [hidden email]] Im Auftrag von Matthew Horridge
> Gesendet: Mittwoch, 10. Mai 2006 15:50
> An: [hidden email]
> Betreff: [protege-owl] Re: AW: Re: querying descendants
>
>
>
> Hi Raj,
>
>
>
> You should just be able to do
>
>
>
> getSubClasses(true)
>
>
>
> Cheers,
>
>
>
> Matthew
>
>
>
> > this is what I'm looking for... I cud successfully use this
>
> > getDescendantClasses() method with the inferred model but I'm not
>
> > able to do that same with asserted classes...
>
> >
>
> > inferredDescendantClasses = reasoner.getDescendantClasses(Pizza,
>
> > null);
>
> > for(Iterator it = inferredDescendantClasses.iterator(); it.hasNext
>
> > ();) {
>
> >     OWLNamedClass curClass = (OWLNamedClass) it.next();
>
> >     System.out.println(curClass.getName());
>
> > }
>
> >
>
> > With the above piece of code it prints all the inferred descendants
>
> > of the class Pizza, which are about 36, but when I try,
>
> >
>
> > OWLNamedClass Pizza = model.getOWLNamedClass("Pizza");
>
> > Collection assertedDescendantClasses = Pizza.getDescendantClasses  
> ();
>
> > for(Iterator it = assertedDescendantClasses.iterator(); it.hasNext
>
> > ();) {
>
> >    OWLNamedClass curClass = (OWLNamedClass) it.next();
>
> >    System.out.println(curClass.getName());
>
> > }
>
> >
>
> > there is an error that says "This method getDescendantClasses() is
>
> > undefined for the type OWLNamed class"... So does it mean that we
>
> > can't use this method for retreiving descendants of asserted
>
> > classes? If not, I mean if it is possible to retrieve descendants
>
> > of asserted classes aswell then how to do it?
>
> >
>
> > Cheers,
>
> > Raj
>
> >
>
> >
>
> >
>
> >
>
> > -----Ursprüngliche Nachricht-----
>
> > Von: [hidden email] [mailto:protege-owl-
>
> > [hidden email]] Im Auftrag von Olivier Dameron
>
> > Gesendet: Dienstag, 9. Mai 2006 18:31
>
> > An: [hidden email]
>
> > Betreff: [protege-owl] Re: querying sub-sub-sub-... classes
>
> >
>
> > On Tue, 9 May 2006 18:16:45 +0200, "Mudunuri, Raj"
>
> > <[hidden email]> wrote:
>
> >
>
> >> At
>
> >> http://protege.stanford.edu/plugins/owl/api/ 
> ReasonerAPIExamples.html
>
> >> it was shown that we can query the subclasses (asserted or  
> inferred)
>
> >> with the statement like "Collection inferredSubclasses =
>
> >> reasoner.getSubclasses(vegetarianPizza, null);"... However, with  
> this
>
> >> 'get.Subclasses' method it gives only the upper-level subclasses  
> but
>
> >> not deep into the hierarchy... So, what I want to know is how  
> can we
>
> >> get all the subclasses of a particular class, including the
>
> >> subclasses subsubclasses and so on...
>
> >
>
> > I think that you are looking for the getDescendantClasses() method
>
> > http://protege-owl.sourceforge.net/javadoc/edu/stanford/smi/
>
> > protegex/owl/inference/protegeowl/
>
> > ProtegeOWLReasoner.html#getDescendantClasses
>
> > (edu.stanford.smi.protegex.owl.model.OWLClass,%
>
> >  
> 20edu.stanford.smi.protegex.owl.inference.protegeowl.task.ReasonerTask
>
> > Listener)
>
> >
>
> > Hope this helps,
>
> > Olivier
>
> >  
> ----------------------------------------------------------------------
>
>
>
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

AW: Re: AW: Re: querying descendants

Rajverma
In reply to this post by Rajverma
Hi Mathew,

I didn't understand what you mean by using (and where) toString method instead of casting! But your other suggestion, 'getNamedSubClasses(true)' did the trick... So if it is just 'getNamedSubClasses()' it gives the list of top-level subclasses, if it is 'getNamedSubClasses(true)' it then gives the list of all descendants...

Thanq,
Raj



-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Matthew Horridge
Gesendet: Mittwoch, 10. Mai 2006 17:32
An: [hidden email]
Betreff: [protege-owl] Re: AW: Re: querying descendants

Hi Raj,

Just us the toString method instead of casting.  This will enable you  
to see what's going on.  Unfortunately, for historical reasons, the  
current version of Protege-OWL stores subClassOf statements for  
equivalent classes, so if A==B then we have A subClassOf B and B  
subClassOf A.  I suspect that some equivalent classes (anonymous  
equivalent classes) are being returned.  This will be equivalent to  
things like VegetarianPizza.

You could either, check that the class is a named class, or, you  
could there should be some method like getNamedSubClasses

Cheers,

Matthew


On 10 May 2006, at 15:57, Mudunuri, Raj wrote:

> Hi Matthew,
>
>
>
> thanq for the suggestion, but it didn't solve my problem... I used  
> the getSublcasses(true) method in the following way in the pizza  
> example from [1]...
>
>
>
> Collection assertedDescendantClasses = Pizza.getSubclasses(true);
>
> System.out.println("Number of asserted Pizzas: " +  
> assertedDescendantClasses.size());
>
> for(Iterator it = assertedDescendantClasses.iterator(); it.hasNext
> ();) {
>
>       OWLNamedClass curClass = (OWLNamedClass) it.next();
>
>       System.out.println(curClass.getName());
>
> }
>
>
>
> It gave the following error in my Eclipse console...
>
>
>
> Number of asserted Pizzas: 44
>
> java.lang.ClassCastException:  
> edu.stanford.smi.protegex.owl.model.impl.DefaultOWLIntersectionClass
>
>       at ReasonerExample.main(ReasonerExample.java:59)
>
> CheeseyPizza
>
>
>
> What I find strange is there are only 34 asserted subclasses of the  
> class Pizza, but here it says there are 44 and then throws this  
> error soon after it started to print them... what's the problem?
>
>
>
> I'm not so good at Java, so pls excuse me if I'm asking trivial  
> questions...
>
>
>
> [1] http://protege.stanford.edu/plugins/owl/api/ 
> ReasonerAPIExamples.html
>
>
>
> Cheers,
>
> Raj
>
>
>
>
>
>
>
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:protege-owl-
> [hidden email]] Im Auftrag von Matthew Horridge
> Gesendet: Mittwoch, 10. Mai 2006 15:50
> An: [hidden email]
> Betreff: [protege-owl] Re: AW: Re: querying descendants
>
>
>
> Hi Raj,
>
>
>
> You should just be able to do
>
>
>
> getSubClasses(true)
>
>
>
> Cheers,
>
>
>
> Matthew
>
>
>
> > this is what I'm looking for... I cud successfully use this
>
> > getDescendantClasses() method with the inferred model but I'm not
>
> > able to do that same with asserted classes...
>
> >
>
> > inferredDescendantClasses = reasoner.getDescendantClasses(Pizza,
>
> > null);
>
> > for(Iterator it = inferredDescendantClasses.iterator(); it.hasNext
>
> > ();) {
>
> >     OWLNamedClass curClass = (OWLNamedClass) it.next();
>
> >     System.out.println(curClass.getName());
>
> > }
>
> >
>
> > With the above piece of code it prints all the inferred descendants
>
> > of the class Pizza, which are about 36, but when I try,
>
> >
>
> > OWLNamedClass Pizza = model.getOWLNamedClass("Pizza");
>
> > Collection assertedDescendantClasses = Pizza.getDescendantClasses  
> ();
>
> > for(Iterator it = assertedDescendantClasses.iterator(); it.hasNext
>
> > ();) {
>
> >    OWLNamedClass curClass = (OWLNamedClass) it.next();
>
> >    System.out.println(curClass.getName());
>
> > }
>
> >
>
> > there is an error that says "This method getDescendantClasses() is
>
> > undefined for the type OWLNamed class"... So does it mean that we
>
> > can't use this method for retreiving descendants of asserted
>
> > classes? If not, I mean if it is possible to retrieve descendants
>
> > of asserted classes aswell then how to do it?
>
> >
>
> > Cheers,
>
> > Raj
>
> >
>
> >
>
> >
>
> >
>
> > -----Ursprüngliche Nachricht-----
>
> > Von: [hidden email] [mailto:protege-owl-
>
> > [hidden email]] Im Auftrag von Olivier Dameron
>
> > Gesendet: Dienstag, 9. Mai 2006 18:31
>
> > An: [hidden email]
>
> > Betreff: [protege-owl] Re: querying sub-sub-sub-... classes
>
> >
>
> > On Tue, 9 May 2006 18:16:45 +0200, "Mudunuri, Raj"
>
> > <[hidden email]> wrote:
>
> >
>
> >> At
>
> >> http://protege.stanford.edu/plugins/owl/api/ 
> ReasonerAPIExamples.html
>
> >> it was shown that we can query the subclasses (asserted or  
> inferred)
>
> >> with the statement like "Collection inferredSubclasses =
>
> >> reasoner.getSubclasses(vegetarianPizza, null);"... However, with  
> this
>
> >> 'get.Subclasses' method it gives only the upper-level subclasses  
> but
>
> >> not deep into the hierarchy... So, what I want to know is how  
> can we
>
> >> get all the subclasses of a particular class, including the
>
> >> subclasses subsubclasses and so on...
>
> >
>
> > I think that you are looking for the getDescendantClasses() method
>
> > http://protege-owl.sourceforge.net/javadoc/edu/stanford/smi/
>
> > protegex/owl/inference/protegeowl/
>
> > ProtegeOWLReasoner.html#getDescendantClasses
>
> > (edu.stanford.smi.protegex.owl.model.OWLClass,%
>
> >  
> 20edu.stanford.smi.protegex.owl.inference.protegeowl.task.ReasonerTask
>
> > Listener)
>
> >
>
> > Hope this helps,
>
> > Olivier
>
> >  
> ----------------------------------------------------------------------
>
>
>
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html