@ezs/sparql
v1.2.4
Published
SPARQL module for ezs
Downloads
415
Readme
sparql
Ce plugin propose une série d'instructions liée à l’usage d’un SPARQL Endpoint.
installation
npm install @ezs/sparql
usage
Table of Contents
SPARQLDecodeQuery
- See: SPARQLQuery
Take a query share link from a YASGUI editor and convert it into an object
which contains the query and the endpoint. Then, it could be used by
SPARQLQuery
instruction.
{
"linkQuery": "https://data.istex.fr/triplestore/sparql/#query=SELECT+DISTINCT+%3Fg%2C+count(*)+AS+%3Fnb+%0AWHERE+%0A%7B+%0A%09graph+%3Fg+%7B+%3Fs+%3Fp+%3Fo+%7D+%0A%7D+%0ALIMIT+3&contentTypeConstruct=text%2Fturtle&endpoint=https%3A%2F%2Fdata.istex.fr%2Fsparql%2F&outputFormat=table"
}
{
"query": "SELECT DISTINCT ?g, count(*) AS ?nb WHERE { graph ?g { ?s ?p ?o } } LIMIT 3",
"endpoint": "https://data.istex.fr/sparql/"
}
SPARQLQuery
Take a SPARQL query and endpoint and send in output the execution result in JSON format.
{
"query": "SELECT DISTINCT ?g, count(*) AS ?nb WHERE { graph ?g { ?s ?p ?o } } LIMIT 3",
"endpoint": "https://data.istex.fr/sparql/"
}
{ "head": { "link": [], "vars": ["g", "nb"] },
"results": { "distinct": false, "ordered": true, "bindings": [
{ "g": {
"type": "uri",
"value": "http://www.openlinksw.com/schemas/virtrdf#"
},
"nb": {
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#integer",
"value": "2477"
}},
{ "g": {
"type": "uri",
"value": "https://bibliography.data.istex.fr/notice/graph"
},
"nb": {
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#integer",
"value": "308023584"
}},
{ "g": {
"type": "uri",
"value": "https://scopus-category.data.istex.fr/graph"
},
"nb": {
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#integer",
"value": "2542"
}}
]}
}
SPARQLToDistinct
Format SPARQLQuery result as a LODEX routine.
The input should contain at least two fields:
- the first is corresponding with the _id output field
- the second is corresponding with the value output field
Warning: input's second field value should contain an integer
See SPARQLQuery
{ "head": { "link": [], "vars": ["g", "nb"] },
"results": { "distinct": false, "ordered": true, "bindings": [
{ "g": {
"type": "uri",
"value": "http://www.openlinksw.com/schemas/virtrdf#"
},
"nb": {
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#integer",
"value": "2477"
}},
{ "g": {
"type": "uri",
"value": "https://bibliography.data.istex.fr/notice/graph" },
"nb": {
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#integer",
"value": "308023584" }},
{ "g": {
"type": "uri",
"value": "https://scopus-category.data.istex.fr/graph"},
"nb": {
"type":
"typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#integer",
"value": "2542"
}}
]}
}
{
"total": 3,
"data": [{
"_id": "http://www.openlinksw.com/schemas/virtrdf#",
"value": 2477
}, {
"_id": "https://bibliography.data.istex.fr/notice/graph",
"value": 308023584
}, {
"_id": "https://scopus-category.data.istex.fr/graph",
"value": 2542
}
]
}