knocean / knode

Knowledge Development Environment
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Improve SPARQL input using labels #52

Closed jamesaoverton closed 6 years ago

jamesaoverton commented 6 years ago

I would like to extend SPARQL syntax to allow single-quoted labels. Given an environment (like the ones we're using for Knotation processing) and a SPARQL query string with single-quoted labels, we should translate to a normal SPARQL query that uses CURIEs or IRIs instead of labels. The resulting normal SPARQL can be submitted to the triplestore. Example: ?s 'type' ?o would translate to ?s rdf:type ?o.

Matching and substituting should be simple enough. We have to skip over literal strings (i.e. double-quoted strings). It would also be good to allow escaped single quotes.

Here's an earlier implementation in JavaScript, where the "Query" tab uses labels from the "Labels" tab: http://52.206.194.36

inaimathi commented 6 years ago

First cut up at https://github.com/knocean/knode/pull/57 (now also allows escaped single quotes)

inaimathi commented 6 years ago

Added a different regex that will ignore single quoted terms inside of double-quoted strings. If we want to get any more complex than this, I think we'll actually need to bite the bullet and use instaparse, but we're fine for now.