n3 1.23.2 → 1.24.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 +7 -0
- package/browser/n3.min.js +1 -1
- package/lib/IRIs.js +2 -1
- package/lib/N3Lexer.js +7 -1
- package/lib/N3Parser.js +6 -2
- package/package.json +1 -1
- package/src/IRIs.js +1 -0
- package/src/N3Lexer.js +8 -2
- package/src/N3Parser.js +4 -1
package/lib/IRIs.js
CHANGED
package/lib/N3Lexer.js
CHANGED
|
@@ -84,6 +84,9 @@ class N3Lexer {
|
|
|
84
84
|
this._endOfFile = /^(?:#[^\n\r]*)?$/;
|
|
85
85
|
options = options || {};
|
|
86
86
|
|
|
87
|
+
// Whether the log:isImpliedBy predicate is supported
|
|
88
|
+
this._isImpliedBy = options.isImpliedBy;
|
|
89
|
+
|
|
87
90
|
// In line mode (N-Triples or N-Quads), only simple features may be parsed
|
|
88
91
|
if (this._lineMode = !!options.lineMode) {
|
|
89
92
|
this._n3Mode = false;
|
|
@@ -179,7 +182,10 @@ class N3Lexer {
|
|
|
179
182
|
// Try to find a nested triple
|
|
180
183
|
else if (input.length > 1 && input[1] === '<') type = '<<', matchLength = 2;
|
|
181
184
|
// Try to find a backwards implication arrow
|
|
182
|
-
else if (this._n3Mode && input.length > 1 && input[1] === '=')
|
|
185
|
+
else if (this._n3Mode && input.length > 1 && input[1] === '=') {
|
|
186
|
+
matchLength = 2;
|
|
187
|
+
if (this._isImpliedBy) type = 'abbreviation', value = '<';else type = 'inverse', value = '>';
|
|
188
|
+
}
|
|
183
189
|
break;
|
|
184
190
|
case '>':
|
|
185
191
|
if (input.length > 1 && input[1] === '>') type = '>>', matchLength = 2;
|
package/lib/N3Parser.js
CHANGED
|
@@ -34,6 +34,8 @@ class N3Parser {
|
|
|
34
34
|
if (!(this._supportsNamedGraphs = !(isTurtle || isN3))) this._readPredicateOrNamedGraph = this._readPredicate;
|
|
35
35
|
// Support triples in other graphs
|
|
36
36
|
this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);
|
|
37
|
+
// Whether the log:isImpliedBy predicate is supported
|
|
38
|
+
this._isImpliedBy = options.isImpliedBy;
|
|
37
39
|
// Support nesting of triples
|
|
38
40
|
this._supportsRDFStar = format === '' || /star|\*$/.test(format);
|
|
39
41
|
// Disable relative IRIs in N-Triples or N-Quads mode
|
|
@@ -43,7 +45,8 @@ class N3Parser {
|
|
|
43
45
|
this._blankNodePrefix = typeof options.blankNodePrefix !== 'string' ? '' : options.blankNodePrefix.replace(/^(?!_:)/, '_:');
|
|
44
46
|
this._lexer = options.lexer || new _N3Lexer.default({
|
|
45
47
|
lineMode: isLineMode,
|
|
46
|
-
n3: isN3
|
|
48
|
+
n3: isN3,
|
|
49
|
+
isImpliedBy: this._isImpliedBy
|
|
47
50
|
});
|
|
48
51
|
// Disable explicit quantifiers by default
|
|
49
52
|
this._explicitQuantifiers = !!options.explicitQuantifiers;
|
|
@@ -1019,7 +1022,8 @@ function initDataFactory(parser, factory) {
|
|
|
1019
1022
|
parser.ABBREVIATIONS = {
|
|
1020
1023
|
'a': factory.namedNode(_IRIs.default.rdf.type),
|
|
1021
1024
|
'=': factory.namedNode(_IRIs.default.owl.sameAs),
|
|
1022
|
-
'>': factory.namedNode(_IRIs.default.log.implies)
|
|
1025
|
+
'>': factory.namedNode(_IRIs.default.log.implies),
|
|
1026
|
+
'<': factory.namedNode(_IRIs.default.log.isImpliedBy)
|
|
1023
1027
|
};
|
|
1024
1028
|
parser.QUANTIFIERS_GRAPH = factory.namedNode('urn:n3:quantifiers');
|
|
1025
1029
|
}
|
package/package.json
CHANGED
package/src/IRIs.js
CHANGED
package/src/N3Lexer.js
CHANGED
|
@@ -54,6 +54,9 @@ export default class N3Lexer {
|
|
|
54
54
|
this._endOfFile = /^(?:#[^\n\r]*)?$/;
|
|
55
55
|
options = options || {};
|
|
56
56
|
|
|
57
|
+
// Whether the log:isImpliedBy predicate is supported
|
|
58
|
+
this._isImpliedBy = options.isImpliedBy;
|
|
59
|
+
|
|
57
60
|
// In line mode (N-Triples or N-Quads), only simple features may be parsed
|
|
58
61
|
if (this._lineMode = !!options.lineMode) {
|
|
59
62
|
this._n3Mode = false;
|
|
@@ -152,8 +155,11 @@ export default class N3Lexer {
|
|
|
152
155
|
else if (input.length > 1 && input[1] === '<')
|
|
153
156
|
type = '<<', matchLength = 2;
|
|
154
157
|
// Try to find a backwards implication arrow
|
|
155
|
-
else if (this._n3Mode && input.length > 1 && input[1] === '=')
|
|
156
|
-
|
|
158
|
+
else if (this._n3Mode && input.length > 1 && input[1] === '=') {
|
|
159
|
+
matchLength = 2;
|
|
160
|
+
if (this._isImpliedBy) type = 'abbreviation', value = '<';
|
|
161
|
+
else type = 'inverse', value = '>';
|
|
162
|
+
}
|
|
157
163
|
break;
|
|
158
164
|
|
|
159
165
|
case '>':
|
package/src/N3Parser.js
CHANGED
|
@@ -27,6 +27,8 @@ export default class N3Parser {
|
|
|
27
27
|
this._readPredicateOrNamedGraph = this._readPredicate;
|
|
28
28
|
// Support triples in other graphs
|
|
29
29
|
this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);
|
|
30
|
+
// Whether the log:isImpliedBy predicate is supported
|
|
31
|
+
this._isImpliedBy = options.isImpliedBy;
|
|
30
32
|
// Support nesting of triples
|
|
31
33
|
this._supportsRDFStar = format === '' || /star|\*$/.test(format);
|
|
32
34
|
// Disable relative IRIs in N-Triples or N-Quads mode
|
|
@@ -34,7 +36,7 @@ export default class N3Parser {
|
|
|
34
36
|
this._resolveRelativeIRI = iri => { return null; };
|
|
35
37
|
this._blankNodePrefix = typeof options.blankNodePrefix !== 'string' ? '' :
|
|
36
38
|
options.blankNodePrefix.replace(/^(?!_:)/, '_:');
|
|
37
|
-
this._lexer = options.lexer || new N3Lexer({ lineMode: isLineMode, n3: isN3 });
|
|
39
|
+
this._lexer = options.lexer || new N3Lexer({ lineMode: isLineMode, n3: isN3, isImpliedBy: this._isImpliedBy });
|
|
38
40
|
// Disable explicit quantifiers by default
|
|
39
41
|
this._explicitQuantifiers = !!options.explicitQuantifiers;
|
|
40
42
|
}
|
|
@@ -1096,6 +1098,7 @@ function initDataFactory(parser, factory) {
|
|
|
1096
1098
|
'a': factory.namedNode(namespaces.rdf.type),
|
|
1097
1099
|
'=': factory.namedNode(namespaces.owl.sameAs),
|
|
1098
1100
|
'>': factory.namedNode(namespaces.log.implies),
|
|
1101
|
+
'<': factory.namedNode(namespaces.log.isImpliedBy),
|
|
1099
1102
|
};
|
|
1100
1103
|
parser.QUANTIFIERS_GRAPH = factory.namedNode('urn:n3:quantifiers');
|
|
1101
1104
|
}
|