Skip to content

Commit

Permalink
feat: reasoning support (#395)
Browse files Browse the repository at this point in the history
* chore: implement an updated n3 reasoner

* feat: init N3Reasoner class

* chore: update perf script

* chore: suport dataset as input and documentation

* chore: add caveat to reasoning docs

* chore: editorial fix

Co-authored-by: Ted Thibodeau Jr <[email protected]>

* chore: editorial fix

Co-authored-by: Ted Thibodeau Jr <[email protected]>

* chore: editorial fix

Co-authored-by: Ruben Verborgh <[email protected]>
Co-authored-by: Ted Thibodeau Jr <[email protected]>

* chore: fix id lookup

---------

Co-authored-by: Ted Thibodeau Jr <[email protected]>
Co-authored-by: Ruben Verborgh <[email protected]>
  • Loading branch information
3 people authored Jul 29, 2024
1 parent 1a6122e commit ff73e61
Show file tree
Hide file tree
Showing 7 changed files with 2,131 additions and 63 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,33 @@ The store provides the following search methods
- `getGraphs` returns an array of unique graphs occurring in matching quad
- `forGraphs` executes a callback on unique graphs occurring in matching quads

## Reasoning

N3.js supports reasoning as follows:

```JavaScript
import { Reasoner, Store, Parser } from 'n3';

const parser = new Parser({ format: 'text/n3' });
const rules = `
{
?s a ?o .
?o <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?o2 .
} => {
?s a ?o2 .
} .
`

const rulesDataset = new Store(parser.parse(rules));
const dataset = new Store(/* Dataset */)

// Applies the rules to the store; mutating it
const reasoner = new Reasoner(store);
reasoner.reason(rules);
```

**Note**: N3.js currently only supports rules with [Basic Graph Patterns](https://www.w3.org/TR/sparql11-query/#BasicGraphPattern) in the premise and conclusion. Built-ins and backward-chaining are *not* supported. For an RDF/JS reasoner that supports all Notation3 reasoning features, see [eye-js](https://github.com/eyereasoner/eye-js/).

## Compatibility
### Format specifications
The N3.js parser and writer is fully compatible with the following W3C specifications:
Expand Down
Loading

0 comments on commit ff73e61

Please sign in to comment.