rdflib 2.2.21 → 2.2.22-0de51c50
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/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +13 -1
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +3 -27
- package/esm/collection.js +7 -29
- package/esm/default-graph.js +1 -15
- package/esm/empty.js +0 -13
- package/esm/factories/canonical-data-factory.js +5 -40
- package/esm/factories/extended-term-factory.js +0 -11
- package/esm/factories/factory-types.js +2 -1
- package/esm/factories/rdflib-data-factory.js +0 -8
- package/esm/fetcher.js +257 -481
- package/esm/formula.js +43 -142
- package/esm/index.js +19 -36
- package/esm/jsonldparser.js +20 -29
- package/esm/jsonparser.js +0 -7
- package/esm/lists.js +18 -33
- package/esm/literal.js +10 -42
- package/esm/n3parser.js +38 -351
- package/esm/named-node.js +8 -27
- package/esm/namespace.js +0 -1
- package/esm/node-internal.js +11 -24
- package/esm/node.js +1 -6
- package/esm/parse.js +10 -17
- package/esm/patch-parser.js +9 -29
- package/esm/query-to-sparql.js +0 -18
- package/esm/query.js +50 -133
- package/esm/rdfaparser.js +72 -210
- package/esm/rdfxmlparser.js +31 -128
- package/esm/serialize.js +8 -33
- package/esm/serializer.js +122 -286
- package/esm/sparql-to-query.js +44 -134
- package/esm/statement.js +8 -19
- package/esm/store.js +109 -280
- package/esm/types.js +3 -2
- package/esm/update-manager.js +110 -246
- package/esm/updates-via.js +0 -27
- package/esm/uri.js +6 -50
- package/esm/utils/default-graph-uri.js +1 -0
- package/esm/utils/termValue.js +0 -1
- package/esm/utils/terms.js +15 -16
- package/esm/utils-js.js +16 -57
- package/esm/utils.js +4 -15
- package/esm/variable.js +0 -20
- package/lib/blank-node.js +3 -28
- package/lib/class-order.js +0 -1
- package/lib/collection.js +7 -34
- package/lib/default-graph.js +0 -20
- package/lib/empty.js +0 -18
- package/lib/factories/canonical-data-factory.js +4 -51
- package/lib/factories/extended-term-factory.js +0 -18
- package/lib/factories/factory-types.d.ts +6 -6
- package/lib/factories/factory-types.js +0 -3
- package/lib/factories/rdflib-data-factory.js +0 -12
- package/lib/fetcher.d.ts +6 -6
- package/lib/fetcher.js +258 -470
- package/lib/formula.d.ts +1 -1
- package/lib/formula.js +43 -151
- package/lib/index.d.ts +1 -2
- package/lib/index.js +14 -82
- package/lib/jsonldparser.js +19 -33
- package/lib/jsonparser.js +0 -9
- package/lib/lists.js +14 -39
- package/lib/literal.js +10 -49
- package/lib/log.d.ts +0 -6
- package/lib/log.js +0 -1
- package/lib/n3parser.d.ts +1 -0
- package/lib/n3parser.js +39 -359
- package/lib/named-node.js +7 -35
- package/lib/namespace.js +0 -3
- package/lib/node-internal.js +11 -21
- package/lib/node.js +1 -11
- package/lib/parse.d.ts +1 -1
- package/lib/parse.js +8 -27
- package/lib/patch-parser.js +10 -33
- package/lib/query-to-sparql.js +0 -23
- package/lib/query.js +46 -152
- package/lib/rdfaparser.js +72 -220
- package/lib/rdfxmlparser.js +31 -132
- package/lib/serialize.d.ts +1 -1
- package/lib/serialize.js +8 -43
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +121 -297
- package/lib/sparql-to-query.js +42 -167
- package/lib/statement.js +8 -24
- package/lib/store.d.ts +2 -2
- package/lib/store.js +102 -282
- package/lib/tf-types.d.ts +4 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +3 -3
- package/lib/update-manager.d.ts +2 -2
- package/lib/update-manager.js +110 -254
- package/lib/updates-via.js +0 -30
- package/lib/uri.js +5 -58
- package/lib/utils/default-graph-uri.js +1 -3
- package/lib/utils/termValue.js +0 -2
- package/lib/utils/terms.js +15 -34
- package/lib/utils-js.js +16 -80
- package/lib/utils.js +4 -21
- package/lib/variable.js +0 -25
- package/lib/xsd-internal.js +0 -3
- package/lib/xsd.js +0 -4
- package/package.json +40 -39
- package/src/fetcher.ts +2 -2
- package/src/index.ts +0 -2
- package/src/jsonldparser.js +13 -4
- package/src/n3parser.js +12 -4
- package/src/serialize.ts +4 -11
- package/src/serializer.js +24 -0
- package/src/update-manager.ts +18 -7
- package/changes.txt +0 -59
- package/esm/convert.js +0 -61
- package/lib/convert.d.ts +0 -2
- package/lib/convert.js +0 -77
- package/src/convert.js +0 -70
package/lib/formula.js
CHANGED
|
@@ -1,68 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
15
|
var _classOrder = _interopRequireDefault(require("./class-order"));
|
|
25
|
-
|
|
26
16
|
var _collection = _interopRequireDefault(require("./collection"));
|
|
27
|
-
|
|
28
17
|
var _canonicalDataFactory = _interopRequireDefault(require("./factories/canonical-data-factory"));
|
|
29
|
-
|
|
30
18
|
var _log = _interopRequireDefault(require("./log"));
|
|
31
|
-
|
|
32
19
|
var _namespace = _interopRequireDefault(require("./namespace"));
|
|
33
|
-
|
|
34
20
|
var _nodeInternal = _interopRequireDefault(require("./node-internal"));
|
|
35
|
-
|
|
36
21
|
var _serialize2 = _interopRequireDefault(require("./serialize"));
|
|
37
|
-
|
|
38
22
|
var _types = require("./types");
|
|
39
|
-
|
|
40
23
|
var _terms = require("./utils/terms");
|
|
41
|
-
|
|
42
24
|
var _variable = _interopRequireDefault(require("./variable"));
|
|
43
|
-
|
|
44
25
|
var _utils = require("./utils");
|
|
45
|
-
|
|
46
26
|
var _namedNode = _interopRequireDefault(require("./named-node"));
|
|
47
|
-
|
|
48
27
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
49
|
-
|
|
50
28
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
51
|
-
|
|
52
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
53
|
-
|
|
29
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
54
30
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
55
|
-
|
|
56
31
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
57
|
-
|
|
58
32
|
/**
|
|
59
33
|
* A formula, or store of RDF statements
|
|
60
34
|
*/
|
|
61
35
|
var Formula = /*#__PURE__*/function (_Node) {
|
|
62
36
|
(0, _inherits2.default)(Formula, _Node);
|
|
63
|
-
|
|
64
37
|
var _super = _createSuper(Formula);
|
|
65
|
-
|
|
66
38
|
/**
|
|
67
39
|
* The accompanying fetcher instance.
|
|
68
40
|
*
|
|
@@ -88,7 +60,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
88
60
|
*/
|
|
89
61
|
function Formula() {
|
|
90
62
|
var _this;
|
|
91
|
-
|
|
92
63
|
var statements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
93
64
|
var constraints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
94
65
|
var initBindings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
@@ -106,22 +77,18 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
106
77
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isVar", 0);
|
|
107
78
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "ns", _namespace.default);
|
|
108
79
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "rdfFactory", void 0);
|
|
109
|
-
_this.rdfFactory = opts && opts.rdfFactory || _canonicalDataFactory.default;
|
|
110
|
-
|
|
80
|
+
_this.rdfFactory = opts && opts.rdfFactory || _canonicalDataFactory.default;
|
|
81
|
+
// Enable default factory methods on this while preserving factory context.
|
|
111
82
|
var _iterator = _createForOfIteratorHelper(_utils.appliedFactoryMethods),
|
|
112
|
-
|
|
113
|
-
|
|
83
|
+
_step;
|
|
114
84
|
try {
|
|
115
85
|
var _loop = function _loop() {
|
|
116
86
|
var factoryMethod = _step.value;
|
|
117
|
-
|
|
118
87
|
_this[factoryMethod] = function () {
|
|
119
88
|
var _this$rdfFactory;
|
|
120
|
-
|
|
121
89
|
return (_this$rdfFactory = _this.rdfFactory)[factoryMethod].apply(_this$rdfFactory, arguments);
|
|
122
90
|
};
|
|
123
91
|
};
|
|
124
|
-
|
|
125
92
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
126
93
|
_loop();
|
|
127
94
|
}
|
|
@@ -130,63 +97,59 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
130
97
|
} finally {
|
|
131
98
|
_iterator.f();
|
|
132
99
|
}
|
|
133
|
-
|
|
134
100
|
return _this;
|
|
135
101
|
}
|
|
102
|
+
|
|
136
103
|
/** Add a statement from its parts
|
|
137
104
|
* @param subject - the first part of the statement
|
|
138
105
|
* @param predicate - the second part of the statement
|
|
139
106
|
* @param object - the third part of the statement
|
|
140
107
|
* @param graph - the last part of the statement
|
|
141
108
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
109
|
(0, _createClass2.default)(Formula, [{
|
|
145
110
|
key: "add",
|
|
146
111
|
value: function add(subject, predicate, object, graph) {
|
|
147
112
|
var _this2 = this;
|
|
148
|
-
|
|
149
113
|
if (arguments.length === 1) {
|
|
150
114
|
subject.forEach(function (st) {
|
|
151
115
|
return _this2.add(st.subject, st.predicate, st.object, st.graph);
|
|
152
116
|
});
|
|
153
117
|
}
|
|
154
|
-
|
|
155
118
|
return this.statements.push(this.rdfFactory.quad(subject, predicate, object, graph));
|
|
156
119
|
}
|
|
120
|
+
|
|
157
121
|
/** Add a statment object
|
|
158
122
|
* @param {Statement} statement - An existing constructed statement to add
|
|
159
123
|
*/
|
|
160
|
-
|
|
161
124
|
}, {
|
|
162
125
|
key: "addStatement",
|
|
163
126
|
value: function addStatement(statement) {
|
|
164
127
|
return this.add(statement);
|
|
165
128
|
}
|
|
129
|
+
|
|
166
130
|
/**
|
|
167
131
|
* Shortcut for adding blankNodes
|
|
168
132
|
* @param [id]
|
|
169
133
|
*/
|
|
170
|
-
|
|
171
134
|
}, {
|
|
172
135
|
key: "bnode",
|
|
173
136
|
value: function bnode(id) {
|
|
174
137
|
return this.rdfFactory.blankNode(id);
|
|
175
138
|
}
|
|
139
|
+
|
|
176
140
|
/**
|
|
177
141
|
* Adds all the statements to this formula
|
|
178
142
|
* @param statements - A collection of statements
|
|
179
143
|
*/
|
|
180
|
-
|
|
181
144
|
}, {
|
|
182
145
|
key: "addAll",
|
|
183
146
|
value: function addAll(statements) {
|
|
184
147
|
var _this3 = this;
|
|
185
|
-
|
|
186
148
|
statements.forEach(function (quad) {
|
|
187
149
|
_this3.add(quad.subject, quad.predicate, quad.object, quad.graph);
|
|
188
150
|
});
|
|
189
151
|
}
|
|
152
|
+
|
|
190
153
|
/** Follow link from one node, using one wildcard, looking for one
|
|
191
154
|
*
|
|
192
155
|
* For example, any(me, knows, null, profile) - a person I know accoring to my profile .
|
|
@@ -199,12 +162,10 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
199
162
|
* @param g - A node to search for as graph, or if null, a wildcard
|
|
200
163
|
* @returns A node which match the wildcard position, or null
|
|
201
164
|
*/
|
|
202
|
-
|
|
203
165
|
}, {
|
|
204
166
|
key: "any",
|
|
205
167
|
value: function any(s, p, o, g) {
|
|
206
168
|
var st = this.anyStatementMatching(s, p, o, g);
|
|
207
|
-
|
|
208
169
|
if (st == null) {
|
|
209
170
|
return null;
|
|
210
171
|
} else if (s == null) {
|
|
@@ -214,9 +175,9 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
214
175
|
} else if (o == null) {
|
|
215
176
|
return st.object;
|
|
216
177
|
}
|
|
217
|
-
|
|
218
178
|
return null;
|
|
219
179
|
}
|
|
180
|
+
|
|
220
181
|
/**
|
|
221
182
|
* Gets the value of a node that matches the specified pattern
|
|
222
183
|
* @param s The subject
|
|
@@ -224,13 +185,13 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
224
185
|
* @param o The object
|
|
225
186
|
* @param g The graph that contains the statement
|
|
226
187
|
*/
|
|
227
|
-
|
|
228
188
|
}, {
|
|
229
189
|
key: "anyValue",
|
|
230
190
|
value: function anyValue(s, p, o, g) {
|
|
231
191
|
var y = this.any(s, p, o, g);
|
|
232
192
|
return y ? y.value : void 0;
|
|
233
193
|
}
|
|
194
|
+
|
|
234
195
|
/**
|
|
235
196
|
* Gets the first JavaScript object equivalent to a node based on the specified pattern
|
|
236
197
|
* @param s The subject
|
|
@@ -238,39 +199,37 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
238
199
|
* @param o The object
|
|
239
200
|
* @param g The graph that contains the statement
|
|
240
201
|
*/
|
|
241
|
-
|
|
242
202
|
}, {
|
|
243
203
|
key: "anyJS",
|
|
244
204
|
value: function anyJS(s, p, o, g) {
|
|
245
205
|
var y = this.any(s, p, o, g);
|
|
246
206
|
return y ? _nodeInternal.default.toJS(y) : void 0;
|
|
247
207
|
}
|
|
208
|
+
|
|
248
209
|
/**
|
|
249
210
|
* Gets the first statement that matches the specified pattern
|
|
250
211
|
*/
|
|
251
|
-
|
|
252
212
|
}, {
|
|
253
213
|
key: "anyStatementMatching",
|
|
254
214
|
value: function anyStatementMatching(s, p, o, g) {
|
|
255
215
|
var x = this.statementsMatching(s, p, o, g, true);
|
|
256
|
-
|
|
257
216
|
if (!x || x.length === 0) {
|
|
258
217
|
return undefined;
|
|
259
218
|
}
|
|
260
|
-
|
|
261
219
|
return x[0];
|
|
262
220
|
}
|
|
221
|
+
|
|
263
222
|
/**
|
|
264
223
|
* Returns a unique index-safe identifier for the given term.
|
|
265
224
|
*
|
|
266
225
|
* Falls back to the rdflib hashString implementation if the given factory doesn't support id.
|
|
267
226
|
*/
|
|
268
|
-
|
|
269
227
|
}, {
|
|
270
228
|
key: "id",
|
|
271
229
|
value: function id(term) {
|
|
272
230
|
return this.rdfFactory.id(term);
|
|
273
231
|
}
|
|
232
|
+
|
|
274
233
|
/**
|
|
275
234
|
* Search the Store
|
|
276
235
|
* This is really a teaching method as to do this properly you would use IndexedFormula
|
|
@@ -282,20 +241,18 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
282
241
|
* @param justOne - flag - stop when found one rather than get all of them?
|
|
283
242
|
* @returns {Array<Node>} - An array of nodes which match the wildcard position
|
|
284
243
|
*/
|
|
285
|
-
|
|
286
244
|
}, {
|
|
287
245
|
key: "statementsMatching",
|
|
288
246
|
value: function statementsMatching(s, p, o, g, justOne) {
|
|
289
247
|
var sts = this.statements.filter(function (st) {
|
|
290
248
|
return (!s || s.equals(st.subject)) && (!p || p.equals(st.predicate)) && (!o || o.equals(st.object)) && (!g || g.equals(st.graph));
|
|
291
249
|
});
|
|
292
|
-
|
|
293
250
|
if (justOne) {
|
|
294
251
|
return sts.length === 0 ? [] : [sts[0]];
|
|
295
252
|
}
|
|
296
|
-
|
|
297
253
|
return sts;
|
|
298
254
|
}
|
|
255
|
+
|
|
299
256
|
/**
|
|
300
257
|
* Finds the types in the list which have no *stored* subtypes
|
|
301
258
|
* These are a set of classes which provide by themselves complete
|
|
@@ -303,7 +260,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
303
260
|
* know the class DAG.
|
|
304
261
|
* @param types A map of the types
|
|
305
262
|
*/
|
|
306
|
-
|
|
307
263
|
}, {
|
|
308
264
|
key: "bottomTypeURIs",
|
|
309
265
|
value: function bottomTypeURIs(types) {
|
|
@@ -316,39 +272,35 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
316
272
|
var subs;
|
|
317
273
|
var v;
|
|
318
274
|
bots = [];
|
|
319
|
-
|
|
320
275
|
for (var _k in types) {
|
|
321
276
|
if (!types.hasOwnProperty(_k)) continue;
|
|
322
277
|
v = types[_k];
|
|
323
278
|
subs = this.each(void 0, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#subClassOf'), this.rdfFactory.namedNode(_k));
|
|
324
279
|
bottom = true;
|
|
325
280
|
i = 0;
|
|
326
|
-
|
|
327
281
|
for (len = subs.length; i < len; i++) {
|
|
328
282
|
elt = subs[i];
|
|
329
283
|
ref = elt.uri;
|
|
330
|
-
|
|
331
284
|
if (ref in types) {
|
|
332
285
|
// the subclass is one we know
|
|
333
286
|
bottom = false;
|
|
334
287
|
break;
|
|
335
288
|
}
|
|
336
289
|
}
|
|
337
|
-
|
|
338
290
|
if (bottom) {
|
|
339
291
|
bots[_k] = v;
|
|
340
292
|
}
|
|
341
293
|
}
|
|
342
|
-
|
|
343
294
|
return bots;
|
|
344
295
|
}
|
|
345
|
-
/** Creates a new collection */
|
|
346
296
|
|
|
297
|
+
/** Creates a new collection */
|
|
347
298
|
}, {
|
|
348
299
|
key: "collection",
|
|
349
300
|
value: function collection() {
|
|
350
301
|
return new _collection.default();
|
|
351
302
|
}
|
|
303
|
+
|
|
352
304
|
/** Follow links from one node, using one wildcard.
|
|
353
305
|
*
|
|
354
306
|
* For example, each(me, knows, null, profile) - people I know accoring to my profile .
|
|
@@ -361,13 +313,11 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
361
313
|
* @param g - A node to search for as graph, or if null, a wildcard
|
|
362
314
|
* @returns {Array<Node>} - An array of nodes which match the wildcard position
|
|
363
315
|
*/
|
|
364
|
-
|
|
365
316
|
}, {
|
|
366
317
|
key: "each",
|
|
367
318
|
value: function each(s, p, o, g) {
|
|
368
319
|
var results = [];
|
|
369
320
|
var sts = this.statementsMatching(s, p, o, g, false);
|
|
370
|
-
|
|
371
321
|
if (s == null) {
|
|
372
322
|
for (var i = 0, len = sts.length; i < len; i++) {
|
|
373
323
|
results.push(sts[i].subject);
|
|
@@ -385,23 +335,22 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
385
335
|
results.push(new _namedNode.default(sts[_q].graph.value));
|
|
386
336
|
}
|
|
387
337
|
}
|
|
388
|
-
|
|
389
338
|
return results;
|
|
390
339
|
}
|
|
340
|
+
|
|
391
341
|
/**
|
|
392
342
|
* Test whether this formula is equals to {other}
|
|
393
343
|
* @param other - The other formula
|
|
394
344
|
*/
|
|
395
|
-
|
|
396
345
|
}, {
|
|
397
346
|
key: "equals",
|
|
398
347
|
value: function equals(other) {
|
|
399
348
|
if (!other) {
|
|
400
349
|
return false;
|
|
401
350
|
}
|
|
402
|
-
|
|
403
351
|
return this.hashString() === other.hashString();
|
|
404
352
|
}
|
|
353
|
+
|
|
405
354
|
/**
|
|
406
355
|
* For thisClass or any subclass, anything which has it is its type
|
|
407
356
|
* or is the object of something which has the type as its range, or subject
|
|
@@ -411,7 +360,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
411
360
|
* Get all the Classes of which we can RDFS-infer the subject is a member
|
|
412
361
|
* @return a hash of URIs
|
|
413
362
|
*/
|
|
414
|
-
|
|
415
363
|
}, {
|
|
416
364
|
key: "findMembersNT",
|
|
417
365
|
value: function findMembersNT(thisClass) {
|
|
@@ -433,43 +381,35 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
433
381
|
seeds[thisClass.toNT()] = true;
|
|
434
382
|
members = {};
|
|
435
383
|
ref = this.transitiveClosure(seeds, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#subClassOf'), true);
|
|
436
|
-
|
|
437
384
|
for (var t in ref) {
|
|
438
385
|
if (!ref.hasOwnProperty(t)) continue;
|
|
439
386
|
ref1 = this.statementsMatching(void 0, this.rdfFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), this.fromNT(t));
|
|
440
|
-
|
|
441
387
|
for (var i = 0, len = ref1.length; i < len; i++) {
|
|
442
388
|
st = ref1[i];
|
|
443
389
|
members[st.subject.toNT()] = st;
|
|
444
390
|
}
|
|
445
|
-
|
|
446
391
|
ref2 = this.each(void 0, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#domain'), this.fromNT(t));
|
|
447
|
-
|
|
448
392
|
for (var l = 0, len1 = ref2.length; l < len1; l++) {
|
|
449
393
|
pred = ref2[l];
|
|
450
394
|
ref3 = this.statementsMatching(void 0, pred);
|
|
451
|
-
|
|
452
395
|
for (m = 0, len2 = ref3.length; m < len2; m++) {
|
|
453
396
|
st = ref3[m];
|
|
454
397
|
members[st.subject.toNT()] = st;
|
|
455
398
|
}
|
|
456
399
|
}
|
|
457
|
-
|
|
458
400
|
ref4 = this.each(void 0, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#range'), this.fromNT(t));
|
|
459
|
-
|
|
460
401
|
for (var _q2 = 0, len3 = ref4.length; _q2 < len3; _q2++) {
|
|
461
402
|
pred = ref4[_q2];
|
|
462
403
|
ref5 = this.statementsMatching(void 0, pred);
|
|
463
|
-
|
|
464
404
|
for (u = 0, len4 = ref5.length; u < len4; u++) {
|
|
465
405
|
st = ref5[u];
|
|
466
406
|
members[st.object.toNT()] = st;
|
|
467
407
|
}
|
|
468
408
|
}
|
|
469
409
|
}
|
|
470
|
-
|
|
471
410
|
return members;
|
|
472
411
|
}
|
|
412
|
+
|
|
473
413
|
/**
|
|
474
414
|
* For thisClass or any subclass, anything which has it is its type
|
|
475
415
|
* or is the object of something which has the type as its range, or subject
|
|
@@ -479,12 +419,12 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
479
419
|
* Get all the Classes of which we can RDFS-infer the subject is a member
|
|
480
420
|
* @param subject - A named node
|
|
481
421
|
*/
|
|
482
|
-
|
|
483
422
|
}, {
|
|
484
423
|
key: "findMemberURIs",
|
|
485
424
|
value: function findMemberURIs(subject) {
|
|
486
425
|
return this.NTtoURI(this.findMembersNT(subject));
|
|
487
426
|
}
|
|
427
|
+
|
|
488
428
|
/**
|
|
489
429
|
* Get all the Classes of which we can RDFS-infer the subject is a superclass
|
|
490
430
|
* Returns a hash table where key is NT of type and value is statement why we
|
|
@@ -492,7 +432,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
492
432
|
* Does NOT return terms, returns URI strings.
|
|
493
433
|
* We use NT representations in this version because they handle blank nodes.
|
|
494
434
|
*/
|
|
495
|
-
|
|
496
435
|
}, {
|
|
497
436
|
key: "findSubClassesNT",
|
|
498
437
|
value: function findSubClassesNT(subject) {
|
|
@@ -500,6 +439,7 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
500
439
|
types[subject.toNT()] = true;
|
|
501
440
|
return this.transitiveClosure(types, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#subClassOf'), true);
|
|
502
441
|
}
|
|
442
|
+
|
|
503
443
|
/**
|
|
504
444
|
* Get all the Classes of which we can RDFS-infer the subject is a subclass
|
|
505
445
|
* @param {RDFlibNamedNode} subject - The thing whose classes are to be found
|
|
@@ -508,7 +448,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
508
448
|
* Does NOT return terms, returns URI strings.
|
|
509
449
|
* We use NT representations in this version because they handle blank nodes.
|
|
510
450
|
*/
|
|
511
|
-
|
|
512
451
|
}, {
|
|
513
452
|
key: "findSuperClassesNT",
|
|
514
453
|
value: function findSuperClassesNT(subject) {
|
|
@@ -516,6 +455,7 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
516
455
|
types[subject.toNT()] = true;
|
|
517
456
|
return this.transitiveClosure(types, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#subClassOf'), false);
|
|
518
457
|
}
|
|
458
|
+
|
|
519
459
|
/**
|
|
520
460
|
* Get all the Classes of which we can RDFS-infer the subject is a member
|
|
521
461
|
* todo: This will loop is there is a class subclass loop (Sublass loops are
|
|
@@ -525,7 +465,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
525
465
|
* Does NOT return terms, returns URI strings.
|
|
526
466
|
* We use NT representations in this version because they handle blank nodes.
|
|
527
467
|
*/
|
|
528
|
-
|
|
529
468
|
}, {
|
|
530
469
|
key: "findTypesNT",
|
|
531
470
|
value: function findTypesNT(subject) {
|
|
@@ -541,36 +480,30 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
541
480
|
rdftype = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
|
|
542
481
|
types = [];
|
|
543
482
|
ref = this.statementsMatching(subject, void 0, void 0);
|
|
544
|
-
|
|
545
483
|
for (var i = 0, len = ref.length; i < len; i++) {
|
|
546
484
|
st = ref[i];
|
|
547
|
-
|
|
548
485
|
if (st.predicate.uri === rdftype) {
|
|
549
486
|
types[st.object.toNT()] = st;
|
|
550
487
|
} else {
|
|
551
488
|
ref1 = this.each(st.predicate, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#domain'));
|
|
552
|
-
|
|
553
489
|
for (var l = 0, len1 = ref1.length; l < len1; l++) {
|
|
554
490
|
range = ref1[l];
|
|
555
491
|
types[range.toNT()] = st;
|
|
556
492
|
}
|
|
557
493
|
}
|
|
558
494
|
}
|
|
559
|
-
|
|
560
495
|
ref2 = this.statementsMatching(void 0, void 0, subject);
|
|
561
|
-
|
|
562
496
|
for (var m = 0, len2 = ref2.length; m < len2; m++) {
|
|
563
497
|
st = ref2[m];
|
|
564
498
|
ref3 = this.each(st.predicate, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#range'));
|
|
565
|
-
|
|
566
499
|
for (var _q3 = 0, len3 = ref3.length; _q3 < len3; _q3++) {
|
|
567
500
|
domain = ref3[_q3];
|
|
568
501
|
types[domain.toNT()] = st;
|
|
569
502
|
}
|
|
570
503
|
}
|
|
571
|
-
|
|
572
504
|
return this.transitiveClosure(types, this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#subClassOf'), false);
|
|
573
505
|
}
|
|
506
|
+
|
|
574
507
|
/**
|
|
575
508
|
* Get all the Classes of which we can RDFS-infer the subject is a member
|
|
576
509
|
* todo: This will loop is there is a class subclass loop (Sublass loops are
|
|
@@ -581,19 +514,18 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
581
514
|
* We use NT representations in this version because they handle blank nodes.
|
|
582
515
|
* @param subject - A subject node
|
|
583
516
|
*/
|
|
584
|
-
|
|
585
517
|
}, {
|
|
586
518
|
key: "findTypeURIs",
|
|
587
519
|
value: function findTypeURIs(subject) {
|
|
588
520
|
return this.NTtoURI(this.findTypesNT(subject));
|
|
589
521
|
}
|
|
522
|
+
|
|
590
523
|
/** Trace statements which connect directly, or through bnodes
|
|
591
524
|
*
|
|
592
525
|
* @param subject - The node to start looking for statments
|
|
593
526
|
* @param doc - The document to be searched, or null to search all documents
|
|
594
527
|
* @returns an array of statements, duplicate statements are suppresssed.
|
|
595
528
|
*/
|
|
596
|
-
|
|
597
529
|
}, {
|
|
598
530
|
key: "connectedStatements",
|
|
599
531
|
value: function connectedStatements(subject, doc, excludePredicateURIs) {
|
|
@@ -603,7 +535,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
603
535
|
var doneArcs = {};
|
|
604
536
|
var result = [];
|
|
605
537
|
var self = this;
|
|
606
|
-
|
|
607
538
|
var follow = function follow(x) {
|
|
608
539
|
var queue = function queue(x) {
|
|
609
540
|
if (x.termType === 'BlankNode' && !done[x.value]) {
|
|
@@ -611,7 +542,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
611
542
|
todo.push(x);
|
|
612
543
|
}
|
|
613
544
|
};
|
|
614
|
-
|
|
615
545
|
var sts = self.statementsMatching(null, null, x, doc).concat(self.statementsMatching(x, null, null, doc));
|
|
616
546
|
sts = sts.filter(function (st) {
|
|
617
547
|
if (excludePredicateURIs[st.predicate.value]) return false;
|
|
@@ -626,46 +556,41 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
626
556
|
});
|
|
627
557
|
result = result.concat(sts);
|
|
628
558
|
};
|
|
629
|
-
|
|
630
559
|
while (todo.length) {
|
|
631
560
|
follow(todo.shift());
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
561
|
+
}
|
|
562
|
+
// console.log('' + result.length + ' statements about ' + subject)
|
|
635
563
|
return result;
|
|
636
564
|
}
|
|
565
|
+
|
|
637
566
|
/**
|
|
638
567
|
* Creates a new empty formula
|
|
639
568
|
*
|
|
640
569
|
* @param _features - Not applicable, but necessary for typing to pass
|
|
641
570
|
*/
|
|
642
|
-
|
|
643
571
|
}, {
|
|
644
572
|
key: "formula",
|
|
645
573
|
value: function formula(_features) {
|
|
646
574
|
return new Formula();
|
|
647
575
|
}
|
|
576
|
+
|
|
648
577
|
/**
|
|
649
578
|
* Transforms an NTriples string format into a Node.
|
|
650
579
|
* The blank node bit should not be used on program-external values; designed
|
|
651
580
|
* for internal work such as storing a blank node id in an HTML attribute.
|
|
652
581
|
* This will only parse the strings generated by the various toNT() methods.
|
|
653
582
|
*/
|
|
654
|
-
|
|
655
583
|
}, {
|
|
656
584
|
key: "fromNT",
|
|
657
585
|
value: function fromNT(str) {
|
|
658
586
|
var dt, k, lang;
|
|
659
|
-
|
|
660
587
|
switch (str[0]) {
|
|
661
588
|
case '<':
|
|
662
589
|
return this.sym(str.slice(1, -1));
|
|
663
|
-
|
|
664
590
|
case '"':
|
|
665
591
|
lang = void 0;
|
|
666
592
|
dt = void 0;
|
|
667
593
|
k = str.lastIndexOf('"');
|
|
668
|
-
|
|
669
594
|
if (k < str.length - 1) {
|
|
670
595
|
if (str[k + 1] === '@') {
|
|
671
596
|
lang = str.slice(k + 2);
|
|
@@ -675,41 +600,34 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
675
600
|
throw new Error("Can't convert string from NT: " + str);
|
|
676
601
|
}
|
|
677
602
|
}
|
|
678
|
-
|
|
679
603
|
str = str.slice(1, k);
|
|
680
604
|
str = str.replace(/\\"/g, '"');
|
|
681
605
|
str = str.replace(/\\n/g, '\n');
|
|
682
606
|
str = str.replace(/\\\\/g, '\\');
|
|
683
607
|
return this.rdfFactory.literal(str, lang || dt);
|
|
684
|
-
|
|
685
608
|
case '_':
|
|
686
609
|
return this.rdfFactory.blankNode(str.slice(2));
|
|
687
|
-
|
|
688
610
|
case '?':
|
|
689
611
|
return new _variable.default(str.slice(1));
|
|
690
612
|
}
|
|
691
|
-
|
|
692
613
|
throw new Error("Can't convert from NT: " + str);
|
|
693
614
|
}
|
|
694
|
-
/** Returns true if this formula holds the specified statement(s) */
|
|
695
615
|
|
|
616
|
+
/** Returns true if this formula holds the specified statement(s) */
|
|
696
617
|
}, {
|
|
697
618
|
key: "holds",
|
|
698
619
|
value: function holds(s, p, o, g) {
|
|
699
620
|
var i;
|
|
700
|
-
|
|
701
621
|
if (arguments.length === 1) {
|
|
702
622
|
if (!s) {
|
|
703
623
|
return true;
|
|
704
624
|
}
|
|
705
|
-
|
|
706
625
|
if (s instanceof Array) {
|
|
707
626
|
for (i = 0; i < s.length; i++) {
|
|
708
627
|
if (!this.holds(s[i])) {
|
|
709
628
|
return false;
|
|
710
629
|
}
|
|
711
630
|
}
|
|
712
|
-
|
|
713
631
|
return true;
|
|
714
632
|
} else if ((0, _terms.isStatement)(s)) {
|
|
715
633
|
return this.holds(s.subject, s.predicate, s.object, s.graph);
|
|
@@ -717,26 +635,25 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
717
635
|
return this.holds(s.statements);
|
|
718
636
|
}
|
|
719
637
|
}
|
|
720
|
-
|
|
721
638
|
var st = this.anyStatementMatching(s, p, o, g);
|
|
722
639
|
return st != null;
|
|
723
640
|
}
|
|
641
|
+
|
|
724
642
|
/**
|
|
725
643
|
* Returns true if this formula holds the specified {statement}
|
|
726
644
|
*/
|
|
727
|
-
|
|
728
645
|
}, {
|
|
729
646
|
key: "holdsStatement",
|
|
730
647
|
value: function holdsStatement(statement) {
|
|
731
648
|
return this.holds(statement.subject, statement.predicate, statement.object, statement.graph);
|
|
732
649
|
}
|
|
650
|
+
|
|
733
651
|
/**
|
|
734
652
|
* Used by the n3parser to generate list elements
|
|
735
653
|
* @param values - The values of the collection
|
|
736
654
|
* @param context - The store
|
|
737
655
|
* @return {BlankNode|Collection} - The term for the statement
|
|
738
656
|
*/
|
|
739
|
-
|
|
740
657
|
}, {
|
|
741
658
|
key: "list",
|
|
742
659
|
value: function list(values, context) {
|
|
@@ -748,37 +665,33 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
748
665
|
return collection;
|
|
749
666
|
} else {
|
|
750
667
|
var node = context.rdfFactory.blankNode();
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
context.addAll(_statements);
|
|
668
|
+
var statements = (0, _utils.arrayToStatements)(context.rdfFactory, node, values);
|
|
669
|
+
context.addAll(statements);
|
|
755
670
|
return node;
|
|
756
671
|
}
|
|
757
672
|
}
|
|
673
|
+
|
|
758
674
|
/**
|
|
759
675
|
* Transform a collection of NTriple URIs into their URI strings
|
|
760
676
|
* @param t - Some iterable collection of NTriple URI strings
|
|
761
677
|
* @return A collection of the URIs as strings
|
|
762
678
|
* todo: explain why it is important to go through NT
|
|
763
679
|
*/
|
|
764
|
-
|
|
765
680
|
}, {
|
|
766
681
|
key: "NTtoURI",
|
|
767
682
|
value: function NTtoURI(t) {
|
|
768
683
|
var k, v;
|
|
769
684
|
var uris = {};
|
|
770
|
-
|
|
771
685
|
for (k in t) {
|
|
772
686
|
if (!t.hasOwnProperty(k)) continue;
|
|
773
687
|
v = t[k];
|
|
774
|
-
|
|
775
688
|
if (k[0] === '<') {
|
|
776
689
|
uris[k.slice(1, -1)] = v;
|
|
777
690
|
}
|
|
778
691
|
}
|
|
779
|
-
|
|
780
692
|
return uris;
|
|
781
693
|
}
|
|
694
|
+
|
|
782
695
|
/**
|
|
783
696
|
* Serializes this formula
|
|
784
697
|
* @param base - The base string
|
|
@@ -786,18 +699,17 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
786
699
|
* @param provenance - The provenance URI
|
|
787
700
|
* @param options - options to pass to the serializer, as defined in serialize method
|
|
788
701
|
*/
|
|
789
|
-
|
|
790
702
|
}, {
|
|
791
703
|
key: "serialize",
|
|
792
704
|
value: function serialize(base, contentType, provenance, options) {
|
|
793
705
|
// delegate the graph serialization to the implementation in ./serialize
|
|
794
706
|
return (0, _serialize2.default)(provenance, this, base, contentType, undefined, options);
|
|
795
707
|
}
|
|
708
|
+
|
|
796
709
|
/**
|
|
797
710
|
* Creates a new formula with the substituting bindings applied
|
|
798
711
|
* @param bindings - The bindings to substitute
|
|
799
712
|
*/
|
|
800
|
-
|
|
801
713
|
}, {
|
|
802
714
|
key: "substitute",
|
|
803
715
|
value: function substitute(bindings) {
|
|
@@ -816,9 +728,9 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
816
728
|
if (name) {
|
|
817
729
|
throw new Error('This feature (kb.sym with 2 args) is removed. Do not assume prefix mappings.');
|
|
818
730
|
}
|
|
819
|
-
|
|
820
731
|
return this.rdfFactory.namedNode(uri);
|
|
821
732
|
}
|
|
733
|
+
|
|
822
734
|
/**
|
|
823
735
|
* Gets the node matching the specified pattern. Throws when no match could be made.
|
|
824
736
|
* @param s - The subject
|
|
@@ -826,18 +738,16 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
826
738
|
* @param o - The object
|
|
827
739
|
* @param g - The graph that contains the statement
|
|
828
740
|
*/
|
|
829
|
-
|
|
830
741
|
}, {
|
|
831
742
|
key: "the",
|
|
832
743
|
value: function the(s, p, o, g) {
|
|
833
744
|
var x = this.any(s, p, o, g);
|
|
834
|
-
|
|
835
745
|
if (x == null) {
|
|
836
746
|
_log.default.error('No value found for the() {' + s + ' ' + p + ' ' + o + '}.');
|
|
837
747
|
}
|
|
838
|
-
|
|
839
748
|
return x;
|
|
840
749
|
}
|
|
750
|
+
|
|
841
751
|
/**
|
|
842
752
|
* RDFS Inference
|
|
843
753
|
* These are hand-written implementations of a backward-chaining reasoner
|
|
@@ -846,16 +756,13 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
846
756
|
* @param predicate - The property to trace though
|
|
847
757
|
* @param inverse - Trace inverse direction
|
|
848
758
|
*/
|
|
849
|
-
|
|
850
759
|
}, {
|
|
851
760
|
key: "transitiveClosure",
|
|
852
761
|
value: function transitiveClosure(seeds, predicate, inverse) {
|
|
853
762
|
var elt, i, len, s, sups, t;
|
|
854
763
|
var agenda = {};
|
|
855
764
|
Object.assign(agenda, seeds); // make a copy
|
|
856
|
-
|
|
857
765
|
var done = {}; // classes we have looked up
|
|
858
|
-
|
|
859
766
|
while (true) {
|
|
860
767
|
t = function () {
|
|
861
768
|
for (var p in agenda) {
|
|
@@ -863,39 +770,32 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
863
770
|
return p;
|
|
864
771
|
}
|
|
865
772
|
}();
|
|
866
|
-
|
|
867
773
|
if (t == null) {
|
|
868
774
|
return done;
|
|
869
775
|
}
|
|
870
|
-
|
|
871
776
|
sups = inverse ? this.each(void 0, predicate, this.fromNT(t)) : this.each(this.fromNT(t), predicate);
|
|
872
|
-
|
|
873
777
|
for (i = 0, len = sups.length; i < len; i++) {
|
|
874
778
|
elt = sups[i];
|
|
875
779
|
s = elt.toNT();
|
|
876
|
-
|
|
877
780
|
if (s in done) {
|
|
878
781
|
continue;
|
|
879
782
|
}
|
|
880
|
-
|
|
881
783
|
if (s in agenda) {
|
|
882
784
|
continue;
|
|
883
785
|
}
|
|
884
|
-
|
|
885
786
|
agenda[s] = agenda[t];
|
|
886
787
|
}
|
|
887
|
-
|
|
888
788
|
done[t] = agenda[t];
|
|
889
789
|
delete agenda[t];
|
|
890
790
|
}
|
|
891
791
|
}
|
|
792
|
+
|
|
892
793
|
/**
|
|
893
794
|
* Finds the types in the list which have no *stored* supertypes
|
|
894
795
|
* We exclude the universal class, owl:Things and rdf:Resource, as it is
|
|
895
796
|
* information-free.
|
|
896
797
|
* @param types - The types
|
|
897
798
|
*/
|
|
898
|
-
|
|
899
799
|
}, {
|
|
900
800
|
key: "topTypeURIs",
|
|
901
801
|
value: function topTypeURIs(types) {
|
|
@@ -908,56 +808,50 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
908
808
|
var tops;
|
|
909
809
|
var v;
|
|
910
810
|
tops = [];
|
|
911
|
-
|
|
912
811
|
for (k in types) {
|
|
913
812
|
if (!types.hasOwnProperty(k)) continue;
|
|
914
813
|
v = types[k];
|
|
915
814
|
n = 0;
|
|
916
815
|
ref = this.each(this.rdfFactory.namedNode(k), this.rdfFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#subClassOf'));
|
|
917
|
-
|
|
918
816
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
919
817
|
j = ref[i];
|
|
920
|
-
|
|
921
818
|
if (j.uri !== 'http://www.w3.org/2000/01/rdf-schema#Resource') {
|
|
922
819
|
n++;
|
|
923
820
|
break;
|
|
924
821
|
}
|
|
925
822
|
}
|
|
926
|
-
|
|
927
823
|
if (!n) {
|
|
928
824
|
tops[k] = v;
|
|
929
825
|
}
|
|
930
826
|
}
|
|
931
|
-
|
|
932
827
|
if (tops['http://www.w3.org/2000/01/rdf-schema#Resource']) {
|
|
933
828
|
delete tops['http://www.w3.org/2000/01/rdf-schema#Resource'];
|
|
934
829
|
}
|
|
935
|
-
|
|
936
830
|
if (tops['http://www.w3.org/2002/07/owl#Thing']) {
|
|
937
831
|
delete tops['http://www.w3.org/2002/07/owl#Thing'];
|
|
938
832
|
}
|
|
939
|
-
|
|
940
833
|
return tops;
|
|
941
834
|
}
|
|
835
|
+
|
|
942
836
|
/**
|
|
943
837
|
* Serializes this formula to a string
|
|
944
838
|
*/
|
|
945
|
-
|
|
946
839
|
}, {
|
|
947
840
|
key: "toString",
|
|
948
841
|
value: function toString() {
|
|
949
842
|
return '{' + this.statements.join('\n') + '}';
|
|
950
843
|
}
|
|
844
|
+
|
|
951
845
|
/**
|
|
952
846
|
* Gets a new variable
|
|
953
847
|
* @param name - The variable's name
|
|
954
848
|
*/
|
|
955
|
-
|
|
956
849
|
}, {
|
|
957
850
|
key: "variable",
|
|
958
851
|
value: function variable(name) {
|
|
959
852
|
return new _variable.default(name);
|
|
960
853
|
}
|
|
854
|
+
|
|
961
855
|
/**
|
|
962
856
|
* Gets the number of statements in this formula that matches the specified pattern
|
|
963
857
|
* @param s - The subject
|
|
@@ -965,7 +859,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
965
859
|
* @param o - The object
|
|
966
860
|
* @param g - The graph that contains the statement
|
|
967
861
|
*/
|
|
968
|
-
|
|
969
862
|
}, {
|
|
970
863
|
key: "whether",
|
|
971
864
|
value: function whether(s, p, o, g) {
|
|
@@ -974,5 +867,4 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
974
867
|
}]);
|
|
975
868
|
return Formula;
|
|
976
869
|
}(_nodeInternal.default);
|
|
977
|
-
|
|
978
870
|
exports.default = Formula;
|