0

I want to make an update for the following: Delete the triple (o,p,s) if the other direction (s,p,o) exists. My query looks as follows:

DELETE {?s ?p ?o} where {
?s <http://n1> ?o .
FILTER (EXISTS {?o <http://n1> ?s } && (str(?s) > str(?o) ))  
}

My model is the following:

<http://0> <http://n1> <http://1> .
<http://1> <http://n1> <http://0> .

My intention is to only delete one of the two triples (it does not matter which one). But the update deletes both triples. How can I change that?

Philip Frerk
  • 91
  • 1
  • 1
  • 11
  • add a filter which takes only one of both triples based on the order of the URIs: `filter(str(?s) > str(?o))` – UninformedUser May 07 '19 at 10:35
  • I tried that (you can see the query above). But still it deletes both triples – Philip Frerk May 07 '19 at 11:56
  • That can't be. I also tried it on my laptop. First of all, now you have a SELECT query here which by the way has no `p` bound in the query body. Moreover, again, I don'T see how you execute the query. I tried the SELECT query (without the `?p`), it returns a single row as expected. I tried the `DELETE` query with the filter, it works as expected. Last time you had some issues somewhere else in your code. Would be good if you check those in advance. All I can say, the query with my suggested FILTER does what it is supposed to do. Unless I'm totally stupid – UninformedUser May 07 '19 at 12:12
  • my result with the SELECT query: `--------------------------- | s | o | =========================== | | | ---------------------------` – UninformedUser May 07 '19 at 12:13
  • with the DELETE query: ` .` – UninformedUser May 07 '19 at 12:13
  • @PhilipFrerk add the `filter(str(?s) > str(?o))` within the `EXISTS{}` – Damyan Ognyanov May 07 '19 at 12:14
  • @DamyanOgnyanov why? the query works, I tried it with the given data. Or what am I doing wrong here? – UninformedUser May 07 '19 at 12:15
  • 1
    Yes it works, I made another mistake :) – Philip Frerk May 07 '19 at 12:38
  • I have to sleep longer – Philip Frerk May 07 '19 at 12:39
  • Maybe ... by the way, what are you trying to achieve in general? Based on your previous questions, it looks a bit like you're trying to apply compression to the RDF graph by means of removing triples that can be inferred via inference rules. Are you preparing the RDF data with that procedure for some inference benchmark? – UninformedUser May 07 '19 at 12:45
  • Yes i write my masters thesis at the working of Axel Ngonga. I try to use the ontology knowledge in order to change the graph in such a way that it is better compressible by a grammar-based compressor. – Philip Frerk May 07 '19 at 12:52

0 Answers0