Dgraphloader fail when using URI

Hi, i need help a bit here.

I have been trying hours without figuring out how to import rdf with URI using a schema.
I want to import this owl-ontology https://raw.githubusercontent.com/obophenotype/cell-ontology/master/cl.owl

First I convert it to nquad using Jena Riot
riot --stream=nq --compress cl.owl > cl.rdf.gz
cl.rdf seems to be in the right format:

<http://purl.obolibrary.org/obo/cl.owl> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Ontology> .
<http://purl.obolibrary.org/obo/cl.owl> <http://www.w3.org/2002/07/owl#versionIRI> <http://purl.obolibrary.org/obo/cl/releases/2017-04-14/cl.owl> .
<http://purl.obolibrary.org/obo/cl.owl> <http://www.w3.org/2002/07/owl#imports> <http://purl.obolibrary.org/obo/cl/imports/pato_import.owl> .

Using a small custom-made script, I write a list of all predicates into a schema:

<http://www.geneontology.org/formats/oboInOwl#hasNarrowSynonym>: uid .
<http://www.w3.org/2002/07/owl#annotatedSource>: uid .
<http://www.w3.org/2002/07/owl#annotatedTarget>: uid .
....
<http://www.w3.org/2002/07/owl#equivalentClass>: uid .
<http://www.w3.org/2002/07/owl#complementOf>: uid .
<http://purl.org/dc/elements/1.1/creator>: uid .
<_xid_>: string @index(exact) .

When running this command:
dgraphloader -x -r cl.rdf.gz -s schema.txt

I get errors complaining about all predicates
Retrying req: 48. Error: rpc error: code = Unknown desc = failed to apply mutations error: internal error: Input for predicate http://www.w3.org/2002/07/owl#annotatedTarget of type scalar is uid

My dgraph version is v0.7.7-dev and I have already deleted the p and w folders to reset.
Could you please provide me some hint ? The example does not use URI and I don’t understand how to solve this using the documentation.

Best

JP

Hi,

Looks like the ontology has some errors in it. Annotations are meant to work like this

https://www.w3.org/TR/owl2-mapping-to-rdf/#Translation_of_Axioms_with_Annotations

That is annotatedTarget and annotatedSource should always point to a node in the graph and the annotation itself can be an rdfs:comment.

In the RDF generated by jena, however, annotatedTarget points to both URIs and strings, so that’s why Dgraph outputs the error because we can’t have a predicate that points to both strings and nodes.

Looks like the original XML/OWL file has errors in the way it presents the axioms. What generated them? I would have expected more like

<owl:Class rdf:about="http://www.semanticweb.org/michael/ontologies/2017/5/untitled-ontology-31#A">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/michael/ontologies/2017/5/untitled-ontology-31#B"/>
</owl:Class>
<owl:Axiom>
    <rdfs:comment>this is my annotion</rdfs:comment>
    <owl:annotatedSource rdf:resource="http://www.semanticweb.org/michael/ontologies/2017/5/untitled-ontology-31#A"/>
    <owl:annotatedTarget rdf:resource="http://www.semanticweb.org/michael/ontologies/2017/5/untitled-ontology-31#B"/>
    <owl:annotatedProperty rdf:resource="&rdfs;subClassOf"/>
</owl:Axiom>

Hi Michael

thank you for your answer.
Indeed, there are a lot of predicates that point to both strings and nodes and hinder the importing process when using a schema. They were generated with Protege and even a simple ontology such as the Pizza has the same type of errors ?

In OWL, a single predicate can have objects either URI or strings. Is this limitation you mentioned related to Dgraph specifically or I am doing something wrong while converting them to Rdf ?

Actually, I have figured out this paragraph: OWL 2 Web Ontology Language Mapping to RDF Graphs (Second Edition)

If axioms have more than two classes, it will first introduce an intermediate blank node.
In my owl file, the number of axiom per class is variable, (some with only one axiom, others with several).
This lack of consistency breaks the logic of some predicates and the schema definition as scalar or uid

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.