Bug fix request: Querying annotations in Owlready2 0.19 and higher

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug fix request: Querying annotations in Owlready2 0.19 and higher

Marie
Hello Jiba,

it seems I have detected a bug concerning SPARQL queries involving annotation properties. When I execute a SPARQL query with of the following code using Owlready2 0.18, I get a correct result:


CODE

ontology = or2.get_ontology(file_location).load()

graph = or2.default_world.as_rdflib_graph()

graph.bind("owl", "http://www.w3.org/2002/07/owl#")
graph.bind("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
graph.bind("onto", ontology.base_iri)

query = "SELECT ?label WHERE { ?annotation owl:annotatedSource onto:individual1 ; owl:annotatedTarget onto:individual2 ; rdfs:comment ?label . }"

result = list(graph.query(query))
print(result)



ONTOLOGY

<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.example/or2_swrl#"
     xml:base="http://www.example/or2_swrl"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:swrl="http://www.w3.org/2003/11/swrl#">
    <owl:Ontology rdf:about="http://www.example/or2_swrl"/>
   


   

   


   

    <owl:ObjectProperty rdf:about="http://www.example/or2_swrl#op1"/>
   


   

    <owl:ObjectProperty rdf:about="http://www.example/or2_swrl#op2"/>
   


   

   


   

    <owl:Class rdf:about="http://www.example/or2_swrl#A"/>
   


   

   


   

    <owl:NamedIndividual rdf:about="http://www.example/or2_swrl#individual1">
        <rdf:type rdf:resource="http://www.example/or2_swrl#A"/>
        <op1 rdf:resource="http://www.example/or2_swrl#individual2"/>
    </owl:NamedIndividual>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://www.example/or2_swrl#individual1"/>
        <owl:annotatedProperty rdf:resource="http://www.example/or2_swrl#op1"/>
        <owl:annotatedTarget rdf:resource="http://www.example/or2_swrl#individual2"/>
        <rdfs:comment>test</rdfs:comment>
    </owl:Axiom>
   


   

    <owl:NamedIndividual rdf:about="http://www.example/or2_swrl#individual2">
        <rdf:type rdf:resource="http://www.example/or2_swrl#A"/>
    </owl:NamedIndividual>
</rdf:RDF>


The same SPARQL query executed with Owlready2 0.19 delivers no result. The code is identical in both cases. This could be related to some changes that were made to Owlready2 from version 0.18 to 0.19.

Many thanks in advance!

Marie
Reply | Threaded
Open this post in threaded view
|

Re: Bug fix request: Querying annotations in Owlready2 0.19 and higher

Jiba
Administrator
Hello,

You are right, there was a problem in version 0.19/0.20, related to blank nodes with RDFlib.

I fixed it in the development version on Bitbucket.

Thank you for reporting this problem,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Bug fix request: Querying annotations in Owlready2 0.19 and higher

Marie
Hi Jiba,

I just installed the development version and it seems to work now. Thank you for the fix!

Best,
Marie