antoniogarrote / rdfstore-js

JS RDF store with SPARQL support
MIT License
564 stars 109 forks source link

?x ?p ?x issue #28

Closed cmatheus closed 12 years ago

cmatheus commented 12 years ago

I'm trying to write some queries that match triples having the same resource for the subject and object, i.e. "WHERE {?x ?p ?x}". in the examples below (one CONSTRUCT the other a SELECT) there are no triples that match this pattern and yet the queries are returning results.

am I missing something here or is this a bug?

thanks!

require('rdfstore').create(function(store) {
    store.load(
        'text/n3', 
        '<http://A> <http://B> <http://C>.',
        function(success) {
            store.execute(
                'CONSTRUCT { ?x ?p ?x } WHERE { ?x ?p ?x }',
                function(success, results) {
                    results.triples.forEach(function(result){
                       console.log(result.subject.nominalValue,
                                    result.predicate.nominalValue,  
                                    result.object.nominalValue);
                       });
                 }
            );
        }); 
 });

// => http://C http://B http://C

require('rdfstore').create(function(store) {
    store.load(
        'text/n3', 
        '<http://A> <http://B> <http://C>.',
        function(success) {
            store.execute(
                'SELECT * WHERE { ?x ?p ?x }',
                function(success, results) {
                    results.forEach(function(result){
                       console.log(result.x.value,
                                    result.p.value);
                       });
                 }
            );
        }); 
});

// => http://C http://B
antoniogarrote commented 12 years ago

Hi, yes it was a bug. I can't believe we didn't come across this before It should be fixed in the new version. Thanks for reporting it.

Regards.

On Wed, May 2, 2012 at 3:10 PM, cmatheus < reply@reply.github.com

wrote:

I'm trying to write some queries that match triples having the same resource for the subject and object, i.e. "WHERE {?x ?p ?x}". in the examples below (one CONSTRUCT the other a SELECT) there are no triples that match this pattern and yet the queries are returning results.

am I missing something here or is this a bug?

thanks!

require('rdfstore').create(function(store) {
       store.load(
               'text/n3',
               '<http://A> <http://B> <http://C>.',
               function(success) {
                       store.execute(
                               'CONSTRUCT { ?x ?p ?x } WHERE { ?x ?p ?x }',
                               function(success, results) {

 results.triples.forEach(function(result){

console.log(result.subject.nominalValue,

 result.predicate.nominalValue,

 result.object.nominalValue);
                                          });
                                }
                       );
               });
 });

// => http://C http://B http://C

require('rdfstore').create(function(store) {
       store.load(
               'text/n3',
               '<http://A> <http://B> <http://C>.',
               function(success) {
                       store.execute(
                               'SELECT * WHERE { ?x ?p ?x }',
                               function(success, results) {
                                       results.forEach(function(result){
                                          console.log(result.x.value,

 result.p.value);
                                          });
                                }
                       );
               });
});

// => http://C http://B

Reply to this email directly or view it on GitHub: https://github.com/antoniogarrote/rdfstore-js/issues/28

cmatheus commented 12 years ago

Antonio,

Thanks for the quick fix! And for all of your effort on rdfstore.js!

I'm using rdfstore for some advanced research on using semantics for network management and control (mostly with UPnP). everything I'm doing is in javascript/node.js so I'm really pleased to have come across your js rdfstore (I plugged it heavily at the IEEE graph data management workshop last month so perhaps you saw a spike in downloads).

I'm woking on adding owl 2 rl rules to rdfstore to support some of the work I'm doing. If you're interested in including this in the distribution I can look into whether Bell Labs legal will let me put this in the public domain. I also have some code to let it work through a corporate firewall which I'm happy to share (will probably need to get permission though). Plus I'd personally like to release everything I'm doing into the public domain but I'm not sure how the company feels about that yet.

Cheers, Chris


From: Antonio Garrote [reply@reply.github.com] Sent: 03 May 2012 10:28 To: Matheus, Chris (Chris) Subject: Re: [rdfstore-js] ?x ?p ?x issue (#28)

Hi, yes it was a bug. I can't believe we didn't come across this before It should be fixed in the new version. Thanks for reporting it.

Regards.

On Wed, May 2, 2012 at 3:10 PM, cmatheus < reply@reply.github.com

wrote:

I'm trying to write some queries that match triples having the same resource for the subject and object, i.e. "WHERE {?x ?p ?x}". in the examples below (one CONSTRUCT the other a SELECT) there are no triples that match this pattern and yet the queries are returning results.

am I missing something here or is this a bug?

thanks!

require('rdfstore').create(function(store) {
       store.load(
               'text/n3',
               '<http://A> <http://B> <http://C>.',
               function(success) {
                       store.execute(
                               'CONSTRUCT { ?x ?p ?x } WHERE { ?x ?p ?x }',
                               function(success, results) {

 results.triples.forEach(function(result){

console.log(result.subject.nominalValue,

 result.predicate.nominalValue,

 result.object.nominalValue);
                                          });
                                }
                       );
               });
 });

// => http://C http://B http://C

require('rdfstore').create(function(store) {
       store.load(
               'text/n3',
               '<http://A> <http://B> <http://C>.',
               function(success) {
                       store.execute(
                               'SELECT * WHERE { ?x ?p ?x }',
                               function(success, results) {
                                       results.forEach(function(result){
                                          console.log(result.x.value,

 result.p.value);
                                          });
                                }
                       );
               });
});

// => http://C http://B

Reply to this email directly or view it on GitHub: https://github.com/antoniogarrote/rdfstore-js/issues/28


Reply to this email directly or view it on GitHub: https://github.com/antoniogarrote/rdfstore-js/issues/28#issuecomment-5483904

antoniogarrote commented 12 years ago

Hi Chris.

That would be great. I think a lot of people would find it really useful.

If I can help you with something else, just drop me a line.

Regards.

On Thu, May 3, 2012 at 8:23 PM, cmatheus < reply@reply.github.com

wrote:

Antonio,

Thanks for the quick fix! And for all of your effort on rdfstore.js!

I'm using rdfstore for some advanced research on using semantics for network management and control (mostly with UPnP). everything I'm doing is in javascript/node.js so I'm really pleased to have come across your js rdfstore (I plugged it heavily at the IEEE graph data management workshop last month so perhaps you saw a spike in downloads).

I'm woking on adding owl 2 rl rules to rdfstore to support some of the work I'm doing. If you're interested in including this in the distribution I can look into whether Bell Labs legal will let me put this in the public domain. I also have some code to let it work through a corporate firewall which I'm happy to share (will probably need to get permission though). Plus I'd personally like to release everything I'm doing into the public domain but I'm not sure how the company feels about that yet.

Cheers, Chris


From: Antonio Garrote [reply@reply.github.com] Sent: 03 May 2012 10:28 To: Matheus, Chris (Chris) Subject: Re: [rdfstore-js] ?x ?p ?x issue (#28)

Hi, yes it was a bug. I can't believe we didn't come across this before It should be fixed in the new version. Thanks for reporting it.

Regards.

On Wed, May 2, 2012 at 3:10 PM, cmatheus < reply@reply.github.com

wrote:

I'm trying to write some queries that match triples having the same resource for the subject and object, i.e. "WHERE {?x ?p ?x}". in the examples below (one CONSTRUCT the other a SELECT) there are no triples that match this pattern and yet the queries are returning results.

am I missing something here or is this a bug?

thanks!

require('rdfstore').create(function(store) {
       store.load(
               'text/n3',
               '<http://A> <http://B> <http://C>.',
               function(success) {
                       store.execute(
                               'CONSTRUCT { ?x ?p ?x } WHERE { ?x ?p ?x
}',
                               function(success, results) {

 results.triples.forEach(function(result){

console.log(result.subject.nominalValue,

 result.predicate.nominalValue,

 result.object.nominalValue);
                                          });
                                }
                       );
               });
 });

// => http://C http://B http://C

require('rdfstore').create(function(store) {
       store.load(
               'text/n3',
               '<http://A> <http://B> <http://C>.',
               function(success) {
                       store.execute(
                               'SELECT * WHERE { ?x ?p ?x }',
                               function(success, results) {
                                       results.forEach(function(result){
                                          console.log(result.x.value,

 result.p.value);
                                          });
                                }
                       );
               });
});

// => http://C http://B

Reply to this email directly or view it on GitHub: https://github.com/antoniogarrote/rdfstore-js/issues/28


Reply to this email directly or view it on GitHub:

https://github.com/antoniogarrote/rdfstore-js/issues/28#issuecomment-5483904


Reply to this email directly or view it on GitHub:

https://github.com/antoniogarrote/rdfstore-js/issues/28#issuecomment-5496031

cmatheus commented 12 years ago

Antonio,

I found a typo under the JSON-LD Support documentation that makes the code not work correctly. the graph name in the load call (ex:text) does not match the name in the node call (ex:test).

Chris

| jsonld = { "@context": { "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "xsd": "http://www.w3.org/2001/XMLSchema#", "name": "http://xmlns.com/foaf/0.1/name", "age": {"@id": "http://xmlns.com/foaf/0.1/age", "@type": "xsd:integer" }, "homepage": {"@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "xsd:anyURI" }, "ex": "http://example.org/people/" }, "@id": "ex:john_smith", "name": "John Smith", "age": "41", "homepage": "http://example.org/home/" };

store.setPrefix("ex", "http://example.org/people/");

store.load("application/json", jsonld,"ex:text", function(success, results) { store.node("ex:john_smith","ex:test", function(success, graph) { // process graph here }); });|

antoniogarrote commented 12 years ago

I've corrected it. Thanks for the warning.