0

I am working on ontology reconciliation between two ontologies. I apply the jena/pellet platform, locally, and apply sparql rules as much as possible. For inserts this is successful, for deletes it is not, no matter what I try. This raises the question whether sparql deletes are supported at all with jena/pellet. Please advise!

Please find the related code snippets below. First the code, then the sparql DELETE query.

public void executeDelete(String mySparqlFile, OntModel o ) {
  UpdateRequest updateObj = null;
  UpdateProcessor up = null;
  GraphStore graphStore = GraphStoreFactory.create();

  graphStore.setDefaultGraph( o.getGraph() );

  updateObj = UpdateFactory.read( mySparqlFile );
  up = UpdateExecutionFactory.create(updateObj, graphStore);
  up.execute();
}


public static void main() {
  static OntModel ontModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, rawModel);
  static OntModel stanfordModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);

  stanfordModel.read("path/to/modelA.owl");
  ontModel.addSubModel(stanfordModel);

  executeDelete("path/to/delQuery.sparql", ontModel);
}

the file "delQuery.sparql"

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX stfd: <http://www.semanticweb.org/brandtp/ontologies/2014/6/Goose-stanford-metamodel.owl#>

DELETE { ?c a stfd:Token . }
WHERE { 
    ?c stfd:hasFeature stfd:Determiner . 
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • 1
    How do you know it's not working? Without seeing any of your data, we can't know whether `?c stfd:hasFeature stfd:Determiner` should match anything or not. While all software can have bugs, I think it's much more likely that there's a bug in your code or data than that "SPARQL DELETE [is] not possible in jena/pellet?" However, the fact that you're asking abot Pellet does raise the question of whether you're trying to delete *inferred* triples. You might not be able to do that, because they "exist" based on Pellet saying they exist when someone asks for them. If you want to be able to... – Joshua Taylor Nov 25 '14 at 11:46
  • 1
    ...delete inferred triples, you'd need to save all the inferred triples to a static graph in advance, and then you could delete from that. – Joshua Taylor Nov 25 '14 at 11:46
  • [Jena TDB after reason then update](http://stackoverflow.com/q/24924684/1281433) might be relevant. – Joshua Taylor Nov 25 '14 at 11:48
  • I'm not expert in the Pellet + Jena area but I would posit Pellet needs to know about the update before it can change its answers - if there is a flush/update method on the OntReasoner interface, it is probably necessary to call it before a delete query can take effect. This might also happen at other levels, as pointed out by Joshua. – Ignazio Nov 25 '14 at 23:45
  • @plbt5 That's what I was asking you. You've shown us a query, but without knowing what your *data* is, how do we know whether that query should actually have any effect? What if `?c stfd:hasFeature stfd:Determiner` doesn't match anything? Then nothing would be deleted, but the query would be working as it's supposed to. Without seeing your data we can't know where the problem is. – Joshua Taylor Nov 26 '14 at 16:05
  • @JoshuaTaylor: How do you know it is not working? When I query the store for what should have been deleted, i.e., `SELECT * WHERE { ?c stfd:hasFeature stfd:Determiner . }`, then it responds with exactly the data that I wanted to get rid off. Of course, the source of the problem may very well lay with an incorrect matching between my code and my data. I just wanted to poll whether others have been capable of deleting data, and whether my code is fundamentally flawed or not. This would be valuable information for me to select the path of debugging to follow. – Paul Brandt Nov 26 '14 at 16:12
  • @plbt5 `?c stfd:hasFeature stfd:Determiner` isn't what's supposed to get deleted. Your query is supposed to delete `?c a stfd:Token` when `?c stfd:hasFeature stfd:Determiner` matches. It removes the `?c a stfd:Token`, but leaves the `?c stfd:hasFeature stfd:Determiner` in the data. `SELECT * WHERE { ?c stfd:hasFeature stfd:Determiner . }` doesn't check whether your delete did anything. This is why it's important to explain *why* it appears that something isn't working; it's one of the places that something could be off. – Joshua Taylor Nov 26 '14 at 16:14

0 Answers0