[Pellet-users] restrictions
Simone Meixler
star405 at googlemail.com
Thu Mar 1 18:03:22 UTC 2007
Thank you! I now get the information I need from my owl-ontology.
2007/2/28, Ibach, Brandon L <brandon.l.ibach at lmco.com>:
>
> It looks like you're close. OWLRestriction has get "getProperty"
> method, which your code snippet calls on the previous line, but not a
> "getOnProperty" method. I think getProperty will provide what you want,
> though. Of course, there are more specific versions of OWLRestriction that
> will provide more details for, say, a restriction on an object property vs.
> one on a data property.
> Regarding lines in your code like "System.out.println(desc)", I'd warn
> against trying to directly print Java objects. While some objects may have
> a useful ToString implementation, I think it's generally better and safer to
> explicitly get the information you want about the object.
> Finally, when you run into error such as the one you list here, my
> first rule would be to always recheck your assumptions regarding method
> availability and such. It's easy to get caught on little details like the
> exact name of a method.
> Keep at it... I think you've nearly got what you're after.
>
> -Brandon :)
>
>
> ------------------------------
> *From:* Simone Meixler [mailto:star405 at googlemail.com]
> *Sent:* Wednesday, February 28, 2007 2:23 PM
> *To:* Ibach, Brandon L
> *Cc:* pellet-users at lists.owldl.com
> *Subject:* Re: [Pellet-users] restrictions
>
> Thank you for your fast answer but I don't get it to work.
>
> for (Iterator it = supers.iterator(); it.hasNext();
> OWLDescription desc = (OWLDescription) it.next();
> if (desc instanceof OWLClass){
> System.out.println(desc);
> }
> else if(desc instanceof OWLRestriction) {
> OWLRestriction restr =(OWLRestriction) desc;
> OWLProperty prop = ((OWLRestriction) desc).getProperty();
> restr.getOnProperty();
> }
> }
>
> I always get following errormessage:
> cannot find symbol
> symbol : method getOnProperty()
> location: interface org.semanticweb.owl.model.OWLRestriction
> restr.getOnProperty();
> I don't know why. In the api I read that I can use this method on an
> OWLRestriction object.
>
>
> 2007/2/27, Ibach, Brandon L < brandon.l.ibach at lmco.com>:
> >
> > I don't do much Java development with Pellet (ok... I haven't
> > really done any...), so take my suggestions here with caution, but the
> > important point is that the Restriction is composed of a set of triples in
> > the RDF graph, just like everything else, so you should be able to use
> > standard methods to access them. For instance, you should be able to get
> > the information you want with a SPARQL query such as:
> >
> > 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 my: <file:///home/ontology#>
> >
> > SELECT *
> > WHERE { my:class1 rdfs:subClassOf ?r . ?r rdf:type owl:Restriction;
> > owl:onProperty ?p; owl:hasValue ?v }
> > This queries the superclasses of your specified class, limiting the
> > results to only those superclasses that are of type owl:Restriction, and
> > returns the values of the owl:onProperty and owl:hasValue properties of the
> > Restriction. If you may be dealing with Restrictions of different types
> > (someValuesFrom, minCardinality, etc.), then you'll need to query the
> > different properties to see which are defined.
> > Now that I've gone on and on about all that, I finally got into a
> > copy of the OWL-API docs and see that you shouldn't even need to worry about
> > such details, as the API provides ready access to what you're looking for.
> > In the case you mention, the OWLDescription appears to actually be an
> > OWLObjectValueRestrictionImpl object, which, by virtue of implementing the
> > OWLObjectValueRestriction and OWLObjectRestriction interfaces, provides the
> > getIndividual and getObjectProperty methods, which should provide the
> > information you're after. Check out the OWL-API javadocs (http://owl.man.ac.uk/api/javadoc.zip
> > ) for more details. You're on the right track, so far. :)
> >
> > -Brandon :)
> >
> >
> > ------------------------------
> > *From:* pellet-users-bounces at lists.owldl.com [mailto:
> > pellet-users-bounces at lists.owldl.com] *On Behalf Of *Simone Meixler
> > *Sent:* Tuesday, February 27, 2007 1:16 PM
> > *To:* pellet-users at lists.owldl.com
> > *Subject:* [Pellet-users] restrictions
> >
> > Hello
> >
> > I'm new to OWL and to Java. I'm trying to get some information out of my
> > OWL ontology. But I have
> > problems with the getSuperClasses function. I want to get the hasValue
> > and onProperty Values of a Restriction. In the moment i'm iterating over my
> > superclasses like this:
> >
> > OWLClass class1=ont.getClass((URI.create("file:///home/ontology#class1
> > "));
> > Set supers = class1.getSuperClasses( ont );
> > for (Iterator it = supers.iterator (); it.hasNext(); ) {
> >
> > OWLDescription desc = (OWLDescription) it.next();
> > if (desc instanceof OWLClass){
> > System.out.println(desc);
> > }
> > else{
> > System.out.println (desc);
> > }
> > }
> >
> > But I dont't know how I can get the Restriction and the information
> > like hasValue and onPorperty.
> > In the moment I only get somthing like
> > org.semanticweb.owl.impl.model.OWLObjectValueRestrictionImpl at 5d8ab0b7
> > It would be great if someone could send me an example.
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.owldl.com/pipermail/pellet-users/attachments/20070301/74acfd79/attachment.htm
More information about the Pellet-users
mailing list