rdf-ext-archive / rdf-examples

Examples for RDFJS Interfaces
4 stars 4 forks source link

rdf-ext SPARQL #3

Open nicky508 opened 7 years ago

nicky508 commented 7 years ago

One of the things I would like to do is, to use SPARQL queries with RDF-ext. I cannot find how we could SPARQL. Somewhere in RDF-ext I found that we should use "sparql-http-client" but only fixed methods are defined (.match .add .remove etc.)

For example with DBpedia:

SELECT ?label ?comment ?homepage WHERE {
<http://dbpedia.org/resource/Eiffel_Tower> rdfs:label ?label.
<http://dbpedia.org/resource/Eiffel_Tower> rdfs:comment ?comment.
<http://dbpedia.org/resource/Eiffel_Tower> foaf:homepage ?homepage.
FILTER ( lang(?comment) = "en" && lang(?label) = "en" )
}
ktk commented 7 years ago

I'm not sure if I understand this one properly. Are you looking for a simple way to get a SPARQL SELECT result set in a parsed form? Or do you want to get triples back and then do something with them in rdf-ext?

Our colleague @l00mi created d3-sparql recently, in case you need a simple result set structure.

bergos commented 7 years ago

It depends a little bit on the data. If there are not to many triples for the <http://dbpedia.org/resource/Eiffel_Tower> subject, than I would fetch all the triples/quads using the rdf-store-sparql using the .match method. That's one async call. Than you can import the result into a dataset/graph and work in memory with sync methods. It combines this and this example.

const quadStream = store.match(rdf.namedNode('http://dbpedia.org/resource/Eiffel_Tower'))

rdf.dataset().import(quadStream).then((dataset) => {
  ...
})

If this is what you want, I can create a complete example.

nicky508 commented 7 years ago

The second option @ktk. I would like to run a SPARQL Select query and put the retrieved triples in rdf-ext to do something with it.

@bergos I see your point. But for that solution we need to now the exact uri. We do not know always the uri.