@ezs/sparql

1.2.3 • Public • Published

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.

Input:
{
  "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"
}
Output:
{
  "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.

Input:
{
  "query": "SELECT DISTINCT ?g, count(*) AS ?nb WHERE { graph ?g { ?s ?p ?o } } LIMIT 3",
   "endpoint": "https://data.istex.fr/sparql/"
}
Ouput:
{ "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

Input:
{ "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"
    }}
  ]}
}
Output:
{
   "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
       }
   ]
}

Readme

Keywords

Package Sidebar

Install

npm i @ezs/sparql

Weekly Downloads

10

Version

1.2.3

License

MIT

Unpacked Size

13.6 kB

Total Files

7

Last publish

Collaborators

  • parmentf
  • touv
  • jj618