The repos, tutorial, and examples are useful but not extensive or informative enough. This issue will collect useful commands from these and other sources, and try to work them into a framework of usage specific to our shacl-vue needs.
const fileUrl = new URL('../../node_modules/housemd/dist/housemd.nt', import.meta.url)
const fileRelativeUrl = './node_modules/housemd/dist/housemd.nt'
const httpUrl = 'https://housemd.rdf-ext.org/person/gregory-house'
async function main () {
// read a Dataset from a file URL
const gregoryHouseFile = await rdf.io.dataset.fromURL(fileUrl)
console.log(`read ${gregoryHouseFile.size} triples from ${fileUrl}`)
// read a Dataset from a relative file URL
const gregoryHouseFileRelative = await rdf.io.dataset.fromURL(fileRelativeUrl)
console.log(`read ${gregoryHouseFileRelative.size} triples from ${fileRelativeUrl}`)
// read a Dataset from a http URL
const gregoryHouseHttp = await rdf.io.dataset.fromURL(httpUrl)
console.log(`read ${gregoryHouseHttp.size} triples from ${httpUrl}`)
}
Serializing
import formatsPretty from '@rdfjs/formats/pretty.js'
// clone the default environment
const rdfPretty = rdf.clone()
// import pretty print serializers
rdfPretty.formats.import(formatsPretty)
// it's also possible import into the default like this:
// rdf.formats.import(formatsPretty)
// serialize a Dataset to plain text
console.log(await rdfPretty.io.dataset.toText('text/turtle', gregoryHouseHttp))
Filters nodes that have an incoming edge with the specified predicate and object.
hasOut(predicate, object)
Filters nodes that have an outgoing edge with the specified predicate and object.
// E.g. find all nodes with predicate rdf:type and object schema:Person
const results = grapoi({ dataset })
.hasOut(ns.rdf.type, ns.schema.Person)
.quads();
Sources:
The repos, tutorial, and examples are useful but not extensive or informative enough. This issue will collect useful commands from these and other sources, and try to work them into a framework of usage specific to our
shacl-vue
needs.Namespaces
Nodes and quads
Datasets
Datasets from URLs
Serializing
Dataset traversal
This uses grapoi
in()
out()
trim()
quads()
distinct()
hasIn(predicate, object)
hasOut(predicate, object)