test_graph v0.1.0 TestGraph.RDF.SPARQL.Client

Module providing simple wrapper functions for the SPARQL.Client module.

Link to this section Summary

Functions

Sets DBpedia SPARQL endpoint

Sets local SPARQL endpoint

Queries a SPARQL endpoint with a SPARQL query

The same as rquery but raises a runtime error if it fails

Returns default SPARQL endpoint

Sets default SPARQL endpoint

Returns default SPARQL query

Returns saved SPARQL query

Returns SPARQL services

Sets Wikidata SPARQL endpoint

Link to this section Functions

Link to this function

dbpedia_sparql_endpoint()

Sets DBpedia SPARQL endpoint.

Examples

iex> dbpedia_sparql_endpoint()
"http://dbpedia.org/sparql"
Link to this function

local_sparql_endpoint()

Sets local SPARQL endpoint.

Examples

iex> local_sparql_endpoint()
"http://localhost:7200/repositories/test-graph"
Link to this function

rquery(query \\ sparql_query(), endpoint \\ sparql_endpoint())

Queries a SPARQL endpoint with a SPARQL query.

Examples

iex> sparql_endpoint
"http://localhost:7200/repositories/test-graph"

iex> sparql_endpoint(:sparql_dbpedia)
"http://dbpedia.org/sparql"

iex> read_rdf_query("hello.rq").data |>  SPARQL_Client.rquery()
{:ok, #RDF.Graph{name: nil
      ~I<http://dbpedia.org/resource/Hello_World>
          ~I<http://www.w3.org/2000/01/rdf-schema#label>
              ~L"Hello World"en}}
Link to this function

rquery!(query \\ sparql_query(), endpoint \\ sparql_endpoint())

The same as rquery but raises a runtime error if it fails.

Examples

iex> sparql_endpoint
"http://dbpedia.org/sparql"

iex> read_rdf_query("hello.rq").data |>  SPARQL_Client.rquery()
#RDF.Graph{name: nil
     ~I<http://dbpedia.org/resource/Hello_World>
         ~I<http://www.w3.org/2000/01/rdf-schema#label>
             ~L"Hello World"en}
Link to this function

sparql_endpoint()

Returns default SPARQL endpoint.

Examples

iex> sparql_endpoint()
"http://localhost:7200/repositories/test-graph"
Link to this function

sparql_endpoint(sparql_service)

Sets default SPARQL endpoint.

Examples

iex> sparql_endpoint(:sparql_dbpedia)
"http://dbpedia.org/sparql"

Returns default SPARQL query.

Examples

iex> sparql_query()
"construct\n{ ?s ?p ?o }\nwhere {\n  ?s ?p ?o\n} limit 1\n"
Link to this function

sparql_query(query_file)

Returns saved SPARQL query.

Examples

iex> list_rdf_queries
["cypher.rq", "london.rq", "elixir.rq", "default.rq", "neo4j.rq",
 "triples_by_uri.rq", "triples.rq", "hello.rq"]

iex> sparql_query("hello.rq")
"construct\n{ ?s ?p ?o }\nwhere {\n  bind (<http://dbpedia.org/resource/Hello_World> as ?s)\n  ?s ?p ?o\n  filter (isLiteral(?o) && langMatches(lang(?o), \"en\"))\n}\n"
Link to this function

sparql_services()

Returns SPARQL services.

Examples

iex> list_sparql_services()
[:sparql_dbpedia, :sparql_local, :sparql_wikidata]
Link to this function

wikidata_sparql_endpoint()

Sets Wikidata SPARQL endpoint.

Examples

iex> wikidata_sparql_endpoint()
"https://query.wikidata.org/bigdata/namespace/wdq/sparql"