Chapter 10. NSMNTX Reference

Complete list of all available stored procedures, functions and extensions in NSMNTX.

10.1. Stored Procedures

10.1.1. RDF Import

Procedure Name params Description and example usage

semantics.importRDF

  • URL of the dataset
  • serialization format (valid formats: Turtle, N-Triples, JSON-LD, TriG, RDF/XML)
  • optional map with params from the table below

Fetches RDF from a url (file or http) and stores it in Neo4j as a property graph. This procedure requires and index on :Resource(uri)

semantics.importRDFSnippet

  • string containing a valid RDF fragment
  • serialization format (valid formats: Turtle, N-Triples, JSON-LD, TriG, RDF/XML)
  • optional map with params from the table below

Imports an RDF snippet passed as parameter and stores it in Neo4j as a property graph. Requires and index on :Resource(uri)

semantics.importQuadRDF

  • URL of the dataset
  • serialization format (valid formats: TriG,N-Quads)
  • optional map with params from the table below

importRDF for RDF Quads

semantics.importOntology

  • URL of the dataset
  • serialization format (valid formats: Turtle, N-Triples, JSON-LD, TriG, RDF/XML)
  • optional map with params from the ontology import table below

Imports classes, properties (dataType and Object), hierarchies thereof and domain and range info.

semantics.streamRDF

  • URL of the dataset
  • serialization format (valid formats: Turtle, N-Triples, JSON-LD, TriG, RDF/XML)
  • optional map with params from the table below

Parses RDF and streams each triple as a record with <S,P,O> along with datatype and language tag for Literal values. No writing to the DB. This SP is useful when you want to import into your Neo4j graph fragments of an RDF dataset in a custom way.

semantics.previewRDF

  • URL of the dataset
  • serialization format (valid formats: Turtle, N-Triples, JSON-LD, TriG, RDF/XML)
  • optional map with params from the table below

Parses RDF and produces virtual Nodes and relationships for preview in the Neo4j browser. No writing to the DB. Notice that this is adequate for a preliminary visual analysis of a SMALL dataset. Think how many nodes you want rendered in your browser.

semantics.previewRDFSnippet

  • string containing a valid RDF fragment
  • serialization format (valid formats: Turtle, N-Triples, JSON-LD, TriG, RDF/XML)
  • optional map with params from the table below

Parses an RDF fragment passed as parameter (no retrieval from url) and produces virtual Nodes and relationships for preview in the Neo4j browser. No writing to the DB

semantics.deleteRDF

  • URL of the dataset
  • serialization format (valid formats: Turtle, N-Triples, JSON-LD, TriG, RDF/XML)
  • optional map with params from the table below

Deletes triples from Neo4j. Works on a graph resulted of importing RDF via semantics.importRDF(). Delete config must match the one used on import

semantics.deleteQuadRDF

  • URL of the dataset
  • serialization format (valid formats: TriG,N-Quads)
  • optional map with params from the table below

Deletes quads from Neo4j. Works on a graph resulted of importing RDF quads via semantics.importQuadRDF(). Delete config must match the one used on import

10.1.1.1. RDF Import Params

Param values(default) Description

handleVocabUris

'SHORTEN','IGNORE','MAP','KEEP' ('SHORTEN')

  • 'SHORTEN', full uris are shortened using prefixes for property names, relationship names and labels
  • 'IGNORE' uris are ignored and only local names are kept
  • 'MAP' vocabulary element mappings are applied on import
  • 'KEEP' uris are kept unchanged

applyNeo4jNaming

boolean (false)

when set to true and in combination with handleVocabUris: 'IGNORE', Neo4j capitalisation is applied to vocabulary elements (all caps for relationship types, capital first for labels, etc.)

handleMultival

'OVERWRITE', 'ARRAY' ('OVERWRITE')

  • 'OVERWRITE' property values are kept single valued. Multiple values in the imported RDF are overwriten (only the last one is kept)
  • 'ARRAY' properties are stored in an array enabling storage of multiple values. All of them unless multivalPropList is set.

multivalPropList

list of strings ([])

List of property names (full uri) to be stored as arrays. The rest are treated as 'OVERWRITE'.

keepLangTag

boolean (false)

when set to true, the language tag is kept along with the property value. Useful for multilingual datasets. Use helper function getLangValue to get specific values.

predicateExclusionList

list of strings ([])

List of predicates (full uri) that are to be ignored on parsing RDF and not stored in Neo4j.

typesToLabels

boolean (true)

when set to true, rdf:type statements are imported as node labels in Neo4j

languageFilter

['en','fr','es',…​]

when set, only literal properties with this language tag (or untagged ones) are imported

headerParams

map {}

parameters to be passed in the HTTP GET request or payload if POST request. <br> Example: { authorization: 'Basic user:pwd', Accept: 'application/rdf+xml'}

commitSize

integer (25000)

commit a partial transaction every n triples

nodeCacheSize

integer (10000)

keep n nodes in cache to minimize reads from DB

verifyUriSyntax

boolean (true)

by default, uri syntax is checked. This can be disable d by setting this parameter to false

keepCustomDataTypes

boolean(false)

when set to true, all properties containing a custom data type will be saved as a string followed by their custom data type IRIs

customDataTypedPropList

list of strings ([])

when set, only custom data types of literal properties in this list are imported

10.1.1.2. Ontology Import Params

Param values(default) Description

predicateExclusionList

list of strings ([])

List of predicates (full uri) that are to be ignored on parsing RDF and not stored in Neo4j.

headerParams

map {}

parameters to be passed in the HTTP GET request or payload if POST request. <br> Example: { authorization: 'Basic user:pwd', Accept: 'application/rdf+xml'}

commitSize

integer (25000)

commit a partial transaction every n triples

nodeCacheSize

integer (10000)

keep n nodes in cache to minimize reads from DB

verifyUriSyntax

boolean (true)

by default, uri syntax is checked. This can be disable d by setting this parameter to false

classLabelName

string ('Class')

Label for classes in the ontology

subClassOfRelName

string ('SCO')

Relationship name for rdfs:subClassOf statements

dataTypePropertyLabelName

string ('Property')

Label for DataTypeProperty definitions (attributes)

objectPropertyLabelName

string ('Relationship')

Label for ObjectProperty definitions (relationships)

subPropertyOfRelName

string ('SPO')

Relationship for rdfs:subPropertyOf statements

domainRelName

string ('DOMAIN')

Domain relationship between Classes and DataTypeProperty/ObjectProperty

rangeRelName

string ('RANGE')

Range relationship between Classes and DataTypeProperty/ObjectProperty

10.1.2. RDF Import Utils

Procedure Name params Description and example usage

semantics.addNamespacePrefix

Adds namespace - prefix pair definition to be used for RDF import

semantics.listNamespacePrefixes

params

Lists all currently defined namespace prefix definitions

10.1.3. Model Mapping

Procedure Name params Description and example usage

semantics.mapping.addSchema

  • URL of the schema/vocabulary/ontology
  • prefix to be used in serialisations

Creates a reference to a vocabulary. Needed to define mappings.

semantics.mapping.dropSchema

  • URL of the schema/vocabulary/ontology

Deletes a vocabulary reference and all associated mappings.

semantics.mapping.listSchemas

  • optional filter string

Returns all vocabulary references. When filter string is set, only schemas containing the search string in their uri or in the associated prefix are returned.

semantics.mapping.addCommonSchemas

no prams

Creates references to a number of popular vocabularies including schema.org, Dublin Core, SKOS, OWL, etc

semantics.mapping.addMappingToSchema

  • URL of the schema/voc/ontology
  • The name of the element in the Neo4j graph (a property name, a label or a relationship type)
  • The matching element (Class, DataTypeProperty or ObjectProperty) in the public schema. Only the local name of the element

Creates a mapping for an element in the Neo4j DB schema to a vocabulary element

semantics.mapping.dropMapping

* mapped DB element name to remove the mapping

Returns an output text message indicating success/failure of the deletion

semantics.mapping.listMappings

  • optional filter string

Returns a list with all the currently defined mappings. Whe filter string is passed, only mappings containing the string in the DB element name or the schema element URI are returned

10.1.4. Inferencing

Stored Proc Name params Description

semantics.inference.nodesLabelled

  • a string with a label name
  • parameters as described in table below

returns all nodes with label 'label' or its sublabels

semantics.inference.nodesInCategory

  • a node representing the category
  • parameters as described in table below

returns all nodes connected to Node 'catNode' or its subcategories

semantics.inference.getRels

  • a start node
  • a (real or 'virtual') relationship type
  • parameters as described in table below

returns all relationships of type 'virtRel' or its subtypes along with the target nodes

semantics.inference.hasLabel (function)

  • a node
  • a label name as a string
  • parameters as described in table below

checks whether node is explicitly or implicitly labeled as 'label'

semantics.inference.inCategory (function)

  • a node representing an instance
  • a node representing a category
  • parameters as described in table below

checks whether node is explicitly or implicitly in a category

10.2. Utility Functions

Function Name params Description

semantics.getIRILocalName

URI string

Returns the local part of the URI (stripping out the namespace)

semantics.getIRINamespace

URI string

Returns the namespace part of the URI (stripping out the local part)

semantics.getDataType

string (a property value)

Returns the XMLSchema (or custom) datatype of a property value when present

semantics.getLangValue

string (a property value)

Returns the value with the language tag passed as first argument or null if there’s not a value for the provided language tag

semantics.getValue

string (a property value)

Returns the value of a datatype of a property after stripping out the datatype information or language tag when present

semantics.shortFromUri

string (a URI)

Returns the shortened version of an IRI using the existing namespace definitions

semantics.uriFromShort

string (a shortened URI)

Returns the expanded (full) URI given a shortened one created in the load process with semantics.importRDF

semantics.importJSONAsTree

  • node to link the imported json to
  • the json fragment
  • (optional) relationship name linking the root node of the JSON to the node passed as first param

Imports a JSON payload by mapping it to nodes and relationships (JSON-LD style). Requires a uniqueness constraint on :Resource(uri)

10.3. Extensions (HTTP endpoints)

method type params Description

/rdf/describe/id/<nodeid>

GET

  • nodeid: path parameter containing the id of a node
  • excludeContext: Optional named parameter. If present output will not include connected nodes, just selected one.
  • format: RDF serialisation format. When present, it overrides the header param accept.

Produces an RDF serialization of the selected node. The format will be determined by the accept parameter in the header. Default is Turtle

/rdf/describe/uri/<nodeuri>

GET

  • nodeuri: path parameter containing the (urlencoded) uri of a node.
  • excludeContext: (optional) if present output will not include connected nodes, just selected one.
  • graphuri: (optional) if present and the graph includes Quad information, only statements in the selected named graph are returned.The value of the parameter is the (urlencoded) uri of a named graph.
  • format: RDF serialisation format. When present, it overrides the header param accept.

Produces an RDF serialization of the selected node. It works on a model either imported from an RDF dataset via semantics.importRDF, semantics.importQuadRDF or built in a way that nodes are labeled as :Resource and have an uri.

/rdf/describe/find/<l>/<p>/<v>

GET

  • the method takes three parameters passed as path parameters in the URL: <l>/<p>/<v>. They represent respectively a label, a property name and a property value.
  • excludeContext: Optional named parameter. If present output will not include connected nodes, just selected one.
  • valType: required when the property value is not to be treated as a string. Valid values: INTEGER, FLOAT and BOOLEAN
  • format: RDF serialisation format. When present, it overrides the header param accept.

returns nodes matching the filter on label and property value

/rdf/cypher

POST

POST request taking as parameter a JSON map with the following keys:

  • cypher: the cypher query to run
  • cypherParams: parameters for the cypher query
  • showOnlyMapped: (optional, default is false) if present output will exclude unmapped elements (see how to define mappings for labels,attributes, relationships)
  • format: RDF serialisation format. When present, it overrides the header param accept.

Produces an RDF serialization of the nodes and relationships returned by the Cypher query

/rdf/cypheronrdf

POST

same parameters as /rdf/cypher

Same as /rdf/cypher but it works on a model either imported from an RDF dataset via semantics.importRDF or built in a way that nodes are labeled as :Resource and have an uri.

/rdf/onto

GET

  • format: RDF serialisation format. When present, it overrides the header param accept.

returns an OWL ontology based on the graph schema

/rdf/ontonrdf

GET

  • format: RDF serialisation format. When present, it overrides the header param accept.

Same as /rdf/onto but it works on a model either imported from an RDF dataset via semantics.importRDF or built in a way that nodes are labeled as :Resource and have an uri.