How to translate GVP SPARQL to GREL?

Edit : I’m also asking this in the GVP google group.

After reconciling against GVP AAT, I want to retrieve only Dutch scope notes for the ID’s that I found, using Add Column by fetching URLs

I’m starting out with this:
Schermafbeelding 2023-03-07 123008

For GVP’s Sparql endpoint, I have this sample query (ID 300212636) and it does exactly what I want.

select * {
  aat:300212636 skos:scopeNote [dct:language gvp_lang:nl; rdf:value ?scope_note]
}

translated to a pasteable URL, this works too:

http://vocab.getty.edu/sparql.json?query=select * {aat:300212636 skos:scopeNote [dct:language gvp_lang:nl; rdf:value ?scope_note]}

As per documentation listed below, I think I need to replace all spaces in the query by a plus, and replace the value that I’m looking for by either '+ value + ' or ' + escape(value, 'url') +'.

'http://vocab.getty.edu/sparql.json?query=select+*{aat:' + value + '+skos:scopeNote+[dct:language+gvp_lang:nl;+rdf:value+?scope_note]}'

or

'http://vocab.getty.edu/sparql.json?query=select+*{aat:' + escape(value, 'url') + '+skos:scopeNote+[dct:language+gvp_lang:nl;+rdf:value+?scope_note]}'

This is what it looks like in OR:

However, the column remains empty.

What am I doing wrong?

Documentation:

GVP OR tutorial
A ppt from Gregg Garcia

Using OpenRefine version 3.7.0

I would suggest building the entire query string first and then escaping the entire thing. That way you don’t need to guess what needs to be escaped and what doesn’t.

For testing, using curl or wget will give you much more transferable results because browsers will add their own escaping before sending a request.

Tom

Thanks, I’ll try with curl or wget.

IDK how to “escape the entire thing”, but let’s cross that bridge after I have some test results.

Cheers
Rolf

http://vocab.getty.edu/sparql.json?query=’ + escape(‘select * {aat:’ + value + ’ skos:scopeNote [dct:language gvp_lang:nl; rdf:value ?scope_note]}', ‘url’)

To help with debugging, click the “Store error” check box so that you can see what the result is for error cases.

1 Like

@tfmorris the escape worked like a charm, THANK YOU!

curl didn’t like the [ and made me face a learning curve that I chose not to follow just yet. wget did give me proper json as a file when I escaped the semicolon.

Your line with curly quotes replaced by straight ones worked straight away. It gave me clean json. Parsing that was no problem.

I looked up the documentation for escape and I have to admit I’d never thought of this being a solution. Learning all the time…

I think it’s a nice use case too, as the built-in reconciliation features don’t let you select partial results by language. That was the reason for trying this.