Reputation: 1091
I want to read the classes for the LNC/LOINC RDF/Turtle version from BioPortal as can be found at http://bioportal.bioontology.org/ontologies/LOINC/, newest submission.
My parsing code is as simple as
OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
ontologyManager.loadOntologyFromOntologyDocument(new File("LOINC.ttl"));
However, I get an error about no parser would be able to parse the ontology (shortened due to character limit):
Exception in thread "main" org.semanticweb.owlapi.io.UnparsableOntologyException: Problem parsing file:/home/faessler/Coding/workspace/bioportal-ontology-tools/LOINC.ttl
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:
1) org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser@3b9d6699
2) org.semanticweb.owlapi.owlxml.parser.OWLXMLParser@2ad3a1bb
3) org.semanticweb.owlapi.functional.parser.OWLFunctionalSyntaxOWLParser@120f38e6
4) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.RioTurtleDocumentFormatFactory@95fd655c
5) org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParser@3ad394e6
6) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.NQuadsDocumentFormatFactory@6f9c39ad
7) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.RDFJsonDocumentFormatFactory@cd748dc3
8) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.NTriplesDocumentFormatFactory@937ecd36
9) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.TrigDocumentFormatFactory@27e81c
10) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.RDFJsonLDDocumentFormatFactory@dcacc47d
11) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.N3DocumentFormatFactory@9a5
12) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.RioRDFXMLDocumentFormatFactory@69b9a3bc
13) org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser@5b43e173
14) org.semanticweb.owlapi.rio.RioTrixParserFactory$TrixParserImpl : org.semanticweb.owlapi.formats.TrixDocumentFormatFactory@27e82d
15) org.semanticweb.owlapi.oboformat.OBOFormatOWLAPIParser@13cda7c9
16) org.semanticweb.owlapi.dlsyntax.parser.DLSyntaxOWLParser@1da6ee17
17) org.semanticweb.owlapi.krss2.parser.KRSS2OWLParser@253c1256
18) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.BinaryRDFDocumentFormatFactory@3bf24493
19) org.coode.owlapi.obo12.parser.OWLOBO12Parser@c827db
20) org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.RDFaDocumentFormatFactory@264e8d
Detailed logs:
--------------------------------------------------------------------------------
SNIP
--------------------------------------------------------------------------------
Parser: org.semanticweb.owlapi.rio.RioParserImpl : org.semanticweb.owlapi.formats.RioTurtleDocumentFormatFactory@95fd655c
Stack trace:
org.openrdf.rio.UnsupportedRDFormatException: Did not recognise RDF format object Turtle (mimeTypes=text/turtle, application/x-turtle; ext=ttl) org.semanticweb.owlapi.rio.RioParserImpl.parse(RioParserImpl.java:138)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:175)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:997)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:961)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:910)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:922)
de.julielab.bioportal.ontologies.apps.Test.main(Test.java:43)
Did not recognise RDF format object Turtle (mimeTypes=text/turtle, application/x-turtle; ext=ttl) org.openrdf.rio.Rio.lambda$unsupportedFormat$0(Rio.java:630)
java.util.Optional.orElseThrow(Optional.java:290)
org.openrdf.rio.Rio.createParser(Rio.java:119)
org.semanticweb.owlapi.rio.RioParserImpl.parseDocumentSource(RioParserImpl.java:173)
org.semanticweb.owlapi.rio.RioParserImpl.parse(RioParserImpl.java:125)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:175)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:997)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:961)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:910)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:922)
--------------------------------------------------------------------------------
Parser: org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser@5b43e173
Stack trace:
org.semanticweb.owlapi.rdf.turtle.parser.ParseException: Encountered " <PN_CHARS> "- "" at line 3635316, column 64.
Was expecting:
"." ...
org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser.parse(TurtleOntologyParser.java:60)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:175)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:997)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:961)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:910)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:922)
de.julielab.bioportal.ontologies.apps.Test.main(Test.java:43)
Encountered " <PN_CHARS> "- "" at line 3635316, column 64.
Was expecting:
"." ...
org.semanticweb.owlapi.rdf.turtle.parser.TurtleParser.generateParseException(TurtleParser.java:1960)
org.semanticweb.owlapi.rdf.turtle.parser.TurtleParser.jj_consume_token(TurtleParser.java:1829)
org.semanticweb.owlapi.rdf.turtle.parser.TurtleParser.parseDocument(TurtleParser.java:111)
org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser.parse(TurtleOntologyParser.java:56)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:175)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:997)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:961)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:910)
uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:922)
de.julielab.bioportal.ontologies.apps.Test.main(Test.java:43)
SNIP
Protégé can load the file fine and even using a TurtleParser directly as in
java.net.URL documentUrl = new File("LOINC.ttl").toURI().toURL();
InputStream inputStream = documentUrl.openStream();
RDFParser rdfParser = new TurtleParser();
java.util.ArrayList myList = new ArrayList();
StatementCollector collector = new StatementCollector(myList);
rdfParser.setRDFHandler(collector);
try {
rdfParser.parse(inputStream, documentUrl.toString());
} catch (IOException | RDFParseException | RDFHandlerException e) {
e.printStackTrace();
}
runs through. I rely on the OWL-API, however.
I don't think there is a syntax error since Protégé can open the file without complaining (nothing special in the logs). I also tried shortened versions of the file because it is rather large. Using about half of the file works. But I didn't find anything about length limits of the OWL-API. And again. Protégé can open it.
It's the same with MESH.ttl and PDQ.ttl files on BioPortal. NCBITAXON.ttl works, however.
OWL-API version is 5.0.5, Protege 5.0beta for Mac was used to open the file successfully.
I would appreciate any hints very much because right now I really don't know what's the issue.
Thanks!
Upvotes: 0
Views: 1174
Reputation: 10659
There is no explicit limit in the owl api except for memory available and size of collections - which is limited to the max value an integer can assume.
What is the detailed log for this parser?
13) org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser@5b43e173
This is the turtle parser in owlapi itself, rather than the Rio parser.
Also, which version of owlapi and protégé are you using?
EDiT: with the error message for the parser, I was able to locate the failing line:
<http://purl.bioontology.org/ontology/LNC/LRN2> """3'''-acetate; [cut]"""^^xsd:string ;
The problem is the three quotes: '''
those are interpreted as equivalent to """
, which is the literal delimiter. Older OWLAPI behaved incorrectly with the specs in this, but it appears this literal is malformed and so it fails with newer OWLAPI. Protege Beta up to (I think) version 15 uses OWLAPI 3.5, which has an older parser.
I'm not sure if this can be corrected in the parsers or if the data needs to be fixed instead, at this stage. I'll raise an issue on GitHub. https://github.com/owlcs/owlapi/issues/610
Second edit: This is a bug; the literal should have been parsed correctly. See the relevant Turtle specs.
Upvotes: 0