From: Igor T. <i.t...@uc...> - 2010-04-28 14:16:00
|
One of further two suggestions may solve your problem, because the code works well for me: - make sure your ontology files are in RDF/XML format; - replace the OWL API library with the attached one (this is an old version, synchronized with two Protégé jars that have been sent you previously); this tip is more likely to help. Igor -----Original Message----- From: mousawi [mailto:mo...@li...] Sent: 26 April 2010 16:07 To: 'Igor Toujilov'; owl...@li... Subject: RE: [OWLAPI-developer] [Fwd: RE: DL Query] Thank you Igor I replaced them but the same error still return. Regards Mahmood -----Original Message----- From: Igor Toujilov [mailto:i.t...@uc...] Sent: Monday, April 26, 2010 1:26 PM To: mo...@li...; owl...@li... Subject: Re: [OWLAPI-developer] [Fwd: RE: DL Query] Your code looks OK. It seems you are using a different version (presumably a newer than used in my example) of Protege libraries, which require analysing their source code to understand what causes the exception. But before going so deep, try replacing your Protege libraries with ones (attached) I use in my applications. Igor > Thank you Igor > This is my code: > > import java.net.URI; > import java.util.Set; > import org.semanticweb.owl.apibinding.OWLManager; > import org.semanticweb.owl.io.OWLXMLOntologyFormat; > import org.semanticweb.owl.model.*; > import org.semanticweb.owl.vocab.XSDVocabulary; > import org.semanticweb.owl.inference.OWLReasoner; > import org.semanticweb.owl.inference.OWLReasonerAdapter; > import org.semanticweb.owl.inference.OWLReasonerException; > import org.semanticweb.owl.inference.OWLReasonerFactory; > import org.semanticweb.owl.model.*; > import org.semanticweb.owl.inference.OWLReasoner; > > import com.owldl.pellet.*; > import org.protege.editor.owl.model.OWLModelManager; > import org.protege.editor.owl.model.event.EventType; > import org.protege.editor.owl.model.OWLModelManagerImpl; > import > org.protege.editor.owl.ui.clsdescriptioneditor.OWLDescriptionChecker; > > public class Librarian { > public final static void main(String[] args) throws Exception { > try{ //try > String u ="file:/C:/Library/pizza.owl"; > String q ="Book"; > //String qr = request.getParameter("word"); > OWLModelManager model_manager = new OWLModelManagerImpl(); > //OWLOntology ontology = > model_manager.loadOntology(u); > > model_manager.setActiveOntology(model_manager.getOWLOntologyManager().loadOn > tologyFromPhysicalURI(new URI(u))); > model_manager.fireEvent(EventType.ONTOLOGY_LOADED); > > OWLReasoner reasoner = (new > PelletReasonerFactory()).createReasoner(model_manager.getOWLOntologyManager( > )); > Set<OWLOntology> active_ontologies = > model_manager.getActiveOntologies(); > reasoner.loadOntologies(active_ontologies); > reasoner.classify(); > Set<OWLIndividual> individuals = reasoner.getIndividuals( > (new OWLDescriptionChecker(model_manager)).createObject(q), > false); > > for(OWLIndividual ind : individuals){ > > System.out.println("<tr><td><center>"+ind+"</center></td></tr>"); > } > > } > catch (OWLOntologyCreationException e1) { > System.out.println(e1.getMessage()); > } > } > } > > Regards > > -----Original Message----- > From: Igor Toujilov [mailto:i.t...@uc...] > Sent: Monday, April 26, 2010 10:41 AM > To: owl...@li... > Subject: Re: [OWLAPI-developer] [Fwd: RE: DL Query] > > As you can see from the stack trace, the exception occurs when setting the > active ontology, which goes after ontology loading. That means the > ontology is loaded OK. That is all I can say from your information. For > detailed analysis, your source code is needed. > > Igor > >> Dear Igor >> Now my program doesn't give errors when I compile but it doesn't load >> the >> file from local disk (LoadFromPhysicalURI). I tested on the cmd, with >> Servlet and finally with NetBeans IDE and with different owl files. Here >> is >> the error message from NetBeans: >> >> run: >> INFO [main] (OWLModelManagerImpl.java:1057) - Rebuilding entity >> indices... >> INFO [main] (OWLModelManagerImpl.java:1062) - ... rebuilt in 15 ms >> loading null from file:/C:/Library/pizza.owl >> INFO [main] (OWLModelManagerImpl.java:649) - Setting active ontology to >> http://www.co-ode.org/ontologies/pizza/pizza.owl >> INFO [main] (OWLModelManagerImpl.java:1057) - Rebuilding entity >> indices... >> Exception in thread "main" java.lang.NoSuchFieldError: RDF_XML_LITERAL >> at >> > org.protege.editor.owl.model.util.OWLDataTypeUtils.getBuiltinDatatypes(OWLDa >> taTypeUtils.java:65) >> at >> > org.protege.editor.owl.model.util.OWLDataTypeUtils.getKnownDatatypes(OWLData >> TypeUtils.java:81) >> at >> > org.protege.editor.owl.model.cache.OWLEntityRenderingCacheImpl.rebuild(OWLEn >> tityRenderingCacheImpl.java:95) >> at >> > org.protege.editor.owl.model.OWLModelManagerImpl.rebuildEntityIndices(OWLMod >> elManagerImpl.java:1059) >> at >> > org.protege.editor.owl.model.OWLModelManagerImpl.setActiveOntology(OWLModelM >> anagerImpl.java:652) >> at >> > org.protege.editor.owl.model.OWLModelManagerImpl.setActiveOntology(OWLModelM >> anagerImpl.java:660) >> at Librarian.main(Librarian.java:28) >> Java Result: 1 >> BUILD SUCCESSFUL (total time: 2 seconds) >> >> Best Regards >> >> -----Original Message----- >> From: Igor Toujilov [mailto:i.t...@uc...] >> Sent: Tuesday, April 20, 2010 8:03 PM >> To: mo...@li...; owl...@li... >> Subject: Re: [OWLAPI-developer] [Fwd: RE: DL Query] >> >> It depends on what you want to display. Once you have got a set of >> individuals, you can iterate through the set, and, inside the iteration >> loop, locate an individual, and apply some of its various methods to >> extract information you want to display. Please refer to Javadoc for the >> methods of interface OWLIndividual. >> >> Igor >> >>> Thank you Igor >>> It is working now the problem was the second argument of the >>> getIndividuals >>> was missing. >>> May I ask you how to display the query result? >>> >>> Best regards >>> Mahmood >>> >>> -----Original Message----- >>> From: Igor Toujilov [mailto:i.t...@uc...] >>> Sent: Tuesday, April 20, 2010 12:50 AM >>> To: owl...@li... >>> Subject: Re: [OWLAPI-developer] [Fwd: RE: DL Query] >>> >>> I have been confused because you do not provide your full code, and >>> detecting you compilation errors by one line is a pretty hard task. Now >>> I >>> looked at my original example and realised that createObject method >>> always >>> requires only one argument in all versions (I was wrong in my previous >>> reply). Now it seems you are missing the boolean argument in >>> getIndividuals method. Please check you parentheses, and once again, >>> this >>> is my original code: >>> >>> Set<OWLIndividual> individuals = >>> reasoner.getIndividuals( >>> (new OWLDescriptionChecker( >>> model_manager)).createObject(your class expression), >>> false); >>> >>> >>>> Dear Igor >>>> I removed the second argument but another error is returned which is >>>> reasoner.getIndividuals please see the attached image. >>>> Regards >>>> Mahmood >>>> >>>> -----Original Message----- >>>> From: Igor Toujilov [mailto:i.t...@uc...] >>>> Sent: Monday, April 19, 2010 4:27 PM >>>> To: mo...@li...; owl...@li... >>>> Subject: Re: [OWLAPI-developer] [Fwd: RE: DL Query] >>>> >>>> Dear Mahmood, >>>> All Protege 4 code can be found at >>>> http://smi-protege.stanford.edu/svn/protege4/. You have got the error >>>> because you are using a version of Protege libraries that are newer >>>> than >>>> that used in my example. So the newer method createObject has just one >>>> string argument, so you do not need the second boolean argument. >>>> Please >>>> see the source code at >>>> >>> >> > http://smi-protege.stanford.edu/svn/protege4/plugins/org.protege.editor.owl/ >>>> >>> >> > trunk/src/org/protege/editor/owl/ui/clsdescriptioneditor/OWLDescriptionCheck >>>> er.java?rev=16090&view=markup. >>>> >>>> Regards, >>>> Igor >>>> >>>>> Dear Igor >>>>> Now I have one error caused by the createBject method. Plus I >>>>> couldn't >>>>> find >>>>> the Implementation source code you mentioned. >>>>> Attached is an image of the error. >>>>> >>>>> Regards >>>>> Mahmood >>>>> >>>>> -----Original Message----- >>>>> From: Igor Toujilov [mailto:i.t...@uc...] >>>>> Sent: Wednesday, April 14, 2010 2:22 PM >>>>> To: owl...@li... >>>>> Subject: [OWLAPI-developer] [Fwd: RE: DL Query] >>>>> >>>>> Please note that the createObject method works properly only in the >>>>> context of the corresponding ontology, as you use names of ontology >>>>> entities in your DL query. So, if your ontology is not loaded >>>>> properly, >>>>> then it does not make sense to call createObject. >>>>> >>>>> Igor >>>>> >>>>>> Thank you Igor for your helps >>>>>> I am going to try that load method, but for creatObject I already >>>>>> removed >>>>>> double quote from the centre of it. >>>>>> >>>>>> Regards >>>>>> Mahmood >>>>>> >>>>>> -----Original Message----- >>>>>> From: Igor Toujilov [mailto:i.t...@uc...] >>>>>> Sent: Wednesday, April 14, 2010 12:35 PM >>>>>> To: mo...@li...; owl...@li... >>>>>> Subject: Re: [OWLAPI-developer] DL Query >>>>>> >>>>>> Mahmood, >>>>>> Sometimes using Javadoc is not enough and you need to look at the >>>>>> implementation source code to understand how it works, and even >>>>>> implement >>>>>> your own classes derived from the existing classes, if the existing >>>>>> implementation is not suitable for your purposes. In your case, the >>>>>> following code fragment may help you to overcome the difficulties. >>>>>> The >>>>>> example below do not require implementing your own derived classes. >>>>>> So >>>>>> they provide the simplest (but not necessary ideal) solution. >>>>>> >>>>>> To load ontology from a physical URI using the Protege libraries: >>>>>> >>>>>> model_manager.setActiveOntology( >>>>>> model_manager.getOWLOntologyManager() >>>>>> .loadOntologyFromPhysicalURI( >>>>>> new URI("file:/C:/your_path/your_file.owl"))); >>>>>> >>>>>> model_manager.fireEvent(EventType.ONTOLOGY_LOADED); >>>>>> >>>>>> Please also note that the string parameter in the createObject >>>>>> method >>>>>> invocation is malformed: delete double quote from the centre of the >>>>>> string. >>>>>> >>>>>> I hope it helps. >>>>>> >>>>>> Cheers, >>>>>> Igor >>>>>> >>>>>>> Dear All >>>>>>> >>>>>>> I am trying to use the Manchester syntax to query my owl file. This >>>>>>> can >>>>>>> be >>>>>>> done using Protégé 4 and it is working but when I try it with >>>>>>> owlapi >>>>>>> 2.20 >>>>>>> it >>>>>>> is not. I was advised by Igor Toujilov to use two jar files from >>>>>>> protégé >>>>>>> 4.0 >>>>>>> with the following methods: >>>>>>> >>>>>>> >>>>>>> >>>>>>> import org.protege.editor.owl.model.OWLModelManager; >>>>>>> >>>>>>> import org.protege.editor.owl.model.OWLModelManagerImpl; >>>>>>> >>>>>>> import >>>>>>> org.protege.editor.owl.ui.clsdescriptioneditor.OWLDescriptionChecker; >>>>>>> >>>>>>> >>>>>>> >>>>>>> OWLModelManager model_manager = new OWLModelManagerImpl(); >>>>>>> >>>>>>> OWLOntology ontology = model_manager.loadOntology( ); >>>>>>> >>>>>>> >>>>>>> >>>>>>> // Any reasoner, e.g. Pellet >>>>>>> >>>>>>> OWLReasoner reasoner = (new >>>>>>> PelletReasonerFactory()).createReasoner( >>>>>>> >>>>>>> model_manager.getOWLOntologyManager()); >>>>>>> >>>>>>> >>>>>>> >>>>>>> Set<OWLOntology> active_ontologies = >>>>>>> >>>>>>> model_manager.getActiveOntologies(); >>>>>>> >>>>>>> >>>>>>> >>>>>>> reasoner.loadOntologies(active_ontologies); >>>>>>> >>>>>>> reasoner.classify(); >>>>>>> >>>>>>> >>>>>>> >>>>>>> Set<OWLIndividual> individuals = >>>>>>> reasoner.getIndividuals( >>>>>>> (new OWLDescriptionChecker(model_manager)).createObject( >>>>>>> hasGivenName value Mathew, false); >>>>>>> >>>>>>> But unfortunately it returns two errors first the loadOntology >>>>>>> because >>>>>>> I >>>>>>> am >>>>>>> trying to load from physical URI. Second the createObject doesnt >>>>>>> accept >>>>>>> String. >>>>>>> >>>>>>> >>>>>>> >>>>>>> Now my question is: since Protégé is built on OWLAPI, why it is >>>>>>> working >>>>>>> with >>>>>>> Protégé and not working with OWLAPI, what are my mistakes in the >>>>>>> above >>>>>>> code >>>>>>> and finally why there is no table for all methods and their >>>>>>> equivalents >>>>>>> that >>>>>>> used in other software or versions. For example: what is the >>>>>>> equivalent >>>>>>> method for loadOntologyFromPhysicalURI() that comes with OWLAPI >>>>>>> 2.20 >>>>>>> in >>>>>>> Protégé and in OWLAPI 3.0. >>>>>>> >>>>>>> >>>>>>> >>>>>>> I am sorry for this long question but because I spent weeks reading >>>>>>> javadocs >>>>>>> for these versions with no luck. >>>>>>> >>>>>>> >>>>>>> >>>>>>> Kind regards >>>>>>> >>>>>>> Mahmood >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> > ---------------------------------------------------------------------------- >>>>>> -- >>>>>>> Download Intel® Parallel Studio Eval >>>>>>> Try the new software tools for yourself. Speed compiling, find bugs >>>>>>> proactively, and fine-tune applications for parallel performance. >>>>>>> See why Intel Parallel Studio got high marks during beta. >>>>>>> >>>>>> >>>>> >>>> >>> >> > http://p.sf.net/sfu/intel-sw-dev____________________________________________ >>>>>> ___ >>>>>>> Owlapi-developer mailing list >>>>>>> Owl...@li... >>>>>>> https://lists.sourceforge.net/lists/listinfo/owlapi-developer >>>>>>> >>>>>> >>>>>> >>>>>> Dr Igor Toujilov >>>>>> Senior Research Fellow >>>>>> Centre for Health Informatics and Multiprofessional Education >>>>>> University College London >>>>>> Highgate Hill >>>>>> London, UK >>>>>> N19 5LW >>>>>> >>>>>> Tel: +44 (0)20 7288 3960 >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> Dr Igor Toujilov >>>>> Senior Research Fellow >>>>> Centre for Health Informatics and Multiprofessional Education >>>>> University College London >>>>> Highgate Hill >>>>> London, UK >>>>> N19 5LW >>>>> >>>>> Tel: +44 (0)20 7288 3960 >>>>> >>>>> >>>>> >>>>> Dr Igor Toujilov >>>>> Senior Research Fellow >>>>> Centre for Health Informatics and Multiprofessional Education >>>>> University College London >>>>> Highgate Hill >>>>> London, UK >>>>> N19 5LW >>>>> >>>>> Tel: +44 (0)20 7288 3960 >>>>> >>>>> >>>>> >>>>> >>>> >>> >> > ---------------------------------------------------------------------------- >>>>> -- >>>>> Download Intel® Parallel Studio Eval >>>>> Try the new software tools for yourself. Speed compiling, find bugs >>>>> proactively, and fine-tune applications for parallel performance. >>>>> See why Intel Parallel Studio got high marks during beta. >>>>> http://p.sf.net/sfu/intel-sw-dev >>>>> _______________________________________________ >>>>> Owlapi-developer mailing list >>>>> Owl...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/owlapi-developer >>>>> >>>> >>> >> > ---------------------------------------------------------------------------- >>>> -- >>>>> Download Intel® Parallel Studio Eval >>>>> Try the new software tools for yourself. Speed compiling, find bugs >>>>> proactively, and fine-tune applications for parallel performance. >>>>> See why Intel Parallel Studio got high marks during beta. >>>>> >>>> >>> >> > http://p.sf.net/sfu/intel-sw-dev____________________________________________ >>>> ___ >>>>> Owlapi-developer mailing list >>>>> Owl...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/owlapi-developer >>>>> >>>> >>>> >>>> Dr Igor Toujilov >>>> Senior Research Fellow >>>> Centre for Health Informatics and Multiprofessional Education >>>> University College London >>>> Highgate Hill >>>> London, UK >>>> N19 5LW >>>> >>>> Tel: +44 (0)20 7288 3960 >>>> >>>> >>> >>> >>> Dr Igor Toujilov >>> Senior Research Fellow >>> Centre for Health Informatics and Multiprofessional Education >>> University College London >>> Highgate Hill >>> London, UK >>> N19 5LW >>> >>> Tel: +44 (0)20 7288 3960 >>> >>> >>> >>> >> > ---------------------------------------------------------------------------- >>> -- >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> _______________________________________________ >>> Owlapi-developer mailing list >>> Owl...@li... >>> https://lists.sourceforge.net/lists/listinfo/owlapi-developer >>> >>> >>> >> > ---------------------------------------------------------------------------- >> -- >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> _______________________________________________ >>> Owlapi-developer mailing list >>> Owl...@li... >>> https://lists.sourceforge.net/lists/listinfo/owlapi-developer >>> >> >> >> Dr Igor Toujilov >> Senior Research Fellow >> Centre for Health Informatics and Multiprofessional Education >> University College London >> Highgate Hill >> London, UK >> N19 5LW >> >> Tel: +44 (0)20 7288 3960 >> >> >> > > > Dr Igor Toujilov > Senior Research Fellow > Centre for Health Informatics and Multiprofessional Education > University College London > Highgate Hill > London, UK > N19 5LW > > Tel: +44 (0)20 7288 3960 > > > > ---------------------------------------------------------------------------- > -- > _______________________________________________ > Owlapi-developer mailing list > Owl...@li... > https://lists.sourceforge.net/lists/listinfo/owlapi-developer > > > ---------------------------------------------------------------------------- -- > _______________________________________________ > Owlapi-developer mailing list > Owl...@li... > https://lists.sourceforge.net/lists/listinfo/owlapi-developer > Dr Igor Toujilov Senior Research Fellow Centre for Health Informatics and Multiprofessional Education University College London Highgate Hill London, UK N19 5LW Tel: +44 (0)20 7288 3960 |