@faubulous/mentor-rdf 0.1.2

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 (44) hide show
  1. package/README.md +11 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +6 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/ontologies/index.d.ts +6 -0
  6. package/dist/ontologies/index.js +10 -0
  7. package/dist/ontologies/index.js.map +1 -0
  8. package/dist/ontologies/owl.d.ts +313 -0
  9. package/dist/ontologies/owl.js +318 -0
  10. package/dist/ontologies/owl.js.map +1 -0
  11. package/dist/ontologies/rdf.d.ts +93 -0
  12. package/dist/ontologies/rdf.js +98 -0
  13. package/dist/ontologies/rdf.js.map +1 -0
  14. package/dist/ontologies/rdfa.d.ts +47 -0
  15. package/dist/ontologies/rdfa.js +52 -0
  16. package/dist/ontologies/rdfa.js.map +1 -0
  17. package/dist/ontologies/rdfs.d.ts +67 -0
  18. package/dist/ontologies/rdfs.js +72 -0
  19. package/dist/ontologies/rdfs.js.map +1 -0
  20. package/dist/ontologies/shacl.d.ts +811 -0
  21. package/dist/ontologies/shacl.js +816 -0
  22. package/dist/ontologies/shacl.js.map +1 -0
  23. package/dist/ontologies/skos.d.ts +135 -0
  24. package/dist/ontologies/skos.js +140 -0
  25. package/dist/ontologies/skos.js.map +1 -0
  26. package/dist/rdf/class-repository.d.ts +44 -0
  27. package/dist/rdf/class-repository.js +116 -0
  28. package/dist/rdf/class-repository.js.map +1 -0
  29. package/dist/rdf/index.d.ts +5 -0
  30. package/dist/rdf/index.js +9 -0
  31. package/dist/rdf/index.js.map +1 -0
  32. package/dist/rdf/owl-reasoner.d.ts +8 -0
  33. package/dist/rdf/owl-reasoner.js +66 -0
  34. package/dist/rdf/owl-reasoner.js.map +1 -0
  35. package/dist/rdf/rdfs-reasoner.d.ts +9 -0
  36. package/dist/rdf/rdfs-reasoner.js +58 -0
  37. package/dist/rdf/rdfs-reasoner.js.map +1 -0
  38. package/dist/rdf/store-factory.d.ts +13 -0
  39. package/dist/rdf/store-factory.js +43 -0
  40. package/dist/rdf/store-factory.js.map +1 -0
  41. package/dist/rdf/vocabulary-generator.d.ts +65 -0
  42. package/dist/rdf/vocabulary-generator.js +193 -0
  43. package/dist/rdf/vocabulary-generator.js.map +1 -0
  44. package/package.json +57 -0
@@ -0,0 +1,9 @@
1
+ import * as n3 from "n3";
2
+ /**
3
+ * A simple RDFS reasoner that expands the graph with inferred triples.
4
+ */
5
+ export declare class RdfsReasoner {
6
+ expand(store: n3.Store, graph: n3.NamedNode): n3.Store;
7
+ protected getInferenceGraphNode(graph?: n3.NamedNode): n3.Quad_Graph;
8
+ protected inferClassAxioms(store: n3.Store, graph: n3.NamedNode, lists: Record<string, n3.Term[]>, quad: n3.Quad): void;
9
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RdfsReasoner = 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 simple RDFS reasoner that expands the graph with inferred triples.
9
+ */
10
+ class RdfsReasoner {
11
+ expand(store, graph) {
12
+ const lists = store.extractLists();
13
+ // Todo: Add the inferred triples to a new subgraph.
14
+ for (let q of store.match(null, null, null)) {
15
+ this.inferClassAxioms(store, graph, lists, q);
16
+ }
17
+ return store;
18
+ }
19
+ getInferenceGraphNode(graph) {
20
+ return graph ? new n3.NamedNode(graph.id + '#inference') : n3.DataFactory.defaultGraph();
21
+ }
22
+ inferClassAxioms(store, graph, lists, quad) {
23
+ let s = quad.subject;
24
+ let p = quad.predicate;
25
+ let o = quad.object.termType != "Literal" ? quad.object : undefined;
26
+ if (!o) {
27
+ return;
28
+ }
29
+ let g = this.getInferenceGraphNode(graph);
30
+ switch (p.id) {
31
+ case ontologies_1.rdf.type.id: {
32
+ if (o.equals(ontologies_1.owl.Class)) {
33
+ store.addQuad(s, ontologies_1.rdf.type, ontologies_1.rdfs.Class, g);
34
+ }
35
+ else if (o) {
36
+ store.addQuad(o, ontologies_1.rdf.type, ontologies_1.rdfs.Class, g);
37
+ }
38
+ break;
39
+ }
40
+ case ontologies_1.rdfs.subClassOf.id: {
41
+ store.addQuad(s, ontologies_1.rdf.type, ontologies_1.rdfs.Class, g);
42
+ if (o) {
43
+ store.addQuad(o, ontologies_1.rdf.type, ontologies_1.rdfs.Class, g);
44
+ }
45
+ break;
46
+ }
47
+ case ontologies_1.rdfs.range.id:
48
+ case ontologies_1.rdfs.domain.id: {
49
+ if (o) {
50
+ store.addQuad(o, ontologies_1.rdf.type, ontologies_1.rdfs.Class, g);
51
+ }
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ }
57
+ exports.RdfsReasoner = RdfsReasoner;
58
+ //# sourceMappingURL=rdfs-reasoner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rdfs-reasoner.js","sourceRoot":"","sources":["../../src/rdf/rdfs-reasoner.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,8CAA+C;AAE/C;;GAEG;AACH,MAAa,YAAY;IACd,MAAM,CAAC,KAAe,EAAE,KAAmB;QAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,EAA+B,CAAC;QAEhE,oDAAoD;QACpD,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;YACzC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAY,CAAC,CAAC;SAC5D;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAES,qBAAqB,CAAC,KAAoB;QAChD,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,YAAY,EAAE,CAA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EAAE,CAAC;YACnB,KAAK,iBAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACjB,IAAI,CAAC,EAAE;oBACH,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,gBAAG,CAAC,IAAI,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBAC7C;gBACD,MAAM;aACT;SACJ;IACL,CAAC;CACJ;AArDD,oCAqDC"}
@@ -0,0 +1,13 @@
1
+ import * as n3 from "n3";
2
+ /**
3
+ * Factory for creating RDF stores.
4
+ */
5
+ export declare class StoreFactory {
6
+ /**
7
+ * Create an RDF store from a file.
8
+ * @param path Path to a file containing RDF triples in Turtle or N3 format.
9
+ * @param inference Indicates if OWL inference should be performed on the store.
10
+ * @returns A promise that resolves to an RDF store.
11
+ */
12
+ static createFromFile(path: string, inference?: boolean): Promise<n3.Store>;
13
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StoreFactory = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const n3 = tslib_1.__importStar(require("n3"));
7
+ const owl_reasoner_1 = require("./owl-reasoner");
8
+ /**
9
+ * Factory for creating RDF stores.
10
+ */
11
+ class StoreFactory {
12
+ /**
13
+ * Create an RDF store from a file.
14
+ * @param path Path to a file containing RDF triples in Turtle or N3 format.
15
+ * @param inference Indicates if OWL inference should be performed on the store.
16
+ * @returns A promise that resolves to an RDF store.
17
+ */
18
+ static createFromFile(path, inference = true) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ return new Promise((resolve, reject) => {
21
+ const graph = new n3.NamedNode('file://' + process.cwd() + '/src/rdf/test/gist.ttl');
22
+ const store = new n3.Store();
23
+ const stream = fs.createReadStream(path);
24
+ new n3.Parser({}).parse(stream, (error, quad, done) => {
25
+ if (quad) {
26
+ store.add(new n3.Quad(quad.subject, quad.predicate, quad.object, graph));
27
+ }
28
+ else if (error) {
29
+ reject(error);
30
+ }
31
+ else if (done) {
32
+ if (inference) {
33
+ new owl_reasoner_1.OwlReasoner().expand(store, graph);
34
+ }
35
+ resolve(store);
36
+ }
37
+ });
38
+ });
39
+ });
40
+ }
41
+ }
42
+ exports.StoreFactory = StoreFactory;
43
+ //# sourceMappingURL=store-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-factory.js","sourceRoot":"","sources":["../../src/rdf/store-factory.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,+CAAyB;AACzB,iDAA6C;AAE7C;;GAEG;AACH,MAAa,YAAY;IACrB;;;;;OAKG;IACI,MAAM,CAAO,cAAc,CAAC,IAAY,EAAE,YAAqB,IAAI;;YACtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC,SAAS,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,wBAAwB,CAAC,CAAC;gBACrF,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;gBAC7B,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBAEzC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;oBACnD,IAAI,IAAI,EAAE;wBACN,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;qBAC5E;yBAAM,IAAI,KAAK,EAAE;wBACd,MAAM,CAAC,KAAK,CAAC,CAAC;qBACjB;yBAAM,IAAI,IAAI,EAAE;wBACb,IAAI,SAAS,EAAE;4BACX,IAAI,0BAAW,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;yBAC1C;wBAED,OAAO,CAAC,KAAK,CAAC,CAAC;qBAClB;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AA5BD,oCA4BC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * A generator for TypeScript vocabulary files.
3
+ */
4
+ export declare class VocabularyGenerator {
5
+ /**
6
+ * The supported RDF file extensions.
7
+ */
8
+ private readonly _supportedExtensions;
9
+ /**
10
+ * The predicates that are used to describe a subject.
11
+ */
12
+ private readonly _descriptionPredicates;
13
+ /**
14
+ * Get the subject of a quad as a named node.
15
+ * @param quad A quad.
16
+ * @returns A named node if the given quad describes a subject, otherwise undefined.
17
+ */
18
+ private _getNamedSubject;
19
+ /**
20
+ * Get the description of a subject from a quad, if any.
21
+ * @param quad A quad.
22
+ * @returns A literal if the given quad describes a subject, otherwise undefined.
23
+ */
24
+ private _getDescription;
25
+ /**
26
+ * Parse the label of a URI.
27
+ * @param subject A URI.
28
+ * @returns The label of the URI.
29
+ */
30
+ private _getLabel;
31
+ /**
32
+ * Write a vocabulary to a TypeScript file given a function for serializing the URI of a subject.
33
+ * @param stream A writable stream to the target file.
34
+ * @param prefix Namespace prefix of the vocabulary.
35
+ * @param subjects URIs of the subjects to serialize.
36
+ * @param value A function that serializes a URI.
37
+ */
38
+ private _writeVocabulary;
39
+ /**
40
+ * Serialize a vocabulary to a TypeScript file.
41
+ * @param stream A writable stream to the target file.
42
+ * @param prefix Namespace prefix of the vocabulary.
43
+ * @param subjects URIs of the subjects to serialize.
44
+ */
45
+ private _serialize;
46
+ /**
47
+ * Create an index.ts file for the given modules.
48
+ * @param path Directory of the index.ts file.
49
+ * @param modules Array of modules to export.
50
+ */
51
+ private _serializeIndex;
52
+ /**
53
+ * Parse a single RDF file and generate a TypeScript vocabulary file.
54
+ * @param path Path of the RDF file to parse.
55
+ * @returns Path of the generated TypeScript file.
56
+ */
57
+ parseFile(path: string): Promise<string>;
58
+ /**
59
+ * Generate TypeScript vocabulary files for all RDF files in the given directory.
60
+ * @param path Path of the directory to parse.
61
+ * @param createIndex Indicate if an index.ts file should be created.
62
+ * @returns An array of paths to the generated files.
63
+ */
64
+ parseDirectory(path: string, createIndex?: boolean): Promise<string[]>;
65
+ }
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VocabularyGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const n3 = tslib_1.__importStar(require("n3"));
7
+ const path_1 = require("path");
8
+ const ontologies_1 = require("../ontologies");
9
+ /**
10
+ * A generator for TypeScript vocabulary files.
11
+ */
12
+ class VocabularyGenerator {
13
+ constructor() {
14
+ /**
15
+ * The supported RDF file extensions.
16
+ */
17
+ this._supportedExtensions = new Set([
18
+ ".ttl",
19
+ ".trig",
20
+ ".n3",
21
+ ".nt",
22
+ ".nq"
23
+ ]);
24
+ /**
25
+ * The predicates that are used to describe a subject.
26
+ */
27
+ this._descriptionPredicates = new Set([
28
+ ontologies_1.RDFS.comment,
29
+ ontologies_1.SKOS.definition
30
+ ]);
31
+ }
32
+ /**
33
+ * Get the subject of a quad as a named node.
34
+ * @param quad A quad.
35
+ * @returns A named node if the given quad describes a subject, otherwise undefined.
36
+ */
37
+ _getNamedSubject(quad) {
38
+ if (quad.subject.termType == "NamedNode") {
39
+ return quad.subject.value;
40
+ }
41
+ else {
42
+ return undefined;
43
+ }
44
+ }
45
+ /**
46
+ * Get the description of a subject from a quad, if any.
47
+ * @param quad A quad.
48
+ * @returns A literal if the given quad describes a subject, otherwise undefined.
49
+ */
50
+ _getDescription(quad) {
51
+ if (this._descriptionPredicates.has(quad.predicate.value)) {
52
+ return quad.object;
53
+ }
54
+ }
55
+ /**
56
+ * Parse the label of a URI.
57
+ * @param subject A URI.
58
+ * @returns The label of the URI.
59
+ */
60
+ _getLabel(subject) {
61
+ let n = subject.lastIndexOf('#');
62
+ if (n > 0) {
63
+ return subject.slice(n + 1);
64
+ }
65
+ n = subject.lastIndexOf('/');
66
+ if (n > 0) {
67
+ return subject.slice(n + 1);
68
+ }
69
+ else {
70
+ return undefined;
71
+ }
72
+ }
73
+ /**
74
+ * Write a vocabulary to a TypeScript file given a function for serializing the URI of a subject.
75
+ * @param stream A writable stream to the target file.
76
+ * @param prefix Namespace prefix of the vocabulary.
77
+ * @param subjects URIs of the subjects to serialize.
78
+ * @param value A function that serializes a URI.
79
+ */
80
+ _writeVocabulary(stream, prefix, subjects, value) {
81
+ stream.write(`export const ${prefix} = {`);
82
+ for (var s of Object.keys(subjects).filter(s => s).sort()) {
83
+ var definitions = subjects[s];
84
+ var comment = definitions.find(l => l.language == "en");
85
+ if (!comment) {
86
+ comment = definitions.find(l => !l.language);
87
+ }
88
+ var label = this._getLabel(s);
89
+ if (!label) {
90
+ continue;
91
+ }
92
+ if (comment) {
93
+ stream.write(`\n\t/** ${comment.value} */`);
94
+ }
95
+ stream.write(`\n\t'${label}': ${value(s)},`);
96
+ }
97
+ stream.write(`\n}`);
98
+ }
99
+ /**
100
+ * Serialize a vocabulary to a TypeScript file.
101
+ * @param stream A writable stream to the target file.
102
+ * @param prefix Namespace prefix of the vocabulary.
103
+ * @param subjects URIs of the subjects to serialize.
104
+ */
105
+ _serialize(stream, prefix, subjects) {
106
+ stream.write(`import * as n3 from "n3";\n\n`);
107
+ this._writeVocabulary(stream, prefix.toUpperCase(), subjects, s => `'${s}'`);
108
+ stream.write(`\n\n`);
109
+ this._writeVocabulary(stream, prefix.toLowerCase(), subjects, s => `new n3.NamedNode('${s}')`);
110
+ stream.on("end", () => {
111
+ stream.end();
112
+ });
113
+ }
114
+ /**
115
+ * Create an index.ts file for the given modules.
116
+ * @param path Directory of the index.ts file.
117
+ * @param modules Array of modules to export.
118
+ */
119
+ _serializeIndex(path, modules) {
120
+ const stream = fs.createWriteStream((0, path_1.join)(path, "index.ts"));
121
+ for (let m of modules.map(x => (0, path_1.basename)(x))) {
122
+ stream.write(`export * from './${(0, path_1.parse)(m).name}';\n`);
123
+ }
124
+ stream.on("end", () => {
125
+ stream.end();
126
+ });
127
+ }
128
+ /**
129
+ * Parse a single RDF file and generate a TypeScript vocabulary file.
130
+ * @param path Path of the RDF file to parse.
131
+ * @returns Path of the generated TypeScript file.
132
+ */
133
+ parseFile(path) {
134
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
135
+ return new Promise((resolve, reject) => {
136
+ const directory = (0, path_1.dirname)(path);
137
+ const prefix = (0, path_1.parse)(path).name;
138
+ const result = (0, path_1.join)(directory, prefix + '.ts');
139
+ const inputStream = fs.createReadStream(path);
140
+ const outputStream = fs.createWriteStream(result);
141
+ const subjects = {};
142
+ new n3.Parser().parse(inputStream, (error, quad, done) => {
143
+ if (quad) {
144
+ const s = this._getNamedSubject(quad);
145
+ if (s) {
146
+ // If the key is not yet in the dictionary, add it.
147
+ if (!subjects[s]) {
148
+ subjects[s] = [];
149
+ }
150
+ const o = this._getDescription(quad);
151
+ // If there is a description, add it to the array.
152
+ if (o) {
153
+ subjects[s].push(o);
154
+ }
155
+ }
156
+ }
157
+ else if (error) {
158
+ reject(error);
159
+ }
160
+ else if (done) {
161
+ this._serialize(outputStream, prefix, subjects);
162
+ resolve(result);
163
+ }
164
+ });
165
+ });
166
+ });
167
+ }
168
+ /**
169
+ * Generate TypeScript vocabulary files for all RDF files in the given directory.
170
+ * @param path Path of the directory to parse.
171
+ * @param createIndex Indicate if an index.ts file should be created.
172
+ * @returns An array of paths to the generated files.
173
+ */
174
+ parseDirectory(path, createIndex = false) {
175
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
176
+ const result = [];
177
+ for (let file of fs.readdirSync(path)) {
178
+ const ext = (0, path_1.extname)(file);
179
+ if (this._supportedExtensions.has(ext)) {
180
+ const f = yield this.parseFile((0, path_1.join)(path, file));
181
+ result.push(f);
182
+ }
183
+ }
184
+ ;
185
+ if (createIndex) {
186
+ this._serializeIndex(path, result);
187
+ }
188
+ return result;
189
+ });
190
+ }
191
+ }
192
+ exports.VocabularyGenerator = VocabularyGenerator;
193
+ //# sourceMappingURL=vocabulary-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocabulary-generator.js","sourceRoot":"","sources":["../../src/rdf/vocabulary-generator.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,+CAAyB;AACzB,+BAA+D;AAE/D,8CAA2C;AAE3C;;GAEG;AACH,MAAa,mBAAmB;IAAhC;QACI;;WAEG;QACc,yBAAoB,GAAG,IAAI,GAAG,CAAS;YACpD,MAAM;YACN,OAAO;YACP,KAAK;YACL,KAAK;YACL,KAAK;SACR,CAAC,CAAC;QAEH;;WAEG;QACc,2BAAsB,GAAG,IAAI,GAAG,CAAS;YACtD,iBAAI,CAAC,OAAO;YACZ,iBAAI,CAAC,UAAU;SAClB,CAAC,CAAC;IA2LP,CAAC;IAzLG;;;;OAIG;IACK,gBAAgB,CAAC,IAAa;QAClC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,WAAW,EAAE;YACtC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;SAC7B;aAAM;YACH,OAAO,SAAS,CAAC;SACpB;IACL,CAAC;IAED;;;;OAIG;IACK,eAAe,CAAC,IAAa;QACjC,IAAI,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YACvD,OAAO,IAAI,CAAC,MAAoB,CAAC;SACpC;IACL,CAAC;IAED;;;;OAIG;IACK,SAAS,CAAC,OAAe;QAC7B,IAAI,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEjC,IAAI,CAAC,GAAG,CAAC,EAAE;YACP,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SAC/B;QAED,CAAC,GAAG,OAAO,CAAC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AI,IAAI,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;gBACnC,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;gBAE1B,IAAI,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;oBACpC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;oBAEjD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBAClB;aACJ;YAAA,CAAC;YAEF,IAAI,WAAW,EAAE;gBACb,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;aACtC;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;KAAA;CACJ;AA7MD,kDA6MC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@faubulous/mentor-rdf",
3
+ "keywords": [
4
+ "rdf",
5
+ "rdfs",
6
+ "owl",
7
+ "reasoning",
8
+ "inference",
9
+ "ontology",
10
+ "vocabulary"
11
+ ],
12
+ "description": "A library for working with RDF vocabularies with support for basic RDFS and OWL inference.",
13
+ "version": "0.1.2",
14
+ "private": false,
15
+ "author": {
16
+ "name": "Sebastian Faubel"
17
+ },
18
+ "main": "dist/index.js",
19
+ "types": "dist/index.d.ts",
20
+ "exports": [
21
+ "./dist/index.js"
22
+ ],
23
+ "files": [
24
+ "./dist"
25
+ ],
26
+ "engines": {
27
+ "node": ">=16"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/faubulous/mentor-rdf.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/faubulous/mentor-rdf/issues"
35
+ },
36
+ "license": "MIT",
37
+ "scripts": {
38
+ "prepublish": "tsc -p tsconfig.app.json",
39
+ "test": "npx jest"
40
+ },
41
+ "devDependencies": {
42
+ "@types/jest": "^29.5.4",
43
+ "@types/node": "^20.5.7",
44
+ "jest": "^29.6.4",
45
+ "jest-environment-node": "^29.6.4",
46
+ "ts-jest": "^29.1.1",
47
+ "ts-node": "^10.9.1",
48
+ "ts-node-dev": "^2.0.0",
49
+ "tslib": "^2.6.2",
50
+ "typescript": "^5.2.2"
51
+ },
52
+ "dependencies": {
53
+ "@types/n3": "^1.16.0",
54
+ "n3": "^1.17.1",
55
+ "rxjs": "^7.8.1"
56
+ }
57
+ }