Last active
December 8, 2020 12:39
-
-
Save andrefs/9d6555492ed94bcf070558ea19783b1c to your computer and use it in GitHub Desktop.
MWE of a SPARQL query with a FILTER in Comunica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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