test_graph v0.1.0 NeoSemantics

Module providing simple wrapper functions for the neosemantics library.

The neosemantics library is authored by Jesús Barrasa (and see https://jbarrasa.com for example usage posts).

Note that the wrapper functions use snake case which is more usual in Elixir, e.g. NeoSemantics.import_rdf/3 for semantics.importRDF. Also there is an additional first argument for the bolt_sips connection. And in the examples this is shown being piped in to emphasize that this is an additional argument.

Note also that the wrapper functions come in two flavours: with and without a trailing bang (!) character. The simple form returns a success or failure tuple which can be used in pattern matching, whereas the marked form returns a plain value or raises an exception. When a positive outcome is expected the marked form may be easier to use. (See Elixir naming conventions for more info.)

TODO - Add parameter maps for function calls which give some fine control. For now, defaults are fine.

Examples

iex> uri = TestGraph.RDF.read_graph().uri
"file:///.../test-graph/priv/rdf/graphs/default.ttl"
iex> fmt = "Turtle"
"Turtle"

# simple form - import_rdf/3
iex> {:ok, resp} = (conn() |> NeoSemantics.import_rdf(uri, fmt))
{:ok,
 [
   %{
     "extraInfo" => "",
     "namespaces" => %{
       "http://purl.org/dc/elements/1.1/" => "dc",
       "http://purl.org/dc/terms/" => "dct",
       "http://purl.org/ontology/bibo/" => "ns0",
       "http://schema.org/" => "sch",
       "http://www.w3.org/1999/02/22-rdf-syntax-ns#" => "rdf",
       "http://www.w3.org/2000/01/rdf-schema#" => "rdfs",
       "http://www.w3.org/2002/07/owl#" => "owl",
       "http://www.w3.org/2004/02/skos/core#" => "skos"
     },
     "terminationStatus" => "OK",
     "triplesLoaded" => 8
   }
 ]}
iex> resp
[
   %{
     "extraInfo" => "",
     "namespaces" => %{
       "http://purl.org/dc/elements/1.1/" => "dc",
       "http://purl.org/dc/terms/" => "dct",
       "http://purl.org/ontology/bibo/" => "ns0",
       "http://schema.org/" => "sch",
       "http://www.w3.org/1999/02/22-rdf-syntax-ns#" => "rdf",
       "http://www.w3.org/2000/01/rdf-schema#" => "rdfs",
       "http://www.w3.org/2002/07/owl#" => "owl",
       "http://www.w3.org/2004/02/skos/core#" => "skos"
     },
     "terminationStatus" => "OK",
     "triplesLoaded" => 8
   }
]
iex> conn() |> Cypher.Client.test()
[%{"nodes" => 6, "paths" => 8, "relationships" => 4}]


# marked form - import_rdf!/3
iex> conn() |> NeoSemantics.import_rdf!(uri, fmt)
[
  %{
    "extraInfo" => "",
    "namespaces" => %{
      "http://purl.org/dc/elements/1.1/" => "dc",
      "http://purl.org/dc/terms/" => "dct",
      "http://purl.org/ontology/bibo/" => "ns0",
      "http://schema.org/" => "sch",
      "http://www.w3.org/1999/02/22-rdf-syntax-ns#" => "rdf",
      "http://www.w3.org/2000/01/rdf-schema#" => "rdfs",
      "http://www.w3.org/2002/07/owl#" => "owl",
      "http://www.w3.org/2004/02/skos/core#" => "skos"
    },
    "terminationStatus" => "OK",
    "triplesLoaded" => 8
  }
]
iex> conn() |> Cypher.Client.test()
[%{"nodes" => 6, "paths" => 8, "relationships" => 4}]

# marked form - import_turtle!/2
iex> conn() |> NeoSemantics.import_turtle!(uri)
[
  %{
    "extraInfo" => "",
    "namespaces" => %{
      "http://purl.org/dc/elements/1.1/" => "dc",
      "http://purl.org/dc/terms/" => "dct",
      "http://purl.org/ontology/bibo/" => "ns0",
      "http://schema.org/" => "sch",
      "http://www.w3.org/1999/02/22-rdf-syntax-ns#" => "rdf",
      "http://www.w3.org/2000/01/rdf-schema#" => "rdfs",
      "http://www.w3.org/2002/07/owl#" => "owl",
      "http://www.w3.org/2004/02/skos/core#" => "skos"
    },
    "terminationStatus" => "OK",
    "triplesLoaded" => 8
  }
]
iex> conn() |> Cypher.Client.test()
[%{"nodes" => 6, "paths" => 8, "relationships" => 4}]

Link to this section Summary

Functions

Wrapper for import_rdf/3 for an "JSON-LD" RDF format

Wrapper for import_rdf!/3 for an "JSON-LD" RDF format

Wrapper for import_rdf/3 for an "N-Triples" RDF format

Wrapper for import_rdf!/3 for an "N-Triples" RDF format

Imports into Neo4j all the triples in the data set according to the mapping defined in this post

The same as import_rdf/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise

Wrapper for import_rdf/3 for an "RDF/XML" RDF format

Wrapper for import_rdf!/3 for an "RDF/XML" RDF format

Wrapper for import_rdf/3 for an "TriG" RDF format

Wrapper for import_rdf!/3 for an "TriG" RDF format

Wrapper for import_rdf/3 for an "Turtle" RDF format

Wrapper for import_rdf!/3 for an "Turtle" RDF format

Imports the basic elements of an OWL or RDFS ontology, i.e. Classes, Properties, Domains, Ranges

The same as lite_onto_import/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise

Parses some RDF and produces a preview in Neo4j browser

The same as preview_rdf/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise

Identical to previewRDF but takes an RDF snippet instead of the url of the dataset

The same as preview_rdf_snippet/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise

Parses some RDF and streams the triples as records of the form subject, predicate, object plus three additional fields

The same as stream_rdf/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise

Link to this section Functions

Link to this function

import_jsonld(conn, uri)

Wrapper for import_rdf/3 for an "JSON-LD" RDF format.

Link to this function

import_jsonld!(conn, uri)

Wrapper for import_rdf!/3 for an "JSON-LD" RDF format.

Link to this function

import_ntriples(conn, uri)

Wrapper for import_rdf/3 for an "N-Triples" RDF format.

Link to this function

import_ntriples!(conn, uri)

Wrapper for import_rdf!/3 for an "N-Triples" RDF format.

Link to this function

import_rdf(conn, uri, format)

Imports into Neo4j all the triples in the data set according to the mapping defined in this post.

Sends the Cypher query call semantics.importRDF(...) to the server and returns {:ok, Bolt.Sips.Response} or {:error, error} otherwise

Link to this function

import_rdf!(conn, uri, format)

The same as import_rdf/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise.

Link to this function

import_rdfxml(conn, uri)

Wrapper for import_rdf/3 for an "RDF/XML" RDF format.

Link to this function

import_rdfxml!(conn, uri)

Wrapper for import_rdf!/3 for an "RDF/XML" RDF format.

Link to this function

import_trig(conn, uri)

Wrapper for import_rdf/3 for an "TriG" RDF format.

Link to this function

import_trig!(conn, uri)

Wrapper for import_rdf!/3 for an "TriG" RDF format.

Link to this function

import_turtle(conn, uri)

Wrapper for import_rdf/3 for an "Turtle" RDF format.

Link to this function

import_turtle!(conn, uri)

Wrapper for import_rdf!/3 for an "Turtle" RDF format.

Link to this function

lite_onto_import(conn, uri, format)

Imports the basic elements of an OWL or RDFS ontology, i.e. Classes, Properties, Domains, Ranges.

Sends the Cypher query call semantics.liteOntoImport(...) to the server and returns {:ok, Bolt.Sips.Response} or {:error, error} otherwise

Link to this function

lite_onto_import!(conn, uri, format)

The same as lite_onto_import/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise.

Link to this function

preview_rdf(conn, uri, format)

Parses some RDF and produces a preview in Neo4j browser.

Sends the Cypher query call semantics.previewRDF(...) to the server and returns {:ok, Bolt.Sips.Response} or {:error, error} otherwise

Link to this function

preview_rdf!(conn, uri, format)

The same as preview_rdf/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise.

Link to this function

preview_rdf_snippet(conn, uri, format)

Identical to previewRDF but takes an RDF snippet instead of the url of the dataset.

Sends the Cypher query call semantics.previewRDFSnippet(...) to the server and returns {:ok, Bolt.Sips.Response} or {:error, error} otherwise

Link to this function

preview_rdf_snippet!(conn, uri, format)

The same as preview_rdf_snippet/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise.

Link to this function

stream_rdf(conn, uri, format)

Parses some RDF and streams the triples as records of the form subject, predicate, object plus three additional fields.

Sends the Cypher query call semantics.streamRDF(...) to the server and returns {:ok, Bolt.Sips.Response} or {:error, error} otherwise

Link to this function

stream_rdf!(conn, uri, format)

The same as stream_rdf/3 but raises a Bolt.Sips.Exception if it fails. Returns the server response otherwise.