RubenVerborgh/SPARQL.js

Would it be interesting to automatically add some well-known prefix when parsing a sparql query?

marcelomachado opened this issue · 1 comments

Suppose I am trying to parse the following sparql query:

SELECT ?inv  ?investigation_type
WHERE
{
    ?inv a ?investigation_type .
    filter(?investigation_type != owl:NamedIndividual)
}

let sparqlParser = new SparqlJS.Parser();
let sparqlObj = sparqlParser.parse(query);

But I forgot to declare the owl prefix. However most of the Triplestores that I know are able to understand that owl prefix. Therefore, I am wondering if it isn't an interesting implementation to automatically add this known prefix when parsing (e.g. rdf and owl).

Absolutely, you can specify any common prefixes you like:

const prefixes = { owl: 'http://www.w3.org/2002/07/owl#' };
const parser = new SparqlParser({ prefixes });