owlcs / owlapi

OWL API main repository
822 stars 315 forks source link

UNPARSED TRIPLES ERROR for class assertions #1023

Closed cmungall closed 2 years ago

cmungall commented 2 years ago

This ttl yields an error

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.w3.org/2002/07/owl#> .

[ rdf:type owl:Ontology
 ] .

#################################################################
#    Object Properties
#################################################################

###  http://purl.obolibrary.org/obo/BFO_0000051
<http://purl.obolibrary.org/obo/BFO_0000051> rdf:type owl:ObjectProperty .

#################################################################
#    Classes
#################################################################

###  http://purl.obolibrary.org/obo/ENVO_00000191
<http://purl.obolibrary.org/obo/ENVO_00000191> rdf:type owl:Class .

#################################################################
#    Individuals
#################################################################

###  https://www.wikidata.org/wiki/Q2306597
<https://www.wikidata.org/wiki/Q2306597> rdf:type owl:NamedIndividual ,
                                                  [ rdf:type owl:Restriction ;
                                                    owl:onProperty <http://purl.obolibrary.org/obo/BFO_0000051> ;
                                                    owl:someValuesFrom <http://purl.obolibrary.org/obo/ENVO_00000191>
                                                  ] .

###  Generated by the OWL API (version 4.5.6) https://github.com/owlcs/owlapi

Note that this was in fact generated by the owlapi from simpler functional syntax:

ClassAssertion(<http://purl.obolibrary.org/obo/ENVO_01000216> <https://www.wikidata.org/wiki/Q2306597>)
ClassAssertion(ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/BFO_0000051> <http://purl.obolibrary.org/obo/ENVO_00000191>) <https://www.wikidata.org/wiki/Q2306597>)

When I parse this using robot using --strict with -vvv I get:

2021-10-08 12:34:04,432 WARN  org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer - STRICT: Not adding implicit type iri=_:genid-nodeid-node1fhgmbtbfx2 types=[http://www.w3.org/2002/07/owl#Thing, http://www.w3.org/2002/07/owl#Nothing, http://purl.obolibrary.org/obo/ENVO_00000191]
2021-10-08 12:34:04,432 WARN  org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer - STRICT: Not adding implicit type iri=_:genid-nodeid-node1fhgmbtbfx2 types=[_:genid-nodeid-node1fhgmbtbfx2]
2021-10-08 12:34:04,432 WARN  org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer - STRICT: Not adding implicit type iri=_:genid-nodeid-node1fhgmbtbfx2 types=[_:genid-nodeid-node1fhgmbtbfx2]
2021-10-08 12:34:04,432 WARN  org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer - STRICT: Not adding implicit type iri=https://www.wikidata.org/wiki/Q2306597 types=[https://www.wikidata.org/wiki/Q2306597]
2021-10-08 12:34:04,432 WARN  org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer - STRICT: Not adding implicit type iri=_:genid-nodeid-node1fhgmbtbfx2 types=[http://www.w3.org/2002/07/owl#Thing, http://www.w3.org/2002/07/owl#Nothing, http://purl.obolibrary.org/obo/ENVO_00000191]
2021-10-08 12:34:04,432 DEBUG org.semanticweb.owlapi.rdf.rdfxml.parser.TripleLogger - Total number of triples: 8
2021-10-08 12:34:04,444 DEBUG org.semanticweb.owlapi.rdf.rdfxml.parser.TripleLogger - Loaded OntologyID(Anonymous-2)
2021-10-08 12:34:04,444 INFO  org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer - Unparsed triple: https://www.wikidata.org/wiki/Q2306597 -> http://www.w3.org/1999/02/22-rdf-syntax-ns#type -> _:genid-nodeid-node1fhgmbtbfx2
2021-10-08 12:34:04,444 DEBUG org.semanticweb.owlapi.rio.RioParserImpl$RioParserRDFHandler - owlParse: timing=27
2021-10-08 12:34:04,444 DEBUG org.semanticweb.owlapi.rio.RioParserImpl - rioParse: timing=27
UNPARSED TRIPLES ERROR input ontology contains 1 triple(s) that could not be parsed:
 - <https://www.wikidata.org/wiki/Q2306597> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> _:genid-nodeid-node1fhgmbtbfx2.

For details see: http://robot.obolibrary.org/errors#unparsed-triples-error
java.io.IOException: errors#UNPARSED TRIPLES ERROR input ontology contains 1 triple(s) that could not be parsed:
 - <https://www.wikidata.org/wiki/Q2306597> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> _:genid-nodeid-node1fhgmbtbfx2.

        at org.obolibrary.robot.IOHelper.loadOntology(IOHelper.java:577)
        at org.obolibrary.robot.IOHelper.loadOntology(IOHelper.java:417)
        at org.obolibrary.robot.IOHelper.loadOntology(IOHelper.java:298)
        at org.obolibrary.robot.CommandLineHelper.getInputOntologies(CommandLineHelper.java:1064)
        at org.obolibrary.robot.CommandLineHelper.getInputOntologies(CommandLineHelper.java:522)
        at org.obolibrary.robot.MergeCommand.execute(MergeCommand.java:114)
        at org.obolibrary.robot.CommandManager.executeCommand(CommandManager.java:248)
        at org.obolibrary.robot.CommandManager.execute(CommandManager.java:192)
        at org.obolibrary.robot.CommandManager.main(CommandManager.java:139)
        at org.obolibrary.robot.CommandLineInterface.main(CommandLineInterface.java:60)

I believe this is the OWLAPI rather than robot.

If I leave off --strict then it parses this correctly (saving to ofn verifies this). However, it still produces the "unparsed triple" as an INFO level logging. statement. ROBOT intercepts this and logs it as an ERROR which is disturbing to some users.

See also #988 where we discuss the strict option.

ignazio1977 commented 2 years ago

I was aware some calls to consume triples were not working, as visible in the logging:

TripleLogger - s=<_:genid-nodeid-node1fhl6m9evx1> p=rdf:type o=owl:Ontology
OWLRDFConsumer - consuming triple failed
TripleLogger - s=<_:genid-nodeid-node1fhl6m9evx2> p=rdf:type o=owl:Restriction
OWLRDFConsumer - consuming triple failed
OWLRDFConsumer - Unparsed triple: https://www.wikidata.org/wiki/Q2306597 -> rdf:type -> _:genid-nodeid-node1fhl6m9evx2

It's taken me quite a bit to realise the unparsed triple is not one where the triple cannot be consumed; rather, for class assertions the consume call is not made at all. The other failures are misleading, as the triples to be consumed are actually dealt with without explicit entries in the maps, and so don't actually need to be consumed. Ironic.