Hi again Jiba,
I might have detected another bug concerning annotation properties which might be related to my recent bug report (and blank nodes): http://owlready.8326.n8.nabble.com/Bug-fix-request-Querying-annotations-in-Owlready2-0-19-and-higher-td1330.html. This time, I would like to delete annotated properties via SPARQL Update queries. The ontology is the same as last time: 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> CODE ontology = or2.get_ontology(file).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 = """DELETE { ?annotation ?p ?o . onto:individual1 onto:op1 onto:individual2 . } WHERE { ?annotation owl:annotatedSource onto:individual1 . ?annotation owl:annotatedProperty onto:op1 . ?annotation owl:annotatedTarget onto:individual2 . ?annotation ?p ?o . }""" graph.update(delete_query) Using Owlready2 0.18, the targeted relation is correctly deleted. Using the development version produces the following error: Traceback (most recent call last): File "***.py", line 58, in <module> graph.update(delete_query) File "/home/maris/PycharmProjects/ontology-interface/venv/lib/python3.6/site-packages/rdflib/graph.py", line 1112, in update return processor.update(update_object, initBindings, initNs, **kwargs) File "/home/maris/PycharmProjects/ontology-interface/venv/lib/python3.6/site-packages/rdflib/plugins/sparql/processor.py", line 56, in update return evalUpdate(self.graph, strOrQuery, initBindings) File "/home/maris/PycharmProjects/ontology-interface/venv/lib/python3.6/site-packages/rdflib/plugins/sparql/update.py", line 305, in evalUpdate evalModify(ctx, u) File "/home/maris/PycharmProjects/ontology-interface/venv/lib/python3.6/site-packages/rdflib/plugins/sparql/update.py", line 173, in evalModify dg -= _fillTemplate(u.delete.triples, c) File "/home/maris/PycharmProjects/ontology-interface/venv/lib/python3.6/site-packages/rdflib/graph.py", line 568, in __isub__ self.remove(triple) File "/home/maris/PycharmProjects/ontology-interface/venv/lib/python3.6/site-packages/rdflib/graph.py", line 415, in remove self.__store.remove((s, p, o), context=self) File "/home/maris/PycharmProjects/ontology-interface/venv/lib/python3.6/site-packages/owlready2/rdflib_store.py", line 143, in remove elif (s < 0) and (s in triplelite.ontology._bnodes): sub = triplelite.ontology._bnodes[s] NameError: name 'triplelite' is not defined Thanks again for your help! Best, Marie |
Administrator
|
Hi,
There was a problem in SPARQL deletion on blank node. I've just fixed it in the development version, Enjoy, Jiba |
Free forum by Nabble | Edit this page |