@ontologos/wasm
v1.1.4
Published
WebAssembly bindings for the OntoLogos OWL reasoner
Maintainers
Readme
@ontologos/wasm
WebAssembly bindings for OntoLogos.
Install
npm install @ontologos/wasm| Channel | How |
|---------|-----|
| npm | @ontologos/wasm |
| Wasmer | eddiethedean/ontologos (.wasm module) |
| Source | Build this crate with wasm-pack (below) |
Build
# Install wasm-pack: https://rustwasm.github.io/wasm-pack/installer/
cd crates/ontologos-wasm
npm install
npm run build
npm testBrowser usage
import init, { OntologyBuilder, Reasoner } from "@ontologos/wasm";
await init({ module_or_path: wasmUrl });
const builder = new OntologyBuilder();
builder.addClass("http://example.org/Pizza");
builder.addClass("http://example.org/Food");
builder.subclassOf("http://example.org/Pizza", "http://example.org/Food");
const ontology = builder.build();
const reasoner = new Reasoner(ontology, "el");
const report = reasoner.classify();
console.log(report);Load OWL from bytes or text (no filesystem):
const ontology = Ontology.fromBytes(new TextEncoder().encode(owlString));
const reasoner = new Reasoner(ontology, "auto");Security
fromBytes/fromTextuse strict parse defaults for untrusted uploads.- Use
fromBytesLenient/fromTextLenientonly for trusted corpora. - Use
fromJsonWithLimitsfor user JSON with tightenedmax_json_bytes. - DL reasoning can block the main thread — set
budgetSecsand prefer Web Workers.
Full guide: WebAssembly bindings
API
Mirrors the Python bindings: Ontology, OntologyBuilder, Reasoner with classify(), checkConsistency(), isEntailed(), query(), and incremental axiom edits.
