n3 2.0.0-beta.2 → 2.0.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 +15 -12
- package/browser/n3.min.js +1 -1
- package/lib/BaseIRI.js +93 -0
- package/lib/IRIs.js +2 -1
- package/lib/N3Lexer.js +8 -3
- package/lib/N3Parser.js +9 -2
- package/lib/N3Store.js +24 -23
- package/lib/N3Util.js +6 -0
- package/lib/N3Writer.js +9 -10
- package/lib/Util.js +9 -0
- package/lib/index.js +9 -2
- package/package.json +4 -5
- package/src/BaseIRI.js +101 -0
- package/src/IRIs.js +1 -0
- package/src/N3Lexer.js +8 -3
- package/src/N3Parser.js +8 -1
- package/src/N3Store.js +22 -21
- package/src/N3Util.js +5 -0
- package/src/N3Writer.js +8 -11
- package/src/Util.js +3 -0
- package/src/index.js +3 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/n3)
|
|
5
5
|
[](https://zenodo.org/badge/latestdoi/3058202)
|
|
6
6
|
|
|
7
|
-
The N3.js library is an implementation of the [RDF.js low-level specification](http://rdf.js.org/) that lets you handle [RDF](https://www.w3.org/TR/rdf-primer/) in JavaScript easily.
|
|
7
|
+
The N3.js library is an implementation of the [RDF.js low-level specification](http://rdf.js.org/) that lets you handle [RDF 1.2](https://www.w3.org/TR/rdf-primer/) in JavaScript easily.
|
|
8
8
|
It offers:
|
|
9
9
|
|
|
10
10
|
- [**Parsing**](#parsing) triples/quads from
|
|
@@ -12,14 +12,12 @@ It offers:
|
|
|
12
12
|
[TriG](https://www.w3.org/TR/trig/),
|
|
13
13
|
[N-Triples](https://www.w3.org/TR/n-triples/),
|
|
14
14
|
[N-Quads](https://www.w3.org/TR/n-quads/),
|
|
15
|
-
[RDF-star](https://www.w3.org/2021/12/rdf-star.html)
|
|
16
15
|
and [Notation3 (N3)](https://www.w3.org/TeamSubmission/n3/)
|
|
17
16
|
- [**Writing**](#writing) triples/quads to
|
|
18
17
|
[Turtle](https://www.w3.org/TR/turtle/),
|
|
19
18
|
[TriG](https://www.w3.org/TR/trig/),
|
|
20
19
|
[N-Triples](https://www.w3.org/TR/n-triples/),
|
|
21
|
-
[N-Quads](https://www.w3.org/TR/n-quads/)
|
|
22
|
-
and [RDF-star](https://www.w3.org/2021/12/rdf-star.html)
|
|
20
|
+
and [N-Quads](https://www.w3.org/TR/n-quads/)
|
|
23
21
|
- [**Storage**](#storing) of triples/quads in memory
|
|
24
22
|
|
|
25
23
|
Parsing and writing is:
|
|
@@ -159,6 +157,13 @@ prefix or, if set to an empty string, completely disable prefixing:
|
|
|
159
157
|
const parser = new N3.Parser({ blankNodePrefix: '' });
|
|
160
158
|
```
|
|
161
159
|
|
|
160
|
+
The parser can output a backwards chaining rule such as `_:q <= _:p.` in two ways:
|
|
161
|
+
- as `_:p log:implies _:q.` (default)
|
|
162
|
+
- as `_:q log:isImpliedBy _:p.` (when the `isImpliedBy` flag is set to `true`)
|
|
163
|
+
```JavaScript
|
|
164
|
+
const parser = new N3.Parser({ isImpliedBy: true });
|
|
165
|
+
```
|
|
166
|
+
|
|
162
167
|
### From an RDF stream to quads
|
|
163
168
|
|
|
164
169
|
`N3.Parser` can parse [Node.js streams](http://nodejs.org/api/stream.html) as they grow,
|
|
@@ -395,7 +400,7 @@ const dataset = new Store(/* Dataset */)
|
|
|
395
400
|
|
|
396
401
|
// Applies the rules to the store; mutating it
|
|
397
402
|
const reasoner = new Reasoner(store);
|
|
398
|
-
reasoner.reason(
|
|
403
|
+
reasoner.reason(rulesDataset);
|
|
399
404
|
```
|
|
400
405
|
|
|
401
406
|
**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/).
|
|
@@ -411,19 +416,17 @@ The N3.js parser and writer is fully compatible with the following W3C specifica
|
|
|
411
416
|
– [EARL report](https://raw.githubusercontent.com/rdfjs/N3.js/earl/n3js-earl-report-ntriples.ttl)
|
|
412
417
|
- [RDF 1.1 N-Quads](https://www.w3.org/TR/n-quads/)
|
|
413
418
|
– [EARL report](https://raw.githubusercontent.com/rdfjs/N3.js/earl/n3js-earl-report-nquads.ttl)
|
|
419
|
+
- [RDF 1.2 Turtle](https://www.w3.org/TR/rdf12-turtle/)
|
|
420
|
+
- [RDF 1.2 TriG](https://www.w3.org/TR/rdf12-trig/)
|
|
421
|
+
- [RDF 1.2 N-Triples](https://www.w3.org/TR/rdf12-n-triples/)
|
|
422
|
+
- [RDF 1.2 N-Quads](https://www.w3.org/TR/rdf12-n-quads/)
|
|
414
423
|
|
|
415
424
|
In addition, the N3.js parser also supports [Notation3 (N3)](https://www.w3.org/TeamSubmission/n3/) (no official specification yet).
|
|
416
425
|
|
|
417
|
-
The N3.js parser and writer are also fully compatible with the RDF-star variants
|
|
418
|
-
of the W3C specifications.
|
|
419
|
-
|
|
420
426
|
The default mode is permissive
|
|
421
|
-
and allows a mixture of different syntaxes
|
|
427
|
+
and allows a mixture of different syntaxes.
|
|
422
428
|
Pass a `format` option to the constructor with the name or MIME type of a format
|
|
423
429
|
for strict, fault-intolerant behavior.
|
|
424
|
-
If a format string contains `star` or `*`
|
|
425
|
-
(e.g., `turtlestar` or `TriG*`),
|
|
426
|
-
RDF-star support for that format will be enabled.
|
|
427
430
|
|
|
428
431
|
### Interface specifications
|
|
429
432
|
The N3.js submodules are compatible with the following [RDF.js](http://rdf.js.org) interfaces:
|