OWL Parsing From EFO

£可爱£侵袭症+ 提交于 2020-01-24 22:09:04

问题


I have been trying endlessly to parse the Experimental Factor Ontology (EFO) file, but I am not able to parse it. The file I have opens fine in Protege, but I cannot seem to get it to load in Java. I have looked at a few sets of example code, and I am copying them seemingly exactly, but I do not understand why parsing fails. Here is my code:

System.setProperty("entityExpansionLimit","100000000");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
URI uri = URI.create("file:~/efo.owl");
IRI iri = IRI.create(uri);
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(iri);

And here are the errors I get:

Could not load ontology: Problem parsing 
file:/~/efo.owl
Could not parse ontology.  Either a suitable parser could not be found, or 
parsing failed.  See parser logs below for explanation.
The following parsers were tried:

Thank you, I know some similar posts have been made, but I have been unable to figure it out and am quite desperate! I can provide the stack trace if necessary, but it is quite long as there is a trace for each parser.


回答1:


File URI need to be absolute for OWLAPI to parse them, but as you have a local file you can just create a File instance and pass that to IRI.create().

Alternatively pass the File instance to OWLOntologyManager::loadOntologyFromOntologyDocument()




回答2:


There must be something wrong with the local, downloaded file. Loading the ontology directly from the ontology IRI worked.



来源:https://stackoverflow.com/questions/44163909/owl-parsing-from-efo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!