@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris 0.7.0 → 0.8.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/components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld +2 -22
- package/components/components.jsonld +0 -0
- package/components/context.jsonld +0 -6
- package/lib/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.d.ts +1 -7
- package/lib/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.js +52 -45
- package/lib/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.js.map +1 -1
- package/lib/index.d.ts +0 -0
- package/lib/index.js +0 -0
- package/lib/index.js.map +0 -0
- package/package.json +6 -9
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
3
|
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris/^0.0.0/components/context.jsonld",
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^5.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld"
|
|
6
6
|
],
|
|
7
7
|
"@id": "npmd:@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris",
|
|
8
8
|
"components": [
|
|
@@ -15,11 +15,6 @@
|
|
|
15
15
|
],
|
|
16
16
|
"comment": "A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.",
|
|
17
17
|
"parameters": [
|
|
18
|
-
{
|
|
19
|
-
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify",
|
|
20
|
-
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
21
|
-
"comment": "Mediator for identifying query sources."
|
|
22
|
-
},
|
|
23
18
|
{
|
|
24
19
|
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects",
|
|
25
20
|
"range": "xsd:boolean",
|
|
@@ -163,11 +158,6 @@
|
|
|
163
158
|
}
|
|
164
159
|
],
|
|
165
160
|
"memberFields": [
|
|
166
|
-
{
|
|
167
|
-
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris__member_mediatorQuerySourceIdentify",
|
|
168
|
-
"memberFieldName": "mediatorQuerySourceIdentify",
|
|
169
|
-
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
170
|
-
},
|
|
171
161
|
{
|
|
172
162
|
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris__member_extractSubjects",
|
|
173
163
|
"memberFieldName": "extractSubjects"
|
|
@@ -209,12 +199,6 @@
|
|
|
209
199
|
{
|
|
210
200
|
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args__constructorArgument",
|
|
211
201
|
"fields": [
|
|
212
|
-
{
|
|
213
|
-
"keyRaw": "mediatorQuerySourceIdentify",
|
|
214
|
-
"value": {
|
|
215
|
-
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify"
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
202
|
{
|
|
219
203
|
"keyRaw": "extractSubjects",
|
|
220
204
|
"value": {
|
|
@@ -290,10 +274,6 @@
|
|
|
290
274
|
],
|
|
291
275
|
"parameters": [],
|
|
292
276
|
"memberFields": [
|
|
293
|
-
{
|
|
294
|
-
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs__member_mediatorQuerySourceIdentify",
|
|
295
|
-
"memberFieldName": "mediatorQuerySourceIdentify"
|
|
296
|
-
},
|
|
297
277
|
{
|
|
298
278
|
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs__member_extractSubjects",
|
|
299
279
|
"memberFieldName": "extractSubjects"
|
|
File without changes
|
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris",
|
|
9
9
|
"@prefix": true,
|
|
10
10
|
"@context": {
|
|
11
|
-
"args_mediatorQuerySourceIdentify": {
|
|
12
|
-
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify"
|
|
13
|
-
},
|
|
14
11
|
"args_extractSubjects": {
|
|
15
12
|
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects"
|
|
16
13
|
},
|
|
@@ -39,9 +36,6 @@
|
|
|
39
36
|
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_beforeActors",
|
|
40
37
|
"@container": "@list"
|
|
41
38
|
},
|
|
42
|
-
"mediatorQuerySourceIdentify": {
|
|
43
|
-
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify"
|
|
44
|
-
},
|
|
45
39
|
"extractSubjects": {
|
|
46
40
|
"@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects"
|
|
47
41
|
},
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { IActionOptimizeQueryOperation, IActorOptimizeQueryOperationOutput } from '@comunica/bus-optimize-query-operation';
|
|
2
2
|
import { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';
|
|
3
|
-
import type { MediatorQuerySourceIdentify } from '@comunica/bus-query-source-identify';
|
|
4
3
|
import type { IActorArgs, IActorTest, TestResult } from '@comunica/core';
|
|
5
|
-
import { Algebra } from '
|
|
4
|
+
import { Algebra } from '@comunica/utils-algebra';
|
|
6
5
|
/**
|
|
7
6
|
* A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.
|
|
8
7
|
*/
|
|
9
8
|
export declare class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends ActorOptimizeQueryOperation {
|
|
10
|
-
readonly mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;
|
|
11
9
|
private readonly extractSubjects;
|
|
12
10
|
private readonly extractPredicates;
|
|
13
11
|
private readonly extractObjects;
|
|
@@ -19,10 +17,6 @@ export declare class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris ex
|
|
|
19
17
|
extractIrisFromOperation(operation: Algebra.Operation): string[];
|
|
20
18
|
}
|
|
21
19
|
export interface IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs extends IActorArgs<IActionOptimizeQueryOperation, IActorTest, IActorOptimizeQueryOperationOutput> {
|
|
22
|
-
/**
|
|
23
|
-
* Mediator for identifying query sources.
|
|
24
|
-
*/
|
|
25
|
-
mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;
|
|
26
20
|
/**
|
|
27
21
|
* If IRIs should be extracted from subject positions.
|
|
28
22
|
* @default {true}
|
|
@@ -4,74 +4,81 @@ exports.ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris = void 0;
|
|
|
4
4
|
const bus_optimize_query_operation_1 = require("@comunica/bus-optimize-query-operation");
|
|
5
5
|
const context_entries_1 = require("@comunica/context-entries");
|
|
6
6
|
const core_1 = require("@comunica/core");
|
|
7
|
-
const
|
|
7
|
+
const utils_algebra_1 = require("@comunica/utils-algebra");
|
|
8
8
|
/**
|
|
9
9
|
* A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.
|
|
10
10
|
*/
|
|
11
11
|
class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends bus_optimize_query_operation_1.ActorOptimizeQueryOperation {
|
|
12
|
+
extractSubjects;
|
|
13
|
+
extractPredicates;
|
|
14
|
+
extractObjects;
|
|
15
|
+
extractGraphs;
|
|
16
|
+
extractVocabIris;
|
|
12
17
|
constructor(args) {
|
|
13
18
|
super(args);
|
|
19
|
+
this.extractSubjects = args.extractSubjects;
|
|
20
|
+
this.extractPredicates = args.extractPredicates;
|
|
21
|
+
this.extractObjects = args.extractObjects;
|
|
22
|
+
this.extractGraphs = args.extractGraphs;
|
|
23
|
+
this.extractVocabIris = args.extractVocabIris;
|
|
14
24
|
}
|
|
15
25
|
async test(_action) {
|
|
16
26
|
return (0, core_1.passTestVoid)();
|
|
17
27
|
}
|
|
18
28
|
async run(action) {
|
|
19
|
-
|
|
29
|
+
const sources = action.context.get(context_entries_1.KeysInitQuery.querySourcesUnidentified);
|
|
20
30
|
if (!sources || sources.length === 0) {
|
|
21
|
-
|
|
22
|
-
.map(
|
|
31
|
+
const links = [...new Set(this.extractIrisFromOperation(action.operation))]
|
|
32
|
+
.map((source) => {
|
|
23
33
|
// Remove fragment from URL
|
|
24
34
|
const hashPosition = source.indexOf('#');
|
|
25
35
|
if (hashPosition >= 0) {
|
|
26
36
|
source = source.slice(0, hashPosition);
|
|
27
37
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
value: source,
|
|
35
|
-
context: new core_1.ActionContext().set(context_entries_1.KeysQuerySourceIdentify.traverse, true),
|
|
36
|
-
},
|
|
37
|
-
context: action.context,
|
|
38
|
-
})).querySource;
|
|
39
|
-
}));
|
|
40
|
-
action.context = action.context.set(context_entries_1.KeysQueryOperation.querySources, sources);
|
|
38
|
+
// Track as discovered link
|
|
39
|
+
action.context.get(context_entries_1.KeysStatistics.discoveredLinks)
|
|
40
|
+
?.updateStatistic({ url: source, metadata: { seed: true } }, { url: 'root' });
|
|
41
|
+
return source;
|
|
42
|
+
});
|
|
43
|
+
action.context = action.context.set(context_entries_1.KeysInitQuery.querySourcesUnidentified, links);
|
|
41
44
|
}
|
|
42
45
|
return { ...action, context: action.context };
|
|
43
46
|
}
|
|
44
47
|
extractIrisFromOperation(operation) {
|
|
45
48
|
const iris = [];
|
|
46
|
-
|
|
47
|
-
[
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
utils_algebra_1.algebraUtils.visitOperation(operation, {
|
|
50
|
+
[utils_algebra_1.Algebra.Types.PATH]: {
|
|
51
|
+
preVisitor: () => ({ continue: false }),
|
|
52
|
+
visitor: (path) => {
|
|
53
|
+
if (this.extractSubjects && path.subject.termType === 'NamedNode') {
|
|
54
|
+
iris.push(path.subject.value);
|
|
55
|
+
}
|
|
56
|
+
// Predicates are ignored
|
|
57
|
+
if (this.extractObjects && path.object.termType === 'NamedNode') {
|
|
58
|
+
iris.push(path.object.value);
|
|
59
|
+
}
|
|
60
|
+
if (this.extractGraphs && path.graph.termType === 'NamedNode') {
|
|
61
|
+
iris.push(path.graph.value);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
59
64
|
},
|
|
60
|
-
[
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
[utils_algebra_1.Algebra.Types.PATTERN]: {
|
|
66
|
+
preVisitor: () => ({ continue: false }),
|
|
67
|
+
visitor: (pattern) => {
|
|
68
|
+
if (this.extractSubjects && pattern.subject.termType === 'NamedNode') {
|
|
69
|
+
iris.push(pattern.subject.value);
|
|
70
|
+
}
|
|
71
|
+
if (this.extractPredicates && pattern.predicate.termType === 'NamedNode') {
|
|
72
|
+
iris.push(pattern.predicate.value);
|
|
73
|
+
}
|
|
74
|
+
if (this.extractObjects && pattern.object.termType === 'NamedNode' &&
|
|
75
|
+
(this.extractVocabIris || pattern.predicate.value !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')) {
|
|
76
|
+
iris.push(pattern.object.value);
|
|
77
|
+
}
|
|
78
|
+
if (this.extractGraphs && pattern.graph.termType === 'NamedNode') {
|
|
79
|
+
iris.push(pattern.graph.value);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
75
82
|
},
|
|
76
83
|
});
|
|
77
84
|
return iris;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.ts"],"names":[],"mappings":";;;AAIA,yFAAqF;
|
|
1
|
+
{"version":3,"file":"ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.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OptimizeQueryOperation,\n IActorOptimizeQueryOperationOutput,\n} from '@comunica/bus-optimize-query-operation';\nimport { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';\nimport { KeysInitQuery, KeysStatistics } from '@comunica/context-entries';\nimport type { IActorArgs, IActorTest, TestResult } from '@comunica/core';\nimport { passTestVoid } from '@comunica/core';\nimport { Algebra, algebraUtils } from '@comunica/utils-algebra';\n\n/**\n * A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.\n */\nexport class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends ActorOptimizeQueryOperation {\n private readonly extractSubjects: boolean;\n private readonly extractPredicates: boolean;\n private readonly extractObjects: boolean;\n private readonly extractGraphs: boolean;\n private readonly extractVocabIris: boolean;\n\n public constructor(args: IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs) {\n super(args);\n this.extractSubjects = args.extractSubjects;\n this.extractPredicates = args.extractPredicates;\n this.extractObjects = args.extractObjects;\n this.extractGraphs = args.extractGraphs;\n this.extractVocabIris = args.extractVocabIris;\n }\n\n public async test(_action: IActionOptimizeQueryOperation): Promise<TestResult<IActorTest>> {\n return passTestVoid();\n }\n\n public async run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput> {\n const sources = action.context.get(KeysInitQuery.querySourcesUnidentified);\n if (!sources || sources.length === 0) {\n const links: string[] = [ ...new Set(this.extractIrisFromOperation(action.operation)) ]\n .map((source) => {\n // Remove fragment from URL\n const hashPosition = source.indexOf('#');\n if (hashPosition >= 0) {\n source = source.slice(0, hashPosition);\n }\n\n // Track as discovered link\n action.context.get(KeysStatistics.discoveredLinks)\n ?.updateStatistic({ url: source, metadata: { seed: true }}, { url: 'root' });\n\n return source;\n });\n action.context = action.context.set(KeysInitQuery.querySourcesUnidentified, links);\n }\n return { ...action, context: action.context };\n }\n\n public extractIrisFromOperation(operation: Algebra.Operation): string[] {\n const iris: string[] = [];\n algebraUtils.visitOperation(operation, {\n [Algebra.Types.PATH]: {\n preVisitor: () => ({ continue: false }),\n visitor: (path) => {\n if (this.extractSubjects && path.subject.termType === 'NamedNode') {\n iris.push(path.subject.value);\n }\n // Predicates are ignored\n if (this.extractObjects && path.object.termType === 'NamedNode') {\n iris.push(path.object.value);\n }\n if (this.extractGraphs && path.graph.termType === 'NamedNode') {\n iris.push(path.graph.value);\n }\n },\n },\n [Algebra.Types.PATTERN]: {\n preVisitor: () => ({ continue: false }),\n visitor: (pattern) => {\n if (this.extractSubjects && pattern.subject.termType === 'NamedNode') {\n iris.push(pattern.subject.value);\n }\n if (this.extractPredicates && pattern.predicate.termType === 'NamedNode') {\n iris.push(pattern.predicate.value);\n }\n if (this.extractObjects && pattern.object.termType === 'NamedNode' &&\n (this.extractVocabIris || pattern.predicate.value !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')) {\n iris.push(pattern.object.value);\n }\n if (this.extractGraphs && pattern.graph.termType === 'NamedNode') {\n iris.push(pattern.graph.value);\n }\n },\n },\n });\n return iris;\n }\n}\n\nexport interface IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs\n extends IActorArgs<IActionOptimizeQueryOperation, IActorTest, IActorOptimizeQueryOperationOutput> {\n /**\n * If IRIs should be extracted from subject positions.\n * @default {true}\n */\n extractSubjects: boolean;\n /**\n * If IRIs should be extracted from predicate positions.\n * @default {false}\n */\n extractPredicates: boolean;\n /**\n * If IRIs should be extracted from object positions.\n * @default {true}\n */\n extractObjects: boolean;\n /**\n * If IRIs should be extracted from graph positions.\n * @default {true}\n */\n extractGraphs: boolean;\n /**\n * If object IRIs should be extracted if the predicate is rdf:type.\n * @default {false}\n */\n extractVocabIris: boolean;\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
File without changes
|
package/lib/index.js
CHANGED
|
File without changes
|
package/lib/index.js.map
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "A set-seed-sources-quadpattern-iris optimize-query-operation actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,13 +41,10 @@
|
|
|
41
41
|
"build:components": "componentsjs-generator"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@comunica/bus-optimize-query-operation": "^
|
|
45
|
-
"@comunica/
|
|
46
|
-
"@comunica/
|
|
47
|
-
"@comunica/
|
|
48
|
-
"@comunica/statistic-link-discovery": "^4.2.0",
|
|
49
|
-
"@comunica/types": "^4.2.0",
|
|
50
|
-
"sparqlalgebrajs": "^4.3.8"
|
|
44
|
+
"@comunica/bus-optimize-query-operation": "^5.0.0",
|
|
45
|
+
"@comunica/context-entries": "^5.0.0",
|
|
46
|
+
"@comunica/core": "^5.0.0",
|
|
47
|
+
"@comunica/utils-algebra": "^4.0.2"
|
|
51
48
|
},
|
|
52
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "8ffee3e33348f45ce70b033426f3abae4ed4ce71"
|
|
53
50
|
}
|