n3 1.18.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/browser/n3.min.js +1 -1
- package/lib/N3Reasoner.js +226 -0
- package/lib/N3Store.js +200 -7
- package/lib/N3Writer.js +3 -3
- package/lib/index.js +14 -0
- package/package.json +2 -1
- package/src/N3Reasoner.js +206 -0
- package/src/N3Store.js +231 -7
- package/src/N3Writer.js +4 -3
- package/src/index.js +4 -0
package/README.md
CHANGED
|
@@ -306,8 +306,8 @@ const store1 = new N3.Store([], { entityIndex });
|
|
|
306
306
|
const store2 = new N3.Store([], { entityIndex });
|
|
307
307
|
```
|
|
308
308
|
|
|
309
|
-
### [`
|
|
310
|
-
This store adheres to the `
|
|
309
|
+
### [`Dataset` Interface](https://rdf.js.org/dataset-spec/#dataset-interface)
|
|
310
|
+
This store adheres to the `Dataset` interface which exposes the following properties
|
|
311
311
|
|
|
312
312
|
Attributes:
|
|
313
313
|
- `size` — A non-negative integer that specifies the number of quads in the set.
|
|
@@ -320,7 +320,7 @@ Methods:
|
|
|
320
320
|
- `[Symbol.iterator]` — Implements the iterator protocol to allow iteration over all `quads` in the dataset as in the example above.
|
|
321
321
|
|
|
322
322
|
### Addition and deletion of quads
|
|
323
|
-
The store
|
|
323
|
+
The store implements the following manipulation methods in addition to the standard [`Dataset` Interface](https://rdf.js.org/dataset-spec/#dataset-interface)
|
|
324
324
|
([documentation](http://rdfjs.github.io/N3.js/docs/N3Store.html)):
|
|
325
325
|
- `addQuad` to insert one quad
|
|
326
326
|
- `addQuads` to insert an array of quads
|
|
@@ -349,6 +349,33 @@ The store provides the following search methods
|
|
|
349
349
|
- `getGraphs` returns an array of unique graphs occurring in matching quad
|
|
350
350
|
- `forGraphs` executes a callback on unique graphs occurring in matching quads
|
|
351
351
|
|
|
352
|
+
## Reasoning
|
|
353
|
+
|
|
354
|
+
N3.js supports reasoning as follows:
|
|
355
|
+
|
|
356
|
+
```JavaScript
|
|
357
|
+
import { Reasoner, Store, Parser } from 'n3';
|
|
358
|
+
|
|
359
|
+
const parser = new Parser({ format: 'text/n3' });
|
|
360
|
+
const rules = `
|
|
361
|
+
{
|
|
362
|
+
?s a ?o .
|
|
363
|
+
?o <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?o2 .
|
|
364
|
+
} => {
|
|
365
|
+
?s a ?o2 .
|
|
366
|
+
} .
|
|
367
|
+
`
|
|
368
|
+
|
|
369
|
+
const rulesDataset = new Store(parser.parse(rules));
|
|
370
|
+
const dataset = new Store(/* Dataset */)
|
|
371
|
+
|
|
372
|
+
// Applies the rules to the store; mutating it
|
|
373
|
+
const reasoner = new Reasoner(store);
|
|
374
|
+
reasoner.reason(rules);
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**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/).
|
|
378
|
+
|
|
352
379
|
## Compatibility
|
|
353
380
|
### Format specifications
|
|
354
381
|
The N3.js parser and writer is fully compatible with the following W3C specifications:
|