On 01/05/11 21:28, Dave Reynolds wrote: > On Sat, 2011-04-30 at 13:05 +0800, 朱曼 wrote: >> Currently I am using Jena to process ontology and create ontology classes. >> But I confront a problem: how can I create a class which is existentially >> restricted by the inverse of an existed property(hasValue inverseOf >> Property)? I tried "property.getInverse()", but I get a >> NullPointerException, I think that is because the inverse property doesn't >> really exist in the current ontology. And I also notice there is a >> createInverseFunctionalProperty method in OntModel, but how can I create an >> inverse property based on an existed property, so far as the >> createInverseFunctionalProperty method only have "uri" and "functional" >> parameters? > > You want OntProperty#addInverseOf Or OntProperty#setInverseOf, which will replace any existing owl:inverseOf assertions for that property.
> (not sure why it is called "add.." > rather than "create..") Because that call is only adding an owl:inverseOf triple, not creating the inverse property itself. To actually create the property which is the inverse of the property in question, June would need a separate OntModel#createObjectProperty method call. Perhaps there could be a shortcut method which performs both steps in one go, but currently there isn't. Ian -- ____________________________________________________________ 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
