clownface-shacl-path
Find nodes in RDF/JS graphs by following SHACL Property Paths using clownface graph traversal library.
Install
yarn add clownface-shacl-path
Usage
The exported function takes two parameters:
- starting graph pointer node
- graph pointer to a SHACL Property Path
import { findNodes } from 'clownface-shacl-path'
import fetch from '@rdfjs/fetch'
import $rdf from 'rdf-ext'
import clownface from 'clownface'
import { sh } from '@tpluscode/rdf-ns-builders'
const response = await fetch('http://zazuko.github.io/tbbt-ld/dist/tbbt.nt', { factory: $rdf })
const amy = clownface({ dataset: await response.dataset() })
.namedNode('http://localhost:8080/data/person/amy-farrah-fowler')
const path = clownface({ dataset: $rdf.dataset() }).blankNode()
path.addList(sh.alternativePath, [
path.blankNode().addOut(sh.inversePath, schema.spouse),
path.blankNode().addOut(sh.inversePath, schema.knows)
])
findNodes(amy, path)
Implementation
The package does not implement the *OrMore
paths