Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reasoning support #395

Merged
merged 10 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,32 @@ 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 now supports reasoning as follows:
jeswr marked this conversation as resolved.
Show resolved Hide resolved

```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 .
jeswr marked this conversation as resolved.
Show resolved Hide resolved
} .
`

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

// Applies the rules to the store; mutating it
new Reasoner(store).reason(rules);
jeswr marked this conversation as resolved.
Show resolved Hide resolved
```

**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 backwards chaining are *not* supported, for an RDF/JS reasoner that supports all Notation3 reasoning features see [eye-js](https://github.com/eyereasoner/eye-js/).
jeswr marked this conversation as resolved.
Show resolved Hide resolved

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