@faubulous/mentor-rdf 0.2.49 → 0.2.50

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.
Files changed (154) hide show
  1. package/out/index.d.ts +0 -0
  2. package/out/index.js +1 -1
  3. package/out/ontologies/index.d.ts +0 -0
  4. package/out/ontologies/owl.d.ts +0 -0
  5. package/out/ontologies/rdf.d.ts +0 -0
  6. package/out/ontologies/rdfa.d.ts +0 -0
  7. package/out/ontologies/rdfs.d.ts +0 -0
  8. package/out/ontologies/sh.d.ts +0 -0
  9. package/out/ontologies/skos-xl.d.ts +0 -0
  10. package/out/ontologies/skos.d.ts +0 -0
  11. package/out/ontologies/src.d.ts +0 -0
  12. package/out/ontologies/xsd.d.ts +0 -0
  13. package/out/rdf/class-repository.d.ts +0 -0
  14. package/out/rdf/concept-repository.d.ts +0 -0
  15. package/out/rdf/index.d.ts +0 -0
  16. package/out/rdf/individual-repository.d.ts +0 -0
  17. package/out/rdf/parsers/rdf-syntax.d.ts +0 -0
  18. package/out/rdf/parsers/sparql-syntax-parser.d.ts +0 -0
  19. package/out/rdf/parsers/syntax-parser.d.ts +0 -0
  20. package/out/rdf/parsers/trig-syntax-parser.d.ts +0 -0
  21. package/out/rdf/parsers/turtle-syntax-parser.d.ts +0 -0
  22. package/out/rdf/property-repository.d.ts +0 -0
  23. package/out/rdf/reasoners/owl-reasoner.d.ts +0 -0
  24. package/out/rdf/reasoners/rdfs-reasoner.d.ts +0 -0
  25. package/out/rdf/reasoners/reasoner.d.ts +0 -0
  26. package/out/rdf/reasoners/shacl-reasoner.d.ts +0 -0
  27. package/out/rdf/reasoners/skos-reasoner.d.ts +0 -0
  28. package/out/rdf/resource-repository.d.ts +31 -15
  29. package/out/rdf/shape-repository.d.ts +0 -0
  30. package/out/rdf/store.d.ts +0 -0
  31. package/out/rdf/uri.d.ts +0 -0
  32. package/out/rdf/vocabulary-repository.d.ts +0 -0
  33. package/package.json +66 -66
  34. package/out/index.js.map +0 -1
  35. package/out/ontologies/index.js +0 -44
  36. package/out/ontologies/index.js.map +0 -1
  37. package/out/ontologies/owl.js +0 -322
  38. package/out/ontologies/owl.js.map +0 -1
  39. package/out/ontologies/rdf.js +0 -102
  40. package/out/ontologies/rdf.js.map +0 -1
  41. package/out/ontologies/rdfa.js +0 -56
  42. package/out/ontologies/rdfa.js.map +0 -1
  43. package/out/ontologies/rdfs.js +0 -76
  44. package/out/ontologies/rdfs.js.map +0 -1
  45. package/out/ontologies/sh.js +0 -822
  46. package/out/ontologies/sh.js.map +0 -1
  47. package/out/ontologies/skos-xl.js +0 -40
  48. package/out/ontologies/skos-xl.js.map +0 -1
  49. package/out/ontologies/skos.js +0 -144
  50. package/out/ontologies/skos.js.map +0 -1
  51. package/out/ontologies/src.js +0 -3016
  52. package/out/ontologies/src.js.map +0 -1
  53. package/out/ontologies/xsd.js +0 -108
  54. package/out/ontologies/xsd.js.map +0 -1
  55. package/out/rdf/class-repository.js +0 -324
  56. package/out/rdf/class-repository.js.map +0 -1
  57. package/out/rdf/concept-repository.js +0 -220
  58. package/out/rdf/concept-repository.js.map +0 -1
  59. package/out/rdf/index.js +0 -18
  60. package/out/rdf/index.js.map +0 -1
  61. package/out/rdf/individual-repository.js +0 -77
  62. package/out/rdf/individual-repository.js.map +0 -1
  63. package/out/rdf/parsers/rdf-syntax.js +0 -19
  64. package/out/rdf/parsers/rdf-syntax.js.map +0 -1
  65. package/out/rdf/parsers/sparql-syntax-parser.js +0 -61
  66. package/out/rdf/parsers/sparql-syntax-parser.js.map +0 -1
  67. package/out/rdf/parsers/syntax-parser.js +0 -3
  68. package/out/rdf/parsers/syntax-parser.js.map +0 -1
  69. package/out/rdf/parsers/trig-syntax-parser.js +0 -30
  70. package/out/rdf/parsers/trig-syntax-parser.js.map +0 -1
  71. package/out/rdf/parsers/turtle-syntax-parser.js +0 -30
  72. package/out/rdf/parsers/turtle-syntax-parser.js.map +0 -1
  73. package/out/rdf/property-repository.js +0 -257
  74. package/out/rdf/property-repository.js.map +0 -1
  75. package/out/rdf/reasoners/owl-reasoner.js +0 -218
  76. package/out/rdf/reasoners/owl-reasoner.js.map +0 -1
  77. package/out/rdf/reasoners/rdfs-reasoner.js +0 -144
  78. package/out/rdf/reasoners/rdfs-reasoner.js.map +0 -1
  79. package/out/rdf/reasoners/reasoner.js +0 -106
  80. package/out/rdf/reasoners/reasoner.js.map +0 -1
  81. package/out/rdf/reasoners/shacl-reasoner.js +0 -170
  82. package/out/rdf/reasoners/shacl-reasoner.js.map +0 -1
  83. package/out/rdf/reasoners/skos-reasoner.js +0 -109
  84. package/out/rdf/reasoners/skos-reasoner.js.map +0 -1
  85. package/out/rdf/resource-repository.js +0 -136
  86. package/out/rdf/resource-repository.js.map +0 -1
  87. package/out/rdf/shape-repository.js +0 -298
  88. package/out/rdf/shape-repository.js.map +0 -1
  89. package/out/rdf/store.js +0 -240
  90. package/out/rdf/store.js.map +0 -1
  91. package/out/rdf/tests/helpers.d.ts +0 -39
  92. package/out/rdf/tests/helpers.js +0 -85
  93. package/out/rdf/tests/helpers.js.map +0 -1
  94. package/out/rdf/tests/vocabularies/bfo.d.ts +0 -413
  95. package/out/rdf/tests/vocabularies/bfo.js +0 -418
  96. package/out/rdf/tests/vocabularies/bfo.js.map +0 -1
  97. package/out/rdf/tests/vocabularies/cidoc-crm.d.ts +0 -2101
  98. package/out/rdf/tests/vocabularies/cidoc-crm.js +0 -2106
  99. package/out/rdf/tests/vocabularies/cidoc-crm.js.map +0 -1
  100. package/out/rdf/tests/vocabularies/emmo.d.ts +0 -5525
  101. package/out/rdf/tests/vocabularies/emmo.js +0 -5530
  102. package/out/rdf/tests/vocabularies/emmo.js.map +0 -1
  103. package/out/rdf/tests/vocabularies/fibo-agents.d.ts +0 -17
  104. package/out/rdf/tests/vocabularies/fibo-agents.js +0 -22
  105. package/out/rdf/tests/vocabularies/fibo-agents.js.map +0 -1
  106. package/out/rdf/tests/vocabularies/fibo-organization.d.ts +0 -69
  107. package/out/rdf/tests/vocabularies/fibo-organization.js +0 -74
  108. package/out/rdf/tests/vocabularies/fibo-organization.js.map +0 -1
  109. package/out/rdf/tests/vocabularies/gist.d.ts +0 -1071
  110. package/out/rdf/tests/vocabularies/gist.js +0 -1076
  111. package/out/rdf/tests/vocabularies/gist.js.map +0 -1
  112. package/out/rdf/tests/vocabularies/index.d.ts +0 -17
  113. package/out/rdf/tests/vocabularies/index.js +0 -90
  114. package/out/rdf/tests/vocabularies/index.js.map +0 -1
  115. package/out/rdf/tests/vocabularies/lob.d.ts +0 -5669
  116. package/out/rdf/tests/vocabularies/lob.js +0 -5674
  117. package/out/rdf/tests/vocabularies/lob.js.map +0 -1
  118. package/out/rdf/tests/vocabularies/multi.d.ts +0 -29
  119. package/out/rdf/tests/vocabularies/multi.js +0 -34
  120. package/out/rdf/tests/vocabularies/multi.js.map +0 -1
  121. package/out/rdf/tests/vocabularies/org.d.ts +0 -193
  122. package/out/rdf/tests/vocabularies/org.js +0 -198
  123. package/out/rdf/tests/vocabularies/org.js.map +0 -1
  124. package/out/rdf/tests/vocabularies/owl.d.ts +0 -317
  125. package/out/rdf/tests/vocabularies/owl.js +0 -322
  126. package/out/rdf/tests/vocabularies/owl.js.map +0 -1
  127. package/out/rdf/tests/vocabularies/prov-o.d.ts +0 -391
  128. package/out/rdf/tests/vocabularies/prov-o.js +0 -396
  129. package/out/rdf/tests/vocabularies/prov-o.js.map +0 -1
  130. package/out/rdf/tests/vocabularies/schema-nq.d.ts +0 -12079
  131. package/out/rdf/tests/vocabularies/schema-nq.js +0 -12084
  132. package/out/rdf/tests/vocabularies/schema-nq.js.map +0 -1
  133. package/out/rdf/tests/vocabularies/schema-nt.d.ts +0 -12079
  134. package/out/rdf/tests/vocabularies/schema-nt.js +0 -12084
  135. package/out/rdf/tests/vocabularies/schema-nt.js.map +0 -1
  136. package/out/rdf/tests/vocabularies/schema.d.ts +0 -12079
  137. package/out/rdf/tests/vocabularies/schema.js +0 -12084
  138. package/out/rdf/tests/vocabularies/schema.js.map +0 -1
  139. package/out/rdf/tests/vocabularies/shapes.d.ts +0 -53
  140. package/out/rdf/tests/vocabularies/shapes.js +0 -58
  141. package/out/rdf/tests/vocabularies/shapes.js.map +0 -1
  142. package/out/rdf/tests/vocabularies/skos.d.ts +0 -139
  143. package/out/rdf/tests/vocabularies/skos.js +0 -144
  144. package/out/rdf/tests/vocabularies/skos.js.map +0 -1
  145. package/out/rdf/tests/vocabularies/unesco.d.ts +0 -10517
  146. package/out/rdf/tests/vocabularies/unesco.js +0 -10522
  147. package/out/rdf/tests/vocabularies/unesco.js.map +0 -1
  148. package/out/rdf/uri.js +0 -84
  149. package/out/rdf/uri.js.map +0 -1
  150. package/out/rdf/vocabulary-generator.d.ts +0 -86
  151. package/out/rdf/vocabulary-generator.js +0 -294
  152. package/out/rdf/vocabulary-generator.js.map +0 -1
  153. package/out/rdf/vocabulary-repository.js +0 -121
  154. package/out/rdf/vocabulary-repository.js.map +0 -1
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReasonerBase = void 0;
4
- const tslib_1 = require("tslib");
5
- const n3 = tslib_1.__importStar(require("n3"));
6
- const ontologies_1 = require("../../ontologies");
7
- /**
8
- * A base class for reasoners that expand graphs with inferred triples.
9
- */
10
- class ReasonerBase {
11
- constructor() {
12
- this.store = new n3.Store();
13
- this.errors = [];
14
- }
15
- getInferenceGraphUri(uri) {
16
- const u = new URL(typeof uri == "string" ? uri : uri.value);
17
- u.protocol = 'mentor:';
18
- // This reasoner is specifically designed to work with the Mentor platform.
19
- return u.toString();
20
- }
21
- isInferenceGraphUri(uri) {
22
- const u = new URL(typeof uri == "string" ? uri : uri.value);
23
- return u.protocol === 'mentor:';
24
- }
25
- getGraphNode(graph) {
26
- if (typeof graph === "string") {
27
- return new n3.NamedNode(graph);
28
- }
29
- else {
30
- return graph;
31
- }
32
- }
33
- isW3CNode(term) {
34
- return term.value.startsWith("http://www.w3.org");
35
- }
36
- /**
37
- * Get the URIs of ordered list members in the store.
38
- * @param graphUris Optional graph URI or array of graph URIs to query.
39
- * @param listUri URI of the list to get the items from.
40
- * @returns An array of URIs of the items in the list.
41
- */
42
- getListItems(listUri) {
43
- // To do: Fix #10
44
- const list = listUri.includes(':') ? new n3.NamedNode(listUri) : new n3.BlankNode(listUri);
45
- return this._getListItems(list);
46
- }
47
- _getListItems(subject) {
48
- var _a;
49
- if (!this.sourceGraph) {
50
- return [];
51
- }
52
- let first = Array.from(this.match(this.sourceGraph, subject, ontologies_1.rdf.first, null));
53
- if (!first.length) {
54
- return [];
55
- }
56
- const rest = Array.from(this.match(this.sourceGraph, subject, ontologies_1.rdf.rest, null));
57
- const firstItem = first[0].object;
58
- const restList = (_a = rest[0]) === null || _a === void 0 ? void 0 : _a.object;
59
- if (restList.value === ontologies_1.RDF.nil) {
60
- return [firstItem];
61
- }
62
- else {
63
- const restItems = this._getListItems(restList);
64
- return [firstItem, ...restItems];
65
- }
66
- }
67
- /**
68
- * Query the store for triples matching the given pattern supporting multiple graphs.
69
- * @param graphUris Optional graph URI or array of graph URIs to query.
70
- * @param subject A subject URI or null to match any subject.
71
- * @param predicate A predicate URI or null to match any predicate.
72
- * @param object An object URI or null to match any object.
73
- * @todo Refactor and merge with the same method in the Mentor RDF Store class.
74
- */
75
- *match(graph, subject, predicate, object) {
76
- if (graph !== undefined) {
77
- yield* this.store.match(subject, predicate, object, graph);
78
- }
79
- else {
80
- yield* this.store.match(subject, predicate, object);
81
- }
82
- }
83
- expand(store, sourceGraph, targetGraph) {
84
- if (!targetGraph) {
85
- targetGraph = this.getInferenceGraphUri(sourceGraph);
86
- }
87
- this.store = store;
88
- if (this.store.getGraphs(null, null, null).filter(g => g.id == targetGraph).length > 0) {
89
- // Ensure the target graph is empty so this function is idempotent and consistent.
90
- store.deleteGraph(targetGraph);
91
- }
92
- this.sourceGraph = this.getGraphNode(sourceGraph);
93
- this.targetGraph = this.getGraphNode(targetGraph);
94
- this.beforeInference();
95
- for (let quad of store.match(null, null, null, this.sourceGraph)) {
96
- let q = quad;
97
- this.applyInference(q);
98
- }
99
- this.afterInference();
100
- return store;
101
- }
102
- beforeInference() { }
103
- afterInference() { }
104
- }
105
- exports.ReasonerBase = ReasonerBase;
106
- //# sourceMappingURL=reasoner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reasoner.js","sourceRoot":"","sources":["../../../src/rdf/reasoners/reasoner.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,iDAA4C;AAwB5C;;GAEG;AACH,MAAsB,YAAY;IAAlC;QACc,UAAK,GAAa,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;QAM3B,WAAM,GAAyC,EAAE,CAAC;IAyHtE,CAAC;IAvHU,oBAAoB,CAAC,GAA2B;QACnD,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5D,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC;QAEvB,2EAA2E;QAC3E,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAEM,mBAAmB,CAAC,GAA2B;QAClD,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE5D,OAAO,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC;IACpC,CAAC;IAES,YAAY,CAAC,KAA6B;QAChD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,IAAI,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACJ,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IAES,SAAS,CAAC,IAAa;QAC7B,OAAO,IAAI,CAAC,KA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AC;YAC/D,IAAI,CAAC,GAAG,IAAe,CAAC;YAExB,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAA;QAC1B,CAAC;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,OAAO,KAAK,CAAC;IACjB,CAAC;IAES,eAAe,KAAK,CAAC;IAErB,cAAc,KAAK,CAAC;CASjC;AAhID,oCAgIC"}
@@ -1,170 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ShaclReasoner = void 0;
4
- const ontologies_1 = require("../../ontologies");
5
- const rdfs_reasoner_1 = require("./rdfs-reasoner");
6
- /**
7
- * A simple SKOS reasoner that expands the graph with inferred triples.
8
- */
9
- class ShaclReasoner extends rdfs_reasoner_1.RdfsReasoner {
10
- constructor() {
11
- super(...arguments);
12
- this.classes = new Set();
13
- }
14
- isClass(id) {
15
- return this.classes.has(id) || super.isClass(id);
16
- }
17
- applyInference(quad) {
18
- super.applyInference(quad);
19
- this.inferShapeAxioms(quad);
20
- }
21
- assertShape(subject, type) {
22
- this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Shape, this.targetGraph);
23
- if (type) {
24
- this.store.addQuad(subject, ontologies_1.rdf.type, type, this.targetGraph);
25
- }
26
- this.classes.add(subject.id);
27
- }
28
- assertValidator(subject) {
29
- this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Validator, this.targetGraph);
30
- this.classes.add(subject.id);
31
- }
32
- assertParameterizable(subject) {
33
- this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Parameterizable, this.targetGraph);
34
- this.classes.add(subject.id);
35
- }
36
- assertRule(subject) {
37
- this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.sh.Rule, this.targetGraph);
38
- this.classes.add(subject.id);
39
- }
40
- isShapeType(subject) {
41
- switch (subject.id) {
42
- case ontologies_1.sh.Shape.id:
43
- case ontologies_1.sh.NodeShape.id:
44
- case ontologies_1.sh.PropertyShape.id:
45
- case ontologies_1.sh.Parameter.id: {
46
- return true;
47
- }
48
- default: {
49
- return false;
50
- }
51
- }
52
- }
53
- isRuleType(subject) {
54
- switch (subject.id) {
55
- case ontologies_1.sh.Rule.id:
56
- case ontologies_1.sh.JSRule.id:
57
- case ontologies_1.sh.SPARQLRule.id:
58
- case ontologies_1.sh.TripleRule.id: {
59
- return true;
60
- }
61
- default: {
62
- return false;
63
- }
64
- }
65
- }
66
- isValidatorType(subject) {
67
- switch (subject.id) {
68
- case ontologies_1.sh.Validator.id:
69
- case ontologies_1.sh.JSValidator.id:
70
- case ontologies_1.sh.SPARQLAskValidator.id:
71
- case ontologies_1.sh.SPARQLSelectValidator.id: {
72
- return true;
73
- }
74
- default: {
75
- return false;
76
- }
77
- }
78
- }
79
- isParameterizableType(subject) {
80
- switch (subject.id) {
81
- case ontologies_1.sh.Parameter.id:
82
- case ontologies_1.sh.ConstraintComponent.id:
83
- case ontologies_1.sh.Function.id:
84
- case ontologies_1.sh.JSFunction.id:
85
- case ontologies_1.sh.SPARQLFunction.id:
86
- case ontologies_1.sh.TargetType.id:
87
- case ontologies_1.sh.JSTargetType.id:
88
- case ontologies_1.sh.SPARQLTargetType.id: {
89
- return true;
90
- }
91
- default: {
92
- return false;
93
- }
94
- }
95
- }
96
- inferShapeAxioms(quad) {
97
- let s = quad.subject;
98
- let p = quad.predicate;
99
- let o = quad.object.termType != "Literal" ? quad.object : undefined;
100
- if (!o) {
101
- return;
102
- }
103
- switch (p.id) {
104
- case ontologies_1.rdf.type.id: {
105
- if (o.equals(ontologies_1.sh.Shape) || o.equals(ontologies_1.sh.Parameterizable)) {
106
- // No need to infer the type, as it is already asserted.
107
- this.classes.add(s.id);
108
- }
109
- else if (this.isShapeType(o)) {
110
- this.assertShape(s, o);
111
- }
112
- else if (this.isParameterizableType(o)) {
113
- this.assertParameterizable(s);
114
- }
115
- else if (this.isValidatorType(o)) {
116
- this.assertValidator(s);
117
- }
118
- else if (this.isRuleType(o)) {
119
- this.assertRule(s);
120
- }
121
- return;
122
- }
123
- case ontologies_1.sh.targetClass.id: {
124
- this.assertShape(s, ontologies_1.sh.NodeShape);
125
- this.assertClass(o);
126
- return;
127
- }
128
- case ontologies_1.sh.class.id: {
129
- this.assertShape(s, ontologies_1.sh.PropertyShape);
130
- this.assertClass(o);
131
- return;
132
- }
133
- case ontologies_1.sh.path.id: {
134
- this.assertShape(s, ontologies_1.sh.PropertyShape);
135
- this.assertProperty(o);
136
- return;
137
- }
138
- case ontologies_1.sh.property.id: {
139
- this.assertShape(s, ontologies_1.sh.NodeShape);
140
- this.assertShape(o, ontologies_1.sh.PropertyShape);
141
- return;
142
- }
143
- case ontologies_1.sh.parameter.id: {
144
- this.assertShape(o, ontologies_1.sh.Parameter);
145
- this.assertParameterizable(s);
146
- return;
147
- }
148
- case ontologies_1.sh.labelTemplate.id: {
149
- this.assertParameterizable(s);
150
- return;
151
- }
152
- case ontologies_1.sh.validator.id: {
153
- this.assertValidator(o);
154
- return;
155
- }
156
- case ontologies_1.sh.rule.id: {
157
- this.assertRule(o);
158
- return;
159
- }
160
- case ontologies_1.sh.subject.id:
161
- case ontologies_1.sh.predicate.id:
162
- case ontologies_1.sh.object.id: {
163
- this.assertRule(s);
164
- return;
165
- }
166
- }
167
- }
168
- }
169
- exports.ShaclReasoner = ShaclReasoner;
170
- //# sourceMappingURL=shacl-reasoner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shacl-reasoner.js","sourceRoot":"","sources":["../../../src/rdf/reasoners/shacl-reasoner.ts"],"names":[],"mappings":";;;AACA,iDAA2C;AAC3C,mDAA+C;AAE/C;;GAEG;AACH,MAAa,aAAc,SAAQ,4BAAY;IAA/C;;QACc,YAAO,GAAgB,IAAI,GAAG,EAAE,CAAC;IA0K/C,CAAC;IAxKa,OAAO,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAA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AAQ,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClB,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,eAAE,CAAC,SAAS,CAAC,CAAC;gBAClC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,eAAE,CAAC,aAAa,CAAC,CAAC;gBACtC,OAAO;YACX,CAAC;YACD,KAAK,eAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnB,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,eAAE,CAAC,SAAS,CAAC,CAAC;gBAClC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;gBAC9B,OAAO;YACX,CAAC;YACD,KAAK,eAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;gBACvB,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;gBAC9B,OAAO;YACX,CAAC;YACD,KAAK,eAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;gBACxB,OAAO;YACX,CAAC;YACD,KAAK,eAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBACd,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACnB,OAAO;YACX,CAAC;YACD,KAAK,eAAE,CAAC,OAAO,CAAC,EAAE,CAAC;YACnB,KAAK,eAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YACrB,KAAK,eAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;gBAChB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACnB,OAAO;YACX,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AA3KD,sCA2KC"}
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SkosReasoner = void 0;
4
- const ontologies_1 = require("../../ontologies");
5
- const reasoner_1 = require("./reasoner");
6
- /**
7
- * A simple SKOS reasoner that expands the graph with inferred triples.
8
- */
9
- class SkosReasoner extends reasoner_1.ReasonerBase {
10
- constructor() {
11
- super(...arguments);
12
- this.concepts = new Set();
13
- this.conceptSchemes = new Set();
14
- this.collections = new Set();
15
- }
16
- applyInference(quad) {
17
- this.inferConceptAxioms(quad);
18
- this.inferCollectionAxioms(quad);
19
- }
20
- assertConcept(subject) {
21
- this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.skos.Concept, this.targetGraph);
22
- this.concepts.add(subject.id);
23
- }
24
- assertConceptScheme(subject) {
25
- this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.skos.ConceptScheme, this.targetGraph);
26
- this.conceptSchemes.add(subject.id);
27
- }
28
- isClass(id) {
29
- return this.concepts.has(id) ||
30
- this.conceptSchemes.has(id) ||
31
- this.collections.has(id);
32
- }
33
- inferConceptAxioms(quad) {
34
- let s = quad.subject;
35
- let p = quad.predicate;
36
- let o = quad.object.termType != "Literal" ? quad.object : undefined;
37
- if (!o) {
38
- return;
39
- }
40
- switch (p.id) {
41
- case ontologies_1.rdf.type.id: {
42
- if (o.equals(ontologies_1.skos.Concept)) {
43
- // No need to infer the type, as it is already asserted.
44
- this.concepts.add(s.id);
45
- }
46
- else if (o.equals(ontologies_1.skos.ConceptScheme)) {
47
- // No need to infer the type, as it is already asserted.
48
- this.conceptSchemes.add(s.id);
49
- }
50
- return;
51
- }
52
- case ontologies_1.skos.inScheme.id: {
53
- this.assertConcept(s);
54
- this.assertConceptScheme(o);
55
- return;
56
- }
57
- case ontologies_1.skos.topConceptOf.id: {
58
- this.assertConcept(s);
59
- this.assertConceptScheme(o);
60
- return;
61
- }
62
- case ontologies_1.skos.hasTopConcept.id: {
63
- this.assertConcept(o);
64
- this.assertConceptScheme(s);
65
- return;
66
- }
67
- }
68
- }
69
- assertCollection(subject) {
70
- this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.skos.Collection, this.targetGraph);
71
- this.collections.add(subject.id);
72
- }
73
- assertOrderedCollection(subject) {
74
- this.store.addQuad(subject, ontologies_1.rdf.type, ontologies_1.skos.OrderedCollection, this.targetGraph);
75
- // We do not make a distinction between collections and ordered collections here.
76
- this.collections.add(subject.id);
77
- }
78
- inferCollectionAxioms(quad) {
79
- let s = quad.subject;
80
- let p = quad.predicate;
81
- let o = quad.object.termType != "Literal" ? quad.object : undefined;
82
- if (!o) {
83
- return;
84
- }
85
- switch (p.id) {
86
- case ontologies_1.rdf.type.id: {
87
- if (o.equals(ontologies_1.skos.Collection)) {
88
- // No need to infer the type, as it is already asserted.
89
- this.collections.add(s.id);
90
- }
91
- else if (o.equals(ontologies_1.skos.OrderedCollection)) {
92
- // No need to infer the type, as it is already asserted.
93
- this.collections.add(s.id);
94
- }
95
- return;
96
- }
97
- case ontologies_1.skos.member.id: {
98
- this.assertCollection(s);
99
- return;
100
- }
101
- case ontologies_1.skos.memberList.id: {
102
- this.assertOrderedCollection(s);
103
- return;
104
- }
105
- }
106
- }
107
- }
108
- exports.SkosReasoner = SkosReasoner;
109
- //# sourceMappingURL=skos-reasoner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skos-reasoner.js","sourceRoot":"","sources":["../../../src/rdf/reasoners/skos-reasoner.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AAC7C,yCAA0C;AAE1C;;GAEG;AACH,MAAa,YAAa,SAAQ,uBAAY;IAA9C;;QACc,aAAQ,GAAgB,IAAI,GAAG,EAAE,CAAC;QAElC,mBAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;QAExC,gBAAW,GAAgB,IAAI,GAAG,EAAE,CAAC;IA0GnD,CAAC;IAxGG,cAAc,CAAC,IAAa;QACxB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAES,aAAa,CAAC,OAAkD;QACtE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE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3
- exports.ResourceRepository = void 0;
4
- const tslib_1 = require("tslib");
5
- const n3 = tslib_1.__importStar(require("n3"));
6
- const ontologies_1 = require("../ontologies");
7
- const uri_1 = require("./uri");
8
- /**
9
- * A repository for retrieving resources from graphs.
10
- */
11
- class ResourceRepository {
12
- constructor(store) {
13
- this.store = store;
14
- }
15
- /**
16
- * Inidiates if a node should not be included in the result of a definition query.
17
- * @param graphUris URIs of the graphs to search.
18
- * @param subject The focus node.
19
- * @param options Definition query options.
20
- * @param optionDefaults Custom default values for the query options.
21
- * @returns
22
- */
23
- skip(graphUris, subject, options, optionDefaults = { includeBlankNodes: false, includeReferenced: false }) {
24
- const opts = Object.assign(Object.assign({}, optionDefaults), options);
25
- if (!opts.includeBlankNodes && subject.termType != "NamedNode") {
26
- // We are only interested in named nodes.
27
- return true;
28
- }
29
- if (!opts.includeReferenced && !this.hasSubject(graphUris, subject)) {
30
- // Skip the node if it is not explicitly defined in the graph as a subject.
31
- return true;
32
- }
33
- if ((opts === null || opts === void 0 ? void 0 : opts.definedBy) !== undefined) {
34
- const isDefined = this.isDefinedBy(graphUris, subject, opts.definedBy);
35
- // Do not skip the node if it has a different namespace but is *explicitly* defined by the given URI.
36
- if (opts.definedBy === null && isDefined || opts.definedBy !== null && !isDefined) {
37
- return true;
38
- }
39
- }
40
- else if ((opts === null || opts === void 0 ? void 0 : opts.notDefinedBy) !== undefined) {
41
- for (const source of opts.notDefinedBy) {
42
- if (this.isDefinedBy(graphUris, subject, source)) {
43
- return true;
44
- }
45
- }
46
- }
47
- return false;
48
- }
49
- /**
50
- * Indicate if a given URI exists as the subject of a triple in the graph.
51
- * @param graphUris URIs of the graphs to search.
52
- * @param subjectUri URI of the subject to search for.
53
- * @returns true if the URI is a subject, false otherwise.
54
- */
55
- hasSubject(graphUris, subjectUri) {
56
- let s;
57
- if (typeof subjectUri === "string") {
58
- s = n3.DataFactory.namedNode(subjectUri);
59
- }
60
- else if (subjectUri.termType !== "Literal") {
61
- s = subjectUri;
62
- }
63
- if (s) {
64
- for (let _ of this.store.match(graphUris, s, null, null, false)) {
65
- return true;
66
- }
67
- }
68
- return false;
69
- }
70
- /**
71
- * Indicate if a node is explicitly defined by the given URI using the `rdfs:isDefinedBy` property, or implicitly by sharing the same namespace.
72
- * @param graphUris URIs of the graphs to search.
73
- * @param node A named node to check if it is defined by the given URI.
74
- * @param definedBy URI of the vocabulary that defines the resource (rdfs:isDefinedBy). Provide `null` to only return resources that have no `rdfs:isDefinedBy` property.
75
- * @returns `true` if the node is defined by the given URI, `false` otherwise.
76
- */
77
- isDefinedBy(graphUris, node, definedBy) {
78
- const s = node;
79
- if (definedBy === null) {
80
- // If there is no definedBy URI, we assume that the resource is not
81
- // explicitly defined by any ontology.
82
- for (let _ of this.store.match(graphUris, s, ontologies_1.rdfs.isDefinedBy, null)) {
83
- return true;
84
- }
85
- }
86
- else {
87
- // We assume that a resource is defined by an ontology if it starts with the namespace of the ontology.
88
- if (node.value.startsWith(definedBy)) {
89
- return true;
90
- }
91
- // If the ontology is something like <http://purl.obolibrary.org/obo/bfo.owl> or <http://www.w3.org/ns/prov#>
92
- // and the subject is <http://purl.obolibrary.org/obo/BFO_0000001> or <http://www.w3.org/ns/prov#Entity>
93
- // then we assume that it is defined by the ontology. The OBO case shows that we need to remove the file
94
- // name in oder to be able to compare the namespace URIs.
95
- const ontologyNamespace = uri_1.Uri.getNormalizedUri(uri_1.Uri.getNamespaceUri(definedBy));
96
- const subjectNamespace = uri_1.Uri.getNormalizedUri(uri_1.Uri.getNamespaceUri(node.value));
97
- if (subjectNamespace === ontologyNamespace) {
98
- return true;
99
- }
100
- const o = n3.DataFactory.namedNode(uri_1.Uri.getNormalizedUri(definedBy));
101
- // The explicit annotation of the definition source has precedence over heuristic checks.
102
- for (let q of this.store.match(graphUris, s, ontologies_1.rdfs.isDefinedBy, null)) {
103
- if (uri_1.Uri.getNormalizedUri(q.object.value) === o.value) {
104
- return true;
105
- }
106
- }
107
- // A blank node is defined in the namespace if it is the object of a triple that is defined by the URI.
108
- if (s.termType === "BlankNode") {
109
- for (let q of this.store.match(graphUris, null, null, s, false)) {
110
- return this.isDefinedBy(graphUris, q.subject, definedBy);
111
- }
112
- }
113
- }
114
- return false;
115
- }
116
- /**
117
- * Indicate if a resource has a given type in the graph.
118
- * @param graphUris URIs of the graphs to search.
119
- * @param subjectUri URI or blank node id of the subject to match.
120
- * @param typeUri URI of the type to match.
121
- * @param options Optional query parameters.
122
- * @returns `true` if the resource has the type, `false` otherwise.
123
- */
124
- hasType(graphUris, subjectUri, typeUri, options) {
125
- const o = n3.DataFactory.namedNode(typeUri);
126
- for (let _ of this.store.match(graphUris, n3.DataFactory.namedNode(subjectUri), ontologies_1.rdf.type, o, options === null || options === void 0 ? void 0 : options.includeInferred)) {
127
- return true;
128
- }
129
- for (let _ of this.store.match(graphUris, n3.DataFactory.blankNode(subjectUri), ontologies_1.rdf.type, o, options === null || options === void 0 ? void 0 : options.includeInferred)) {
130
- return true;
131
- }
132
- return false;
133
- }
134
- }
135
- exports.ResourceRepository = ResourceRepository;
136
- //# sourceMappingURL=resource-repository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resource-repository.js","sourceRoot":"","sources":["../../src/rdf/resource-repository.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AAGzB,8CAA0C;AAC1C,+BAA4B;AAgD5B;;GAEG;AACH,MAAa,kBAAkB;IAM3B,YAAY,KAAY;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED;;;;;;;OAOG;IACO,IAAI,CAAC,SAAwC,EAAE,OAAmC,EAAE,OAAgC,EAAE,iBAAyC,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE;QAC3N,MAAM,IAAI,mCAAQ,cAAc,GAAK,OAAO,CAAE,CAAC;QAE/C,IAAI,CAAC,IAAI,CAAC,iBAAiB,IAAI,OAAO,CAAC,QAAQ,IAAI,WAAW,EAAE,CAAC;YAC7D,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