From: Blom, J.J.C. (Jaap) <jb...@cr...> - 2010-06-18 15:04:02
|
Hi, I'm working on NG4J 0.9.3 and have the following code: Node graph1 = Node.createURI("http://graph1"); Node graph2 = Node.createURI("http://graph2"); Node start = Node.createURI("http://start"); Node predicate1 = Node.createURI("http://predicate1"); Node predicate2 = Node.createURI("http://predicate2"); Node result1 = Node.createLiteral("expected result"); Node result2 = Node.createLiteral("not expected result"); NamedGraphSet ngs = new NamedGraphSetImpl(); ngs.addQuad(new Quad(graph1, start, predicate1, Node.createAnon(new AnonId("blank")))); ngs.addQuad(new Quad(graph1, Node.createAnon(new AnonId("blank")), predicate2, result1)); ngs.addQuad(new Quad(graph2, Node.createAnon(new AnonId("blank")), predicate2, result2));//*/ String query = "Select ?target Where\n" + "{\n" + " <" + start.getURI() + "> <" + predicate1.getURI() + "> ?b .\n" + " ?b <" + predicate2.getURI() + "> ?target\n" + "}"; System.out.println(query); Query sparqlQuery = QueryFactory.create(query); QueryExecution qe = QueryExecutionFactory.create(sparqlQuery, new NamedGraphDataset(ngs)); ResultSet results = qe.execSelect(); while(results.hasNext()) { System.out.println(results.next()); } System.out.println("done"); This gives the following result: Select $target Where { <http://start> <http://predicate1> ?b . ?b <http://predicate2> $target } ( ?target = "expected result" ) ( ?target = "not expected result" ) done I didn't expect the "not expected result", since it is linked to a blank node in another graph. Granted the blank nodes have the same label, but RDF states that blank nodes in different graphs are not linked by their label. Am I correct in this one and if so is this a NG4J error or a Jena/ARQ error? Greetings, Jaap Blom ________________________________ http://www.croon.nl/disclaimer http://www.croon.nl/inkoopvoorwaarden Kamer van Koophandel Rotterdam nr. / Chamber of Commerce Rotterdam no.: 24002312 |
From: Olaf H. <ha...@in...> - 2010-06-19 07:24:38
|
Hey, On Friday 18 June 2010 17:03:54 Blom, J.J.C. (Jaap) wrote: > Hi, > > I'm working on NG4J 0.9.3 and have the following code: > Node graph1 = Node.createURI("http://graph1"); > Node graph2 = Node.createURI("http://graph2"); > Node start = Node.createURI("http://start"); > Node predicate1 = Node.createURI("http://predicate1"); > Node predicate2 = Node.createURI("http://predicate2"); > Node result1 = Node.createLiteral("expected result"); > Node result2 = Node.createLiteral("not expected result"); > NamedGraphSet ngs = new NamedGraphSetImpl(); > ngs.addQuad(new Quad(graph1, start, predicate1, > Node.createAnon(new AnonId("blank")))); ngs.addQuad(new Quad(graph1, > Node.createAnon(new AnonId("blank")), predicate2, result1)); > ngs.addQuad(new Quad(graph2, Node.createAnon(new AnonId("blank")), > predicate2, result2));//*/ String query = > "Select ?target Where\n" + > "{\n" + > " <" + start.getURI() + "> <" + > predicate1.getURI() + "> ?b .\n" + " ?b <" + predicate2.getURI() + > "> ?target\n" + "}"; > System.out.println(query); > Query sparqlQuery = QueryFactory.create(query); > QueryExecution qe = > QueryExecutionFactory.create(sparqlQuery, new NamedGraphDataset(ngs)); > ResultSet results = qe.execSelect(); > while(results.hasNext()) > { > System.out.println(results.next()); > } > System.out.println("done"); > > This gives the following result: > Select $target Where > { > <http://start> <http://predicate1> ?b . > ?b <http://predicate2> $target > } > ( ?target = "expected result" ) > ( ?target = "not expected result" ) > done > > I didn't expect the "not expected result", since it is linked to a blank > node in another graph. Granted the blank nodes have the same label, but > RDF states that blank nodes in different graphs are not linked by their > label. Am I correct in this one and if so is this a NG4J error or a > Jena/ARQ error? I agree that you would expect only the "expected result" and that would be the correct behavior. The issue is that none ever expected to have two blank nodes with the same label in different graphs. Usually, this would never happen because Jena creates new blank node with unique labels whenever it reads an RDF document. Programmatically, you would typically create a Node object that represents your blank node and use this Node object instead of creating new Node objects with the same label. Hence, to me it seems that your example code uses the Jena API in a way it was not intended to be used. Why do you want to do it the way your example code outlines? Greetings, Olaf PS: I cannot answer the other questions you sent to the list because I'm not familiar with that part of NG4J. |
From: Blom, J.J.C. (Jaap) <jb...@cr...> - 2010-06-20 06:56:53
|
Hi, Wel for a number of reasons: A) It reads a little easier to track a blank node with a readable label in respect to a UID. B) Data received from sources not using NG4J/Jena (and thus not supporting this "rule" of uniquely naming blank nodes) C) Because I should be able to do it. The RDF defenitions specify that two blank nodes with the same label in different graphs should not be considered the same node on that fact alone. (Sorry if I seem to be ranting here) Like I said I doubt this is a bug from NG4J (I think it is Jena in this case), but since there are some elements from NG4J involved I need to be sure of this. Thanks, Jaap Blom -----Original Message----- From: Olaf Hartig [mailto:ha...@in...] Sent: zaterdag 19 juni 2010 9:24 To: Blom, J.J.C. (Jaap) Cc: ng4...@li... Subject: Re: [namedgraphs] SPARQL over named graphs with blank nodes Hey, On Friday 18 June 2010 17:03:54 Blom, J.J.C. (Jaap) wrote: > Hi, > > I'm working on NG4J 0.9.3 and have the following code: > Node graph1 = Node.createURI("http://graph1"); > Node graph2 = Node.createURI("http://graph2"); > Node start = Node.createURI("http://start"); > Node predicate1 = Node.createURI("http://predicate1"); > Node predicate2 = Node.createURI("http://predicate2"); > Node result1 = Node.createLiteral("expected result"); > Node result2 = Node.createLiteral("not expected result"); > NamedGraphSet ngs = new NamedGraphSetImpl(); > ngs.addQuad(new Quad(graph1, start, predicate1, > Node.createAnon(new AnonId("blank")))); ngs.addQuad(new Quad(graph1, > Node.createAnon(new AnonId("blank")), predicate2, result1)); > ngs.addQuad(new Quad(graph2, Node.createAnon(new AnonId("blank")), > predicate2, result2));//*/ String query = > "Select ?target Where\n" + > "{\n" + > " <" + start.getURI() + "> <" + > predicate1.getURI() + "> ?b .\n" + " ?b <" + predicate2.getURI() + > "> ?target\n" + "}"; > System.out.println(query); > Query sparqlQuery = QueryFactory.create(query); > QueryExecution qe = > QueryExecutionFactory.create(sparqlQuery, new > NamedGraphDataset(ngs)); ResultSet results = qe.execSelect(); > while(results.hasNext()) > { > System.out.println(results.next()); > } > System.out.println("done"); > > This gives the following result: > Select $target Where > { > <http://start> <http://predicate1> ?b . > ?b <http://predicate2> $target } ( ?target = "expected result" > ) ( ?target = "not expected result" ) done > > I didn't expect the "not expected result", since it is linked to a > blank node in another graph. Granted the blank nodes have the same > label, but RDF states that blank nodes in different graphs are not > linked by their label. Am I correct in this one and if so is this a > NG4J error or a Jena/ARQ error? I agree that you would expect only the "expected result" and that would be the correct behavior. The issue is that none ever expected to have two blank nodes with the same label in different graphs. Usually, this would never happen because Jena creates new blank node with unique labels whenever it reads an RDF document. Programmatically, you would typically create a Node object that represents your blank node and use this Node object instead of creating new Node objects with the same label. Hence, to me it seems that your example code uses the Jena API in a way it was not intended to be used. Why do you want to do it the way your example code outlines? Greetings, Olaf PS: I cannot answer the other questions you sent to the list because I'm not familiar with that part of NG4J. http://www.croon.nl/disclaimer http://www.croon.nl/inkoopvoorwaarden Kamer van Koophandel Rotterdam nr. / Chamber of Commerce Rotterdam no.: 24002312 |
From: Olaf H. <ha...@in...> - 2010-06-21 10:38:21
|
Hey, On Sunday 20 June 2010 08:56:42 Blom, J.J.C. (Jaap) wrote: > Hi, > > Wel for a number of reasons: > A) It reads a little easier to track a blank node with a readable label in > respect to a UID. But only for debugging purposes. Right? I mean, this data is meant to be processed automatically and an application doesn't care about labels. > B) Data received from sources not using NG4J/Jena (and > thus not supporting this "rule" of uniquely naming blank nodes) I don't see a problem here. If you import such data into a Jena Model (or Graph) then Jena automatically creates unique blank node identifiers. > C) Because > I should be able to do it. The RDF defenitions specify that two blank > nodes with the same label in different graphs should not be considered the > same node on that fact alone. (Sorry if I seem to be ranting here) Okay. > Like I said I doubt this is a bug from NG4J (I think it is Jena in this > case), but since there are some elements from NG4J involved I need to be > sure of this. Yes, I think it is a problem in Jena. NG4J uses the Jena implementation of triple pattern matching over a union of RDF graphs which is implemented in the 'MultiUnion' class (package 'com.hp.hpl.jena.graph.compose'); more precisely, the method 'multiGraphFind' Greetings, Olaf |
From: Blom, J.J.C. (Jaap) <jb...@cr...> - 2010-06-25 14:08:30
|
Hi again, Sorry forgot about this for a bit. <snip> > But only for debugging purposes. Right? I mean, this data is meant to be processed automatically and an application doesn't care about labels. </snip> Well if that means that running in debugging mode actually enables bugs, that may not be the best approach. Since I had the choice of keeping the TRIX a bit readable or putting in labels that seemed to cause errors (not sure why and the details have since escaped me). So now I declare logical named blank nodes everywhere (assuming ARQ would hold itself to the principles of RDF). So I may want to turn back on that decision. <snip> > I don't see a problem here. If you import such data into a Jena Model (or > Graph) then Jena automatically creates unique blank node identifiers. </snip> Well actually I import it in TriX for transporting and I checked, that means the blank node labels aren't renamed. So that means I would need to loop through all the named graphs and do it. Not something I would want to implement for such a thing tbh. <snip> > Yes, I think it is a problem in Jena. NG4J uses the Jena implementation of triple pattern matching over a union of RDF graphs which is implemented in > > the 'MultiUnion' class (package 'com.hp.hpl.jena.graph.compose'); more precisely, the method 'multiGraphFind' </snip> Kay, thanks. Greetings, Jaap Blom http://www.croon.nl/disclaimer http://www.croon.nl/inkoopvoorwaarden Kamer van Koophandel Rotterdam nr. / Chamber of Commerce Rotterdam no.: 24002312 |
From: Jennifer C. <jen...@at...> - 2010-06-26 00:35:33
|
This probably is not related to the issues you are seeing, but it might be worth noting. Previously I had some problems in a particular use case including NG4J. Eventually tracked them down to the NG4J-provided parser for TriX. It appears that TriX is not fully supported by the parser. The problems were completely resolved by a single change - using TriG instead of TriX. This was not a matter of incorrectly written TriX on our system's part. Rather, we were beginning with a named graph model, writing as TriX and later reading in the TriX - all done using NG4J. Jennifer -----Original Message----- From: Blom, J.J.C. (Jaap) [mailto:jb...@cr...] Sent: Friday, June 25, 2010 10:08 AM To: ng4...@li... Subject: Re: [namedgraphs] SPARQL over named graphs with blank nodes Hi again, Sorry forgot about this for a bit. <snip> > But only for debugging purposes. Right? I mean, this data is meant to be processed automatically and an application doesn't care about labels. </snip> Well if that means that running in debugging mode actually enables bugs, that may not be the best approach. Since I had the choice of keeping the TRIX a bit readable or putting in labels that seemed to cause errors (not sure why and the details have since escaped me). So now I declare logical named blank nodes everywhere (assuming ARQ would hold itself to the principles of RDF). So I may want to turn back on that decision. <snip> > I don't see a problem here. If you import such data into a Jena Model (or > Graph) then Jena automatically creates unique blank node identifiers. </snip> Well actually I import it in TriX for transporting and I checked, that means the blank node labels aren't renamed. So that means I would need to loop through all the named graphs and do it. Not something I would want to implement for such a thing tbh. <snip> > Yes, I think it is a problem in Jena. NG4J uses the Jena implementation of triple pattern matching over a union of RDF graphs which is implemented in > > the 'MultiUnion' class (package 'com.hp.hpl.jena.graph.compose'); more precisely, the method 'multiGraphFind' </snip> Kay, thanks. Greetings, Jaap Blom http://www.croon.nl/disclaimer http://www.croon.nl/inkoopvoorwaarden Kamer van Koophandel Rotterdam nr. / Chamber of Commerce Rotterdam no.: 24002312 -------------------------------------------------------------------------- ---- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ ng4j-namedgraphs mailing list ng4...@li... https://lists.sourceforge.net/lists/listinfo/ng4j-namedgraphs |
From: Olaf H. <ha...@in...> - 2010-06-26 16:39:16
|
Hey, On Friday 25 June 2010 16:07:59 Blom, J.J.C. (Jaap) wrote: > [...] > > I don't see a problem here. If you import such data into a Jena Model (or > > Graph) then Jena automatically creates unique blank node identifiers. > > </snip> > > Well actually I import it in TriX for transporting and I checked, that > means the blank node labels aren't renamed. So that means I would need to > loop through all the named graphs and do it. Not something I would want to > implement for such a thing tbh. You mean you import a TriX document in NG4J, right? Unlike the other parsers (RDF/XML, Turtle, etc.) that are implemented in Jena, the TriX parser is part of NG4J, I think. That might be the reason why data imported from TriX documents has the same blank node labels internally than in the document. Greetings, Olaf |