Package Exports
- sparql-inferenced
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sparql-inferenced) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sparql-inferenced
An RDF inferencer that extends the HyLAR inferencing engine to allow inferencing with SPARQL Construct queries
Usage
import inferencer from 'sparql-inferenced'
import { Store, Parser } from 'n3';
import { owl2rl } from 'hylar-core';
import constructInferences from 'construct-inferences-shacl';
import * as fs from 'fs'
const parser = new Parser();
const ontologyQuads = parser.parse(
fs.readFileSync(/* Path to SHACL ontology */).toString()
);
const shaclConstraint = parser.parse(`
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix ex: <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
ex:myShape a sh:NodeShape ;
sh:property [
sh:path foaf:friend ;
] .
`)
const SHACLInferences = [...constructInferences, `
PREFIX ex: <http://example.org#>
CONSTRUCT {
?s ex:myCustomConstraint false
} WHERE {
?s a sh:PropertyShape
FILTER(NOT EXISTS { ?s ex:myCustomConstraint ?o })
}
`]
(async () => {
// Store to hold explicitly loaded triples
const explicit = new Store();
// Store to hold implicitly loaded triples
const implicit = new Store();
await inferencer(ontologyQuads, [], explicit, implicit, owl2rl, SHACLInferences)
await inferencer(shaclConstraint, [], explicit, implicit, owl2rl, SHACLInferences)
/**
* Implicit now contains inferenced triples including
*
* ex:myShape sh:closed false (from Construct inferences)
* _b:1 a sh:PropertyShape ; (from owl2rl inferences)
* sh:order 0 ; (from Construct inferences)
* sh:minCount 0 . (from Construct inferences)
*/
})
Future work
- Perform reasoning using
sh:rule