@faubulous/mentor-rdf 2.1.9 → 2.2.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/dist/index.js +103 -52
- package/dist/index.js.map +2 -2
- package/dist/rdf/reasoners/reasoner.d.ts +2 -0
- package/dist/rdf/store.d.ts +54 -10
- package/package.json +2 -2
|
@@ -33,6 +33,8 @@ export interface Reasoner {
|
|
|
33
33
|
targetUriGenerator: GraphUriGenerator;
|
|
34
34
|
/**
|
|
35
35
|
* Apply inference on the source graph and store the inferred triples in the target graph.
|
|
36
|
+
* The source graph is iterated live while the inferred triples are added, so an
|
|
37
|
+
* implementation must only ever write to the target graph.
|
|
36
38
|
* @param store The store to be inferenced.
|
|
37
39
|
* @param sourceGraph The source graph where to find the triples to be inferenced.
|
|
38
40
|
* @param targetGraph The optional target graph where to store the inferred triples. If none is provided, the graph from getGraphUri will be used.
|
package/dist/rdf/store.d.ts
CHANGED
|
@@ -14,16 +14,19 @@ export declare class TripleNotFoundError extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
|
|
16
16
|
/**
|
|
17
|
-
* The adapted RDF.js triple store implementation.
|
|
17
|
+
* The adapted RDF.js triple store implementation. Replaced by {@link clear}.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* Reads go through `_store.readQuads`, a live iterator over the indexes. The dataset
|
|
20
|
+
* view's `match` is never used for reading: rdf-stores implements it by copying every
|
|
21
|
+
* matching quad into a new store first, which costs hundreds of megabytes and
|
|
22
|
+
* seconds for a graph the size of a workspace vocabulary.
|
|
20
23
|
*/
|
|
21
|
-
private
|
|
24
|
+
private _store;
|
|
22
25
|
/**
|
|
23
|
-
* The RDF dataset
|
|
24
|
-
*
|
|
26
|
+
* The RDF dataset view of {@link _store}, used for the mutations and membership
|
|
27
|
+
* checks of the `DatasetCore` interface.
|
|
25
28
|
*/
|
|
26
|
-
private
|
|
29
|
+
private _ds;
|
|
27
30
|
/**
|
|
28
31
|
* The reasoner to be used for inference.
|
|
29
32
|
*/
|
|
@@ -89,8 +92,21 @@ export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
|
|
|
89
92
|
/**
|
|
90
93
|
* Get the URIs of the graphs in the triple store.
|
|
91
94
|
* @returns An array of graph URIs in no particular order.
|
|
95
|
+
* @note Every mutation of the store records the graph it touched, so the graphs are the
|
|
96
|
+
* recorded ones that still hold a triple. Matching all triples instead would copy the whole
|
|
97
|
+
* store, which takes seconds for a store holding a large workspace.
|
|
92
98
|
*/
|
|
93
99
|
getGraphs(): string[];
|
|
100
|
+
/**
|
|
101
|
+
* Indicates if a graph holds at least one triple, without reading more than one.
|
|
102
|
+
* @param graph The graph term, or its URI with an empty string for the default graph.
|
|
103
|
+
*/
|
|
104
|
+
private _hasTriples;
|
|
105
|
+
/**
|
|
106
|
+
* Resolves a graph URI to its term; an empty string denotes the default graph.
|
|
107
|
+
* @param graph The graph term or URI.
|
|
108
|
+
*/
|
|
109
|
+
private _getGraphTerm;
|
|
94
110
|
/**
|
|
95
111
|
* Load a set of triples into the store.
|
|
96
112
|
* @param quads An array of quads to be loaded into the store.
|
|
@@ -101,6 +117,12 @@ export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
|
|
|
101
117
|
*/
|
|
102
118
|
private _remapBlankNodes;
|
|
103
119
|
private _loadQuads;
|
|
120
|
+
/**
|
|
121
|
+
* Runs the reasoner over a graph. The reasoner is handed this store rather than the
|
|
122
|
+
* dataset view, so its reads are live iterators and its writes bump the graph versions.
|
|
123
|
+
* @param graphUri The URI of the source graph.
|
|
124
|
+
*/
|
|
125
|
+
private _expand;
|
|
104
126
|
/**
|
|
105
127
|
* Create an RDF store from Turtle, N3 or N-Triples data.
|
|
106
128
|
* @param input Input string in Turtle, N3 or N-Triples format.
|
|
@@ -111,6 +133,15 @@ export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
|
|
|
111
133
|
* @returns A promise that resolves to an RDF store.
|
|
112
134
|
*/
|
|
113
135
|
loadTurtle(input: string, graphUri: string, executeInference?: boolean, clearGraph?: boolean, onQuad?: (quad: rdfjs.Quad) => void): Store;
|
|
136
|
+
/**
|
|
137
|
+
* Reads the quads of a Turtle token stream. A valid document is read without a syntax
|
|
138
|
+
* tree, which is the fast path. A document the quad reader rejects is parsed with error
|
|
139
|
+
* recovery and read from its syntax tree, so that a partially valid document yields the
|
|
140
|
+
* quads it did before.
|
|
141
|
+
* @param tokens The tokens of the document.
|
|
142
|
+
* @returns The quads of the document.
|
|
143
|
+
*/
|
|
144
|
+
private _readTurtleQuads;
|
|
114
145
|
/**
|
|
115
146
|
* Create an RDF store from N-Quads data.
|
|
116
147
|
* @param input Input string in N-Quads format.
|
|
@@ -153,9 +184,17 @@ export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
|
|
|
153
184
|
executeInference(graphUri: rdfjs.Quad_Graph | string): void;
|
|
154
185
|
/**
|
|
155
186
|
* Delete named graphs from the store.
|
|
156
|
-
* @param graphUris URIs of the graphs to be deleted.
|
|
187
|
+
* @param graphUris URIs of the graphs to be deleted; an empty string denotes the default graph.
|
|
188
|
+
* @param includeInferred Whether to also delete the inference graph of each graph, as
|
|
189
|
+
* named by the reasoner's target URI generator. Ignored when the store has no reasoner.
|
|
190
|
+
*/
|
|
191
|
+
deleteGraphs(graphUris: string[], includeInferred?: boolean): void;
|
|
192
|
+
/**
|
|
193
|
+
* Removes every quad from the store and releases the memory of the underlying store,
|
|
194
|
+
* including its term dictionary, which never shrinks when quads are deleted. The
|
|
195
|
+
* version counters keep increasing so that cached views and validators notice the change.
|
|
157
196
|
*/
|
|
158
|
-
|
|
197
|
+
clear(): void;
|
|
159
198
|
/**
|
|
160
199
|
* Get the URIs of ordered list members in the store.
|
|
161
200
|
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
@@ -182,7 +221,9 @@ export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
|
|
|
182
221
|
/**
|
|
183
222
|
* Returns a lazy, read-only dataset view of the quads matching the given pattern.
|
|
184
223
|
* Implements the RDF/JS `DatasetCore.match` semantics: the result reflects the
|
|
185
|
-
* current contents of the store and does not copy any quads.
|
|
224
|
+
* current contents of the store and does not copy any quads. Because the view
|
|
225
|
+
* iterates the live indexes, do not add or delete quads while iterating it;
|
|
226
|
+
* take a snapshot with `Array.from(...)` first.
|
|
186
227
|
* @param subject The optional subject.
|
|
187
228
|
* @param predicate The optional predicate.
|
|
188
229
|
* @param object The optional object.
|
|
@@ -191,7 +232,8 @@ export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
|
|
|
191
232
|
*/
|
|
192
233
|
match(subject?: rdfjs.Term | null, predicate?: rdfjs.Term | null, object?: rdfjs.Term | null, graph?: rdfjs.Term | null): DatasetView;
|
|
193
234
|
/**
|
|
194
|
-
* Synchronously iterate the quads matching a single pattern.
|
|
235
|
+
* Synchronously iterate the quads matching a single pattern. The iterator is live:
|
|
236
|
+
* do not add or delete quads while iterating; take a snapshot with `Array.from(...)` first.
|
|
195
237
|
* @param subject The optional subject.
|
|
196
238
|
* @param predicate The optional predicate.
|
|
197
239
|
* @param object The optional object.
|
|
@@ -206,6 +248,8 @@ export declare class Store implements rdfjs.DatasetCore<rdfjs.Quad> {
|
|
|
206
248
|
asSource(): rdfjs.Source<rdfjs.Quad>;
|
|
207
249
|
/**
|
|
208
250
|
* Query the store for triples matching the given pattern supporting multiple graphs.
|
|
251
|
+
* The iterator is live: do not add or delete quads while iterating; take a snapshot
|
|
252
|
+
* with `Array.from(...)` first.
|
|
209
253
|
* @param graphUris Optional graph URI or array of graph URIs to query.
|
|
210
254
|
* @param subject A subject URI or null to match any subject.
|
|
211
255
|
* @param predicate A predicate URI or null to match any predicate.
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"ontology",
|
|
11
11
|
"vocabulary"
|
|
12
12
|
],
|
|
13
|
-
"version": "2.
|
|
13
|
+
"version": "2.2.0",
|
|
14
14
|
"private": false,
|
|
15
15
|
"author": {
|
|
16
16
|
"name": "Sebastian Faubel"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"parse-url": "^11.1.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@faubulous/mentor-rdf-parsers": "^2.
|
|
71
|
+
"@faubulous/mentor-rdf-parsers": "^2.2.0",
|
|
72
72
|
"memory-level": "^3.1.0",
|
|
73
73
|
"quadstore": "^15.4.1",
|
|
74
74
|
"rdf-stores": "^2.8.0",
|