You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by 朱曼 <zh...@gmail.com> on 2011/05/23 06:43:16 UTC
Question about asComplementClass().getOperand()
Hi list,
In the following code, I try to create an ontology model with pellet, then I
create an anonymous class which is complement to an existed class
"Mother"(see details from the attached ontology test.owl), and I want to
print "not Mother", but the results appear to be:
not (Female) (Mother)
not Female
Are there convenient ways to print "not Mother" directly?
---------------------------------------------------------------------------------------------------------------------------------------
OntModel m =
ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
m.read("test.owl");
OntClass c = m.getOntClass(m.getNsPrefixURI("") + "Mother");
OntClass newCls = m.createComplementClass(null, c);
if (newCls.isComplementClass()) {
System.out.print("not");
for (ExtendedIterator<? extends OntClass> iter =
newCls.asComplementClass().listOperands(); iter.hasNext(); )
System.out.print(" (" + iter.next().getLocalName() + ") ");
System.out.print("\nnot ");
System.out.println(newCls.asComplementClass().getOperand().getLocalName());
}
------------------------------------------------------------------------------------------------------------------------------------------
All the best,
June
Re: Question about asComplementClass().getOperand()
Posted by Dave Reynolds <da...@gmail.com>.
On Mon, 2011-05-23 at 16:14 +0800, 朱曼 wrote:
> 2011/5/23 Dave Reynolds <da...@gmail.com>
>
> > On Mon, 2011-05-23 at 12:43 +0800, 朱曼 wrote:
> > > Hi list,
> > >
> > > In the following code, I try to create an ontology model with pellet,
> > > then I create an anonymous class which is complement to an existed
> > > class "Mother"(see details from the attached ontology test.owl), and I
> > > want to print "not Mother", but the results appear to be:
> > >
> > > not (Female) (Mother)
> > > not Female
> > >
> >
> > If you try without a reasoner (use OntModelSpec.OWL_MEM) you will
> > probably get what you want.
> >
> > Why Pellet is inferring the extra complementOf relation is hard to tell
> > without seeing the ontology.
> >
>
> In the ontology, Mother is a subClass of Female, and the ontology is created
> according to actual facts.
>
> If I create a complement class of "Female", listOperands() also return
> Female and Mother.
So it seems that Pellet is inferring that Mother and Female are
equivalent, which may indicate some problem in the rest of the ontology.
Dave
>
> >
> > Dave
> >
> > > Are there convenient ways to print "not Mother" directly?
> > >
> > >
> > ---------------------------------------------------------------------------------------------------------------------------------------
> > > OntModel m =
> > > ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
> > > m.read("test.owl");
> > > OntClass c = m.getOntClass(m.getNsPrefixURI("") + "Mother");
> > > OntClass newCls = m.createComplementClass(null, c);
> > > if (newCls.isComplementClass()) {
> > > System.out.print("not");
> > > for (ExtendedIterator<? extends OntClass> iter =
> > > newCls.asComplementClass().listOperands(); iter.hasNext(); )
> > > System.out.print(" (" + iter.next().getLocalName() +
> > > ") ");
> > > System.out.print("\nnot ");
> > >
> > >
> > System.out.println(newCls.asComplementClass().getOperand().getLocalName());
> > >
> > > }
> > >
> > ------------------------------------------------------------------------------------------------------------------------------------------
> > >
> > > All the best,
> > >
> > > June
> >
> >
> >
> >
Re: Question about asComplementClass().getOperand()
Posted by 朱曼 <mz...@seu.edu.cn>.
2011/5/23 Dave Reynolds <da...@gmail.com>
> On Mon, 2011-05-23 at 12:43 +0800, 朱曼 wrote:
> > Hi list,
> >
> > In the following code, I try to create an ontology model with pellet,
> > then I create an anonymous class which is complement to an existed
> > class "Mother"(see details from the attached ontology test.owl), and I
> > want to print "not Mother", but the results appear to be:
> >
> > not (Female) (Mother)
> > not Female
> >
>
> If you try without a reasoner (use OntModelSpec.OWL_MEM) you will
> probably get what you want.
>
> Why Pellet is inferring the extra complementOf relation is hard to tell
> without seeing the ontology.
>
In the ontology, Mother is a subClass of Female, and the ontology is created
according to actual facts.
If I create a complement class of "Female", listOperands() also return
Female and Mother.
>
> Dave
>
> > Are there convenient ways to print "not Mother" directly?
> >
> >
> ---------------------------------------------------------------------------------------------------------------------------------------
> > OntModel m =
> > ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
> > m.read("test.owl");
> > OntClass c = m.getOntClass(m.getNsPrefixURI("") + "Mother");
> > OntClass newCls = m.createComplementClass(null, c);
> > if (newCls.isComplementClass()) {
> > System.out.print("not");
> > for (ExtendedIterator<? extends OntClass> iter =
> > newCls.asComplementClass().listOperands(); iter.hasNext(); )
> > System.out.print(" (" + iter.next().getLocalName() +
> > ") ");
> > System.out.print("\nnot ");
> >
> >
> System.out.println(newCls.asComplementClass().getOperand().getLocalName());
> >
> > }
> >
> ------------------------------------------------------------------------------------------------------------------------------------------
> >
> > All the best,
> >
> > June
>
>
>
>
Re: Question about asComplementClass().getOperand()
Posted by Dave Reynolds <da...@gmail.com>.
On Mon, 2011-05-23 at 12:43 +0800, 朱曼 wrote:
> Hi list,
>
> In the following code, I try to create an ontology model with pellet,
> then I create an anonymous class which is complement to an existed
> class "Mother"(see details from the attached ontology test.owl), and I
> want to print "not Mother", but the results appear to be:
>
> not (Female) (Mother)
> not Female
>
If you try without a reasoner (use OntModelSpec.OWL_MEM) you will
probably get what you want.
Why Pellet is inferring the extra complementOf relation is hard to tell
without seeing the ontology.
Dave
> Are there convenient ways to print "not Mother" directly?
>
> ---------------------------------------------------------------------------------------------------------------------------------------
> OntModel m =
> ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
> m.read("test.owl");
> OntClass c = m.getOntClass(m.getNsPrefixURI("") + "Mother");
> OntClass newCls = m.createComplementClass(null, c);
> if (newCls.isComplementClass()) {
> System.out.print("not");
> for (ExtendedIterator<? extends OntClass> iter =
> newCls.asComplementClass().listOperands(); iter.hasNext(); )
> System.out.print(" (" + iter.next().getLocalName() +
> ") ");
> System.out.print("\nnot ");
>
> System.out.println(newCls.asComplementClass().getOperand().getLocalName());
>
> }
> ------------------------------------------------------------------------------------------------------------------------------------------
>
> All the best,
>
> June