Skip to content

Instantly share code, notes, and snippets.

@andrefs
Last active December 8, 2020 12:39
Show Gist options
  • Save andrefs/9d6555492ed94bcf070558ea19783b1c to your computer and use it in GitHub Desktop.
Save andrefs/9d6555492ed94bcf070558ea19783b1c to your computer and use it in GitHub Desktop.
MWE of a SPARQL query with a FILTER in Comunica
const newEngine = require('@comunica/actor-init-sparql').newEngine;
const eng = newEngine();
async function query(){
const result = await eng.query(`
SELECT ?o WHERE {
<http://dbpedia.org/resource/Landscaping> <http://www.w3.org/2002/07/owl#sameAs> ?o .
FILTER regex(?o, "wikidata")
}
`, {
sources: ['http://dbpedia.org/sparql'],
});
result.bindingsStream.on('data', (binding) => {
console.log(binding.get('?o').value);
});
result.bindingsStream.on('error', err => console.log);
}
query()
.then(() => console.log('done'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment