Module: Pho::Sparql

Defined in:
lib/pho/sparql.rb

Overview

Module providing a SPARQL client library, support for parsing SPARQL query responses into Ruby objects and other useful behaviour

Defined Under Namespace

Classes: SparqlClient, SparqlHelper

Constant Summary collapse

SPARQL_RESULTS_XML =
"application/sparql-results+xml"
SPARQL_RESULTS_JSON =
"application/sparql-results+json"
SYMMETRIC_BOUNDED_DESCRIPTION =

Includes all statements along both in-bound and out-bound arc paths

See n2.talis.com/wiki/Bounded_Descriptions_in_RDF

"CONSTRUCT {?uri ?p ?o . ?s ?p2 ?uri .} WHERE { {?uri ?p ?o .} UNION {?s ?p2 ?uri .} }\n"
LABELLED_BOUNDED_DESCRIPTION =

Similar to Concise Bounded Description but includes labels for referenced resources

See n2.talis.com/wiki/Bounded_Descriptions_in_RDF

"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \nCONSTRUCT {\n   ?uri ?p ?o . \n   ?o rdfs:label ?label . \n   ?o rdfs:comment ?comment . \n   ?o <http://www.w3.org/2004/02/skos/core#prefLabel> ?plabel . \n   ?o rdfs:seeAlso ?seealso.\n} WHERE {\n  ?uri ?p ?o . \n  OPTIONAL { \n    ?o rdfs:label ?label .\n  } \n  OPTIONAL {\n    ?o <http://www.w3.org/2004/02/skos/core#prefLabel> ?plabel . \n  } \n  OPTIONAL {\n    ?o rdfs:comment ?comment . \n  } \n  OPTIONAL { \n    ?o rdfs:seeAlso ?seealso.\n  }\n}    \n"
SYMMETRIC_LABELLED_BOUNDED_DESCRIPTION =

Derived from both the Symmetric and Labelled Bounded Descriptions. Includes all in-bound and out-bound arc paths, with labels for any referenced resources.

See n2.talis.com/wiki/Bounded_Descriptions_in_RDF

"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \nCONSTRUCT {\n  ?uri ?p ?o . \n  ?o rdfs:label ?label . \n  ?o rdfs:comment ?comment . \n  ?o rdfs:seeAlso ?seealso. \n  ?s ?p2 ?uri . \n  ?s rdfs:label ?label . \n  ?s rdfs:comment ?comment . \n  ?s rdfs:seeAlso ?seealso.\n} WHERE { \n  { ?uri ?p ?o . \n    OPTIONAL { \n      ?o rdfs:label ?label .\n    } \n    OPTIONAL {\n      ?o rdfs:comment ?comment .\n    } \n    OPTIONAL {\n      ?o rdfs:seeAlso ?seealso.\n    } \n  } \n  UNION {\n    ?s ?p2 ?uri . \n    OPTIONAL {\n      ?s rdfs:label ?label .\n    } \n    OPTIONAL {\n      ?s rdfs:comment ?comment .\n    } \n    OPTIONAL {\n      ?s rdfs:seeAlso ?seealso.\n    } \n  } \n}    \n"
DESCRIPTIONS =
{
  :cbd => "DESCRIBE ?uri",
  :scbd => SYMMETRIC_BOUNDED_DESCRIPTION,
  :lcbd => LABELLED_BOUNDED_DESCRIPTION,
  :slcbd => SYMMETRIC_LABELLED_BOUNDED_DESCRIPTION
}