Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comments in SPARQL query?

Can I write comments in a query, so that only God but also me remember what I was doing?

I just started learning SPARQL, so forgive my ignorance.

For example:

SELECT ?names
WHERE {
  ?names dbo:award :Turing_Award // get names that won Turing award
}

that throws a parsing error.

A negative answer will also be accepted!

I am using SPARQL endpoint over the DBpedia data set at http://dbpedia.org/sparql.

like image 381
gsamaras Avatar asked Nov 28 '15 21:11

gsamaras


People also ask

What types of queries does SPARQL support?

SPARQL allows for a query to consist of triple patterns, conjunctions, disjunctions, and optional patterns. Implementations for multiple programming languages exist. There exist tools that allow one to connect and semi-automatically construct a SPARQL query for a SPARQL endpoint, for example ViziQuer.

What is a prefix in Sparql query?

"PREFIX", however (without the "@"), is the SPARQL instruction for a declaration of a namespace prefix. It allows you to write prefixed names in queries instead of having to use full URIs everywhere. So it's a syntax convenience mechanism for shorter, easier to read (and write) queries.

What is bind in SPARQL?

BIND. SPARQL's BIND function allows us to assign a value to a variable.


1 Answers

The SPARQL 1.1 specification says:

Comments in SPARQL queries take the form of '#', outside an IRI or string, and continue to the end of line (marked by characters 0x0D or 0x0A) or end of file if there is no end of line after the comment marker. Comments are treated as white space.

Hence, your example SPARQL fragment should read:

    SELECT ?names
    WHERE {
      ?names dbo:award :Turing_Award # get names that won Turing award
    }
like image 186
O. R. Mapper Avatar answered Sep 23 '22 18:09

O. R. Mapper