0.1.3 • Published 1 year ago
roxi-js v0.1.3
RoXi
RoXi provides a uniform framework for Reactive Reasoning applications including:
- Incremental maintenance
- RDF Stream Processing
Temporal Reasoning (TODO)
RoXi also supports efficient materialization of static data.
RoXi uses some of the internals of oxigraph, including sparqlalgebra and OxRDF.
RoXi can be included as a library, run in server mode through CLI or in the browser using web assembly. You can try it out in your own browser!
Usage
Example usage when using the static reasoner:
import {RoxiReasoner} from "roxi-js";
// create the reasoner
const reasoner = RoxiReasoner.new();
// add ABox
reasoner.add_abox("<http://example2.com/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.test.be/test#SubClass> .");
// Add rules
reasoner.add_rules("@prefix test: <http://www.test.be/test#>.\n @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\n {?s rdf:type test:SubClass. }=>{?s rdf:type test:SuperType.}");
// perform materialization through forward chaining
reasoner.materialize();
// log a dump of the materialized abox
console.log(reasoner.get_abox_dump());
Example usage when using the RSP engine:
import {JSRSPEngine} from "roxi-js";
// callback function
function callback(val) {
console.log(val);
}
let width = 10;
let slide = 2;
let rules = "@prefix test: <http://test/>.\n @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\n {?x test:isIn ?y. ?y test:isIn ?z. }=>{?x test:isIn ?z.}";
let abox = "";
let query = "Select * WHERE{ ?x <http://test/isIn> ?y}";
// create the engine
let rspEngine = JSRSPEngine.new(width,slide,rules,abox,query,callback);
// add some data
let event = "<http://test/0> <http://test/isIn> <http://test/1>.";
let currentTimeStamp = 0;
rspEngine.add(event, currentTimeStamp);
...
let event = ... ;
currentTimeStamp += 1;
rspEngine.add(event, currentTimeStamp);