-1

When parsing a set of ontologies, some of the files give me the following error while others work well (Note that I am using OWL API 5.1.6):

uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1033)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:933)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadImports(OWLOntologyManagerImpl.java:1630)

....

Could not parse JSONLD        org.eclipse.rdf4j.rio.jsonld.JSONLDParser.parse(JSONLDParser.java:110)
    org.semanticweb.owlapi.rio.RioParserImpl.parseDocumentSource(RioParserImpl.java:172)
    org.semanticweb.owlapi.rio.RioParserImpl.parse(RioParserImpl.java:125)

....

Stack trace:
org.eclipse.rdf4j.rio.RDFParseException: unqualified attribute 'class' not allowed [line 3, column 65]        
org.semanticweb.owlapi.rio.RioParserImpl.parse(RioParserImpl.java:138)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:193)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1071)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1033)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:933)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadImports(OWLOntologyManagerImpl.java:1630)

....

and many errors like those. Any idea how to fix this problem(s)?


update:

The snippet that loads the ontology is:

File file = new File("C:\\vocabs\\" + Ontofile.getName());

OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology o;
o = m.loadOntologyFromOntologyDocument(file);
OWLDocumentFormat format = m.getOntologyFormat(o);

OWLOntologyXMLNamespaceManager nsManager = new 
OWLOntologyXMLNamespaceManager(o, format);
Kittani
  • 115
  • 9

1 Answers1

1

This error is saying that one of the ontologies you're parsing is not valid JSON/LD format.

To fix this, you have to do two things:

  • Ensure the format that's being used is the one you expect: OWLAPI, if no format is specified, will attempt to use all parsers available until one of them successfully parses the ontology

  • Fix the input data if the format is correct: in this case, for JSON/LD, the error is on line 3

If the format used is not what should be, you need to specify a format in your code - for that, you'll have to add a snippet of the code you're using to parse your files.

Ignazio
  • 10,504
  • 1
  • 14
  • 25
  • Thank you for the information. The problem that I face is that I need to parse many ontologies (more than 600) to extract the list of imported ontologies from each of them. The previous error happened with around 100 ontologies. I do not know what to do with them. When I open the failed ones on Protege desktop, they open without any problem. I need a dynamic programming solution that can extract the needed information from any given ontology. Do you have any suggestions or snippets to load ontologies? – Kittani Sep 03 '18 at 20:32
  • We need at least one example of such ontologies and a snippet of the code used to load them, otherwise it's not possible to guess what might be going wrong. – Ignazio Sep 03 '18 at 21:59
  • OK, I can send you one of the failed ontologies, and the snippet I used to load them. Where should I send them? – Kittani Sep 03 '18 at 22:40
  • You can create an issue on the owlapi tracker https://github.com/owlcs/owlapi/issues – Ignazio Sep 04 '18 at 05:33
  • Done. You can find it at https://github.com/owlcs/owlapi/issues/782#issue-356669324 – Kittani Sep 04 '18 at 06:32