@faubulous/mentor-rdf 0.1.9 → 0.1.11

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 (50) hide show
  1. package/out/rdf/class-repository.d.ts +14 -6
  2. package/out/rdf/class-repository.js +36 -20
  3. package/out/rdf/class-repository.js.map +1 -1
  4. package/out/rdf/index.d.ts +4 -4
  5. package/out/rdf/index.js +4 -4
  6. package/out/rdf/parsers/rdf-syntax.d.ts +14 -0
  7. package/out/rdf/parsers/rdf-syntax.js +19 -0
  8. package/out/rdf/parsers/rdf-syntax.js.map +1 -0
  9. package/out/rdf/parsers/tokenizer.d.ts +17 -0
  10. package/out/rdf/parsers/tokenizer.js +30 -0
  11. package/out/rdf/parsers/tokenizer.js.map +1 -0
  12. package/out/rdf/parsers/trig-syntax-parser.d.ts +13 -0
  13. package/out/rdf/parsers/trig-syntax-parser.js +29 -0
  14. package/out/rdf/parsers/trig-syntax-parser.js.map +1 -0
  15. package/out/rdf/property-repository.d.ts +26 -7
  16. package/out/rdf/property-repository.js +30 -9
  17. package/out/rdf/property-repository.js.map +1 -1
  18. package/out/rdf/reasoners/owl-reasoner.d.ts +27 -0
  19. package/out/rdf/reasoners/owl-reasoner.js +165 -0
  20. package/out/rdf/reasoners/owl-reasoner.js.map +1 -0
  21. package/out/rdf/reasoners/rdfs-reasoner.d.ts +12 -0
  22. package/out/rdf/reasoners/rdfs-reasoner.js +118 -0
  23. package/out/rdf/reasoners/rdfs-reasoner.js.map +1 -0
  24. package/out/rdf/reasoners/reasoner.d.ts +10 -0
  25. package/out/rdf/reasoners/reasoner.js +3 -0
  26. package/out/rdf/reasoners/reasoner.js.map +1 -0
  27. package/out/rdf/store-factory.d.ts +1 -7
  28. package/out/rdf/store-factory.js +0 -11
  29. package/out/rdf/store-factory.js.map +1 -1
  30. package/out/rdf/tests/helpers.d.ts +19 -0
  31. package/out/rdf/tests/helpers.js +36 -0
  32. package/out/rdf/tests/helpers.js.map +1 -0
  33. package/out/rdf/tests/ontologies/fibo-agents.d.ts +13 -0
  34. package/out/rdf/tests/ontologies/fibo-agents.js +18 -0
  35. package/out/rdf/tests/ontologies/fibo-agents.js.map +1 -0
  36. package/out/rdf/tests/ontologies/gist.d.ts +1067 -0
  37. package/out/rdf/tests/ontologies/gist.js +1072 -0
  38. package/out/rdf/tests/ontologies/gist.js.map +1 -0
  39. package/out/rdf/tests/ontologies/index.d.ts +7 -0
  40. package/out/rdf/tests/ontologies/index.js +11 -0
  41. package/out/rdf/tests/ontologies/index.js.map +1 -0
  42. package/out/rdf/tests/ontologies/owl.d.ts +313 -0
  43. package/out/rdf/tests/ontologies/owl.js +318 -0
  44. package/out/rdf/tests/ontologies/owl.js.map +1 -0
  45. package/out/rdf/tests/ontologies/schema.d.ts +12075 -0
  46. package/out/rdf/tests/ontologies/schema.js +12080 -0
  47. package/out/rdf/tests/ontologies/schema.js.map +1 -0
  48. package/out/rdf/vocabulary-generator.js +4 -2
  49. package/out/rdf/vocabulary-generator.js.map +1 -1
  50. package/package.json +2 -1
@@ -1,21 +1,28 @@
1
1
  import * as n3 from "n3";
2
2
  import { ResourceRepository } from "./resource-repository";
3
+ interface ClassRetrievalOptions {
4
+ /**
5
+ * Indicate if classes what are not defined in the ontology should be included when retrieving classes (default true).
6
+ */
7
+ includeReferencedClasses?: boolean;
8
+ }
3
9
  /**
4
10
  * A repository for retrieving classes from graphs.
5
11
  */
6
12
  export declare class ClassRepository extends ResourceRepository {
7
13
  constructor(store: n3.Store);
14
+ private _skip;
8
15
  /**
9
16
  * Get all classes in the repository.
10
17
  * @returns A list of all classes in the repository.
11
18
  */
12
- getClasses(): string[];
19
+ getClasses(options?: ClassRetrievalOptions): string[];
13
20
  /**
14
21
  * Get the super classes of a given class.
15
22
  * @param subject URI of a class.
16
23
  * @returns An array of super classes of the given class, an empty array if the class has no super classes.
17
24
  */
18
- getSuperClasses(subject: string): string[];
25
+ getSuperClasses(subject: string, options?: ClassRetrievalOptions): string[];
19
26
  /**
20
27
  * Recursively find the first path from a given class to a root class.
21
28
  * @param subject URI of a class.
@@ -29,24 +36,24 @@ export declare class ClassRepository extends ResourceRepository {
29
36
  * @param subject URI of a class.
30
37
  * @returns A string array containing the first path that is found from the given class to a root class.
31
38
  */
32
- getRootClassPath(subject: string): string[];
39
+ getRootClassPath(subject: string, options?: ClassRetrievalOptions): string[];
33
40
  /**
34
41
  * Indicate if there are sub classes of a given class.
35
42
  * @param subject URI of a class.
36
43
  * @returns true if the class has sub classes, false otherwise.
37
44
  */
38
- hasSubClasses(subject: string): boolean;
45
+ hasSubClasses(subject: string, options?: ClassRetrievalOptions): boolean;
39
46
  /**
40
47
  * Get the sub classes of a given class or all root classes.
41
48
  * @param subject URI of a class or undefined to get all root classes.
42
49
  * @returns An array of sub classes of the given class, an empty array if the class has no sub classes.
43
50
  */
44
- getSubClasses(subject?: string): string[];
51
+ getSubClasses(subject?: string, options?: ClassRetrievalOptions): string[];
45
52
  /**
46
53
  * Get all classes from the repository that have no super classes.
47
54
  * @returns An array of root classes in the repository.
48
55
  */
49
- getRootClasses(): string[];
56
+ getRootClasses(options?: ClassRetrievalOptions): string[];
50
57
  /**
51
58
  * Indicate if there is an equivalent class of a given class.
52
59
  * @param subject URI of a class.
@@ -54,3 +61,4 @@ export declare class ClassRepository extends ResourceRepository {
54
61
  */
55
62
  hasEquivalentClass(uri: string): boolean;
56
63
  }
64
+ export {};
@@ -10,15 +10,24 @@ const resource_repository_1 = require("./resource-repository");
10
10
  */
11
11
  class ClassRepository extends resource_repository_1.ResourceRepository {
12
12
  constructor(store) { super(store); }
13
+ _skip(node, options) {
14
+ if (node.termType != "NamedNode") {
15
+ return true;
16
+ }
17
+ if ((options === null || options === void 0 ? void 0 : options.includeReferencedClasses) === false && !this.hasSubject(node.value)) {
18
+ return true;
19
+ }
20
+ return false;
21
+ }
13
22
  /**
14
23
  * Get all classes in the repository.
15
24
  * @returns A list of all classes in the repository.
16
25
  */
17
- getClasses() {
26
+ getClasses(options) {
18
27
  const result = new Set();
19
28
  for (let q of this.store.match(null, ontologies_1.rdf.type, ontologies_1.rdfs.Class)) {
20
29
  const s = q.subject;
21
- if (s.termType != "NamedNode") {
30
+ if (this._skip(s, options)) {
22
31
  continue;
23
32
  }
24
33
  result.add(s.value);
@@ -30,17 +39,17 @@ class ClassRepository extends resource_repository_1.ResourceRepository {
30
39
  * @param subject URI of a class.
31
40
  * @returns An array of super classes of the given class, an empty array if the class has no super classes.
32
41
  */
33
- getSuperClasses(subject) {
34
- const result = [];
42
+ getSuperClasses(subject, options) {
43
+ const result = new Set();
35
44
  const s = n3.DataFactory.namedNode(subject);
36
45
  for (let q of this.store.match(s, ontologies_1.rdfs.subClassOf, null)) {
37
46
  const o = q.object;
38
- if (o.termType != "NamedNode") {
47
+ if (this._skip(o, options)) {
39
48
  continue;
40
49
  }
41
- result.push(o.value);
50
+ result.add(o.value);
42
51
  }
43
- return result;
52
+ return Array.from(result);
44
53
  }
45
54
  /**
46
55
  * Recursively find the first path from a given class to a root class.
@@ -49,10 +58,10 @@ class ClassRepository extends resource_repository_1.ResourceRepository {
49
58
  * @param backtrack Set of URIs that have already been visited.
50
59
  * @returns The first path that is found from the given class to a root class.
51
60
  */
52
- _getRootClassPath(subject, path, backtrack) {
53
- const superClasses = this.getSuperClasses(subject);
61
+ _getRootClassPath(subject, path, backtrack, options) {
62
+ const superClasses = this.getSuperClasses(subject, options);
54
63
  for (let o of superClasses.filter(o => !backtrack.has(o))) {
55
- return this._getRootClassPath(o, [...path, o], backtrack);
64
+ return this._getRootClassPath(o, [...path, o], backtrack, options);
56
65
  }
57
66
  return path;
58
67
  }
@@ -61,18 +70,23 @@ class ClassRepository extends resource_repository_1.ResourceRepository {
61
70
  * @param subject URI of a class.
62
71
  * @returns A string array containing the first path that is found from the given class to a root class.
63
72
  */
64
- getRootClassPath(subject) {
65
- return this._getRootClassPath(subject, [], new Set());
73
+ getRootClassPath(subject, options) {
74
+ return this._getRootClassPath(subject, [], new Set(), options);
66
75
  }
67
76
  /**
68
77
  * Indicate if there are sub classes of a given class.
69
78
  * @param subject URI of a class.
70
79
  * @returns true if the class has sub classes, false otherwise.
71
80
  */
72
- hasSubClasses(subject) {
81
+ hasSubClasses(subject, options) {
73
82
  const o = n3.DataFactory.namedNode(subject);
74
83
  for (let _q of this.store.match(null, ontologies_1.rdfs.subClassOf, o)) {
75
- return true;
84
+ if (this._skip(_q.subject, options)) {
85
+ continue;
86
+ }
87
+ else {
88
+ return true;
89
+ }
76
90
  }
77
91
  return false;
78
92
  }
@@ -81,13 +95,13 @@ class ClassRepository extends resource_repository_1.ResourceRepository {
81
95
  * @param subject URI of a class or undefined to get all root classes.
82
96
  * @returns An array of sub classes of the given class, an empty array if the class has no sub classes.
83
97
  */
84
- getSubClasses(subject) {
98
+ getSubClasses(subject, options) {
85
99
  if (subject) {
86
100
  const result = new Set();
87
101
  const o = n3.DataFactory.namedNode(subject);
88
102
  for (let q of this.store.match(null, ontologies_1.rdfs.subClassOf, o)) {
89
103
  const s = q.subject;
90
- if (s.termType != "NamedNode") {
104
+ if (this._skip(s, options)) {
91
105
  continue;
92
106
  }
93
107
  result.add(s.value);
@@ -95,27 +109,29 @@ class ClassRepository extends resource_repository_1.ResourceRepository {
95
109
  return Array.from(result);
96
110
  }
97
111
  else {
98
- return this.getRootClasses();
112
+ return this.getRootClasses(options);
99
113
  }
100
114
  }
101
115
  /**
102
116
  * Get all classes from the repository that have no super classes.
103
117
  * @returns An array of root classes in the repository.
104
118
  */
105
- getRootClasses() {
119
+ getRootClasses(options) {
106
120
  const classes = new Set();
107
121
  const subclasses = new Set();
122
+ // 1. Get all classes that are defined in the ontology.
108
123
  for (let q of this.store.match(null, ontologies_1.rdf.type, ontologies_1.rdfs.Class)) {
109
124
  const s = q.subject;
110
- if (s.termType != "NamedNode") {
125
+ if (this._skip(s, options)) {
111
126
  continue;
112
127
  }
113
128
  classes.add(s.value);
114
129
  }
130
+ // 2. Get all classes that have a sub class relationship.
115
131
  for (let q of this.store.match(null, ontologies_1.rdfs.subClassOf, null)) {
116
132
  const s = q.subject;
117
133
  const o = q.object;
118
- if (s.termType != "NamedNode" || o.termType != "NamedNode") {
134
+ if (this._skip(s, options) || this._skip(o, options)) {
119
135
  continue;
120
136
  }
121
137
  classes.add(s.value);
@@ -1 +1 @@
1
- {"version":3,"file":"class-repository.js","sourceRoot":"","sources":["../../src/rdf/class-repository.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,8CAA+C;AAC/C,+DAA2D;AAE3D;;GAEG;AACH,MAAa,eAAgB,SAAQ,wCAAkB;IACnD,YAAY,KAAe,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA,CAAC;IAE7C;;;OAGG;IACH,UAAU;QACN,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,gBAAG,CAAC,IAAI,EAAE,iBAAI,CAAC,KAAK,CAAC,EAAE;YACxD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YAEpB,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,EAAE;gBAC3B,SAAS;aACZ;YAED,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SACvB;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,OAAe;QAC3B,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAE5C,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAI,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE;YACtD,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;YAEnB,IAAI,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,KAAK,CAAC,CAAC;YAErB,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACI,kBAAkB,CAAC,GAAW;QACjC,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAExC,oFAAoF;QACpF,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAG,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE;YAC1D,OAAO,IAAI,CAAC;SACf;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AArLD,0CAqLC"}
@@ -1,9 +1,9 @@
1
1
  export * from "./class-repository";
2
2
  export * from "./individual-repository";
3
- export * from "./parsing/rdf-syntax";
4
- export * from "./parsing/tokenizer";
3
+ export * from "./parsers/rdf-syntax";
4
+ export * from "./parsers/tokenizer";
5
5
  export * from "./property-repository";
6
- export * from "./reasoning/owl-reasoner";
7
- export * from "./reasoning/rdfs-reasoner";
6
+ export * from "./reasoners/owl-reasoner";
7
+ export * from "./reasoners/rdfs-reasoner";
8
8
  export * from "./resource-repository";
9
9
  export * from "./store-factory";
package/out/rdf/index.js CHANGED
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./class-repository"), exports);
5
5
  tslib_1.__exportStar(require("./individual-repository"), exports);
6
- tslib_1.__exportStar(require("./parsing/rdf-syntax"), exports);
7
- tslib_1.__exportStar(require("./parsing/tokenizer"), exports);
6
+ tslib_1.__exportStar(require("./parsers/rdf-syntax"), exports);
7
+ tslib_1.__exportStar(require("./parsers/tokenizer"), exports);
8
8
  tslib_1.__exportStar(require("./property-repository"), exports);
9
- tslib_1.__exportStar(require("./reasoning/owl-reasoner"), exports);
10
- tslib_1.__exportStar(require("./reasoning/rdfs-reasoner"), exports);
9
+ tslib_1.__exportStar(require("./reasoners/owl-reasoner"), exports);
10
+ tslib_1.__exportStar(require("./reasoners/rdfs-reasoner"), exports);
11
11
  tslib_1.__exportStar(require("./resource-repository"), exports);
12
12
  tslib_1.__exportStar(require("./store-factory"), exports);
13
13
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Enumerates the RDF syntaxes supported by the Mentor RDF library.
3
+ */
4
+ export declare enum RdfSyntax {
5
+ N3 = "n3",
6
+ NTriples = "ntriples",
7
+ NQuads = "nquads",
8
+ Turtle = "turtle",
9
+ TriG = "trig",
10
+ TriX = "trix",
11
+ JsonLd = "jsonld",
12
+ RdfXml = "rdfxml",
13
+ Sparql = "sparql"
14
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RdfSyntax = void 0;
4
+ /**
5
+ * Enumerates the RDF syntaxes supported by the Mentor RDF library.
6
+ */
7
+ var RdfSyntax;
8
+ (function (RdfSyntax) {
9
+ RdfSyntax["N3"] = "n3";
10
+ RdfSyntax["NTriples"] = "ntriples";
11
+ RdfSyntax["NQuads"] = "nquads";
12
+ RdfSyntax["Turtle"] = "turtle";
13
+ RdfSyntax["TriG"] = "trig";
14
+ RdfSyntax["TriX"] = "trix";
15
+ RdfSyntax["JsonLd"] = "jsonld";
16
+ RdfSyntax["RdfXml"] = "rdfxml";
17
+ RdfSyntax["Sparql"] = "sparql";
18
+ })(RdfSyntax || (exports.RdfSyntax = RdfSyntax = {}));
19
+ //# sourceMappingURL=rdf-syntax.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rdf-syntax.js","sourceRoot":"","sources":["../../../src/rdf/parsers/rdf-syntax.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,SAUX;AAVD,WAAY,SAAS;IACjB,sBAAS,CAAA;IACT,kCAAqB,CAAA;IACrB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,0BAAa,CAAA;IACb,0BAAa,CAAA;IACb,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACrB,CAAC,EAVW,SAAS,yBAAT,SAAS,QAUpB"}
@@ -0,0 +1,17 @@
1
+ import { IRecognitionException } from "chevrotain";
2
+ import { IToken } from "millan";
3
+ import { RdfSyntax } from "./rdf-syntax";
4
+ /**
5
+ * Parse result of the RDF tokenizer.
6
+ */
7
+ export interface TokenizerResult {
8
+ tokens: IToken[];
9
+ syntaxErrors: IRecognitionException[];
10
+ semanticErrors: IRecognitionException[];
11
+ }
12
+ /**
13
+ * Parses RDF data into tokens.
14
+ */
15
+ export declare class Tokenizer {
16
+ static parseData(data: string, syntax: RdfSyntax): Promise<TokenizerResult>;
17
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tokenizer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const millan_1 = require("millan");
6
+ const rdf_syntax_1 = require("./rdf-syntax");
7
+ const trig_syntax_parser_1 = require("./trig-syntax-parser");
8
+ /**
9
+ * Parses RDF data into tokens.
10
+ */
11
+ class Tokenizer {
12
+ static parseData(data, syntax) {
13
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
+ if (syntax === rdf_syntax_1.RdfSyntax.Sparql) {
15
+ const parser = new millan_1.W3SpecSparqlParser();
16
+ const { errors, comments } = parser.parse(data);
17
+ const tokens = comments ? [...parser.input, ...comments] : parser.input;
18
+ return { tokens, syntaxErrors: errors, semanticErrors: [] };
19
+ }
20
+ else {
21
+ const parser = new trig_syntax_parser_1.TrigSyntaxParser();
22
+ const { errors, semanticErrors, comments } = parser.parse(data);
23
+ const tokens = [...parser.input, ...comments];
24
+ return { tokens, syntaxErrors: errors, semanticErrors };
25
+ }
26
+ });
27
+ }
28
+ }
29
+ exports.Tokenizer = Tokenizer;
30
+ //# sourceMappingURL=tokenizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["../../../src/rdf/parsers/tokenizer.ts"],"names":[],"mappings":";;;;AACA,mCAAoD;AACpD,6CAAyC;AACzC,6DAAwD;AAWxD;;GAEG;AACH,MAAa,SAAS;IAClB,MAAM,CAAO,SAAS,CAAC,IAAY,EAAE,MAAiB;;YAClD,IAAI,MAAM,KAAK,sBAAS,CAAC,MAAM,EAAE;gBAC7B,MAAM,MAAM,GAAG,IAAI,2BAAkB,EAAE,CAAC;gBAExC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAChD,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAExE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;aAC/D;iBAAM;gBACH,MAAM,MAAM,GAAG,IAAI,qCAAgB,EAAE,CAAC;gBAEtC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAChE,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC;gBAE9C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;aAC3D;QACL,CAAC;KAAA;CACJ;AAlBD,8BAkBC"}
@@ -0,0 +1,13 @@
1
+ import { IRecognitionException, IToken } from "chevrotain";
2
+ import { TrigParser } from "millan";
3
+ /**
4
+ * An extended version of the Millan Trig parser that also returns comments.
5
+ */
6
+ export declare class TrigSyntaxParser extends TrigParser {
7
+ parse: (document: string) => {
8
+ errors: IRecognitionException[];
9
+ semanticErrors: IRecognitionException[];
10
+ comments: IToken[];
11
+ cst: any;
12
+ };
13
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrigSyntaxParser = void 0;
4
+ const millan_1 = require("millan");
5
+ /**
6
+ * An extended version of the Millan Trig parser that also returns comments.
7
+ */
8
+ class TrigSyntaxParser extends millan_1.TrigParser {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.parse = (document) => {
12
+ const result = this.lexer.tokenize(document);
13
+ this.input = result.tokens;
14
+ const cst = this.turtleDoc(0, ['standard']);
15
+ const errors = [...this.errors];
16
+ const semanticErrors = [...this.semanticErrors];
17
+ const comments = result.groups.comments || [];
18
+ this.resetManagedState();
19
+ return {
20
+ errors,
21
+ semanticErrors,
22
+ comments,
23
+ cst,
24
+ };
25
+ };
26
+ }
27
+ }
28
+ exports.TrigSyntaxParser = TrigSyntaxParser;
29
+ //# sourceMappingURL=trig-syntax-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trig-syntax-parser.js","sourceRoot":"","sources":["../../../src/rdf/parsers/trig-syntax-parser.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AAEpC;;GAEG;AACH,MAAa,gBAAiB,SAAQ,mBAAU;IAAhD;;QACW,UAAK,GAAG,CAAC,QAAgB,EAK9B,EAAE;YACA,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAE7C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;YAE3B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;YAC5C,MAAM,MAAM,GAA4B,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YACzD,MAAM,cAAc,GAA4B,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;YACzE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;YAE9C,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAEzB,OAAO;gBACH,MAAM;gBACN,cAAc;gBACd,QAAQ;gBACR,GAAG;aACN,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CAAA;AAzBD,4CAyBC"}
@@ -1,5 +1,15 @@
1
1
  import * as n3 from "n3";
2
2
  import { ResourceRepository } from "./resource-repository";
3
+ interface PropertyRetrievalOptions {
4
+ /**
5
+ * A predicate that must be present on the returned properties.
6
+ */
7
+ predicate?: string;
8
+ /**
9
+ * An object value that must be present on the returned properties.
10
+ */
11
+ object?: string;
12
+ }
3
13
  /**
4
14
  * A repository for retrieving properties from graphs.
5
15
  */
@@ -13,51 +23,59 @@ export declare class PropertyRepository extends ResourceRepository {
13
23
  */
14
24
  rangePredicate: n3.NamedNode<"http://www.w3.org/2000/01/rdf-schema#range">;
15
25
  constructor(store: n3.Store);
26
+ private _skip;
16
27
  /**
17
28
  * Get all properties in the repository.
29
+ * @param options Optional options for retrieving properties.
18
30
  * @returns A list of all properties in the repository.
19
31
  */
20
- getProperties(): string[];
32
+ getProperties(options?: PropertyRetrievalOptions): string[];
21
33
  /**
22
34
  * Get the super properties of a given property.
23
35
  * @param subject URI of a property.
36
+ * @param options Optional options for retrieving properties.
24
37
  * @returns An array of super properties of the given property, an empty array if the property has no super properties.
25
38
  */
26
- getSuperProperties(subject: string): string[];
39
+ getSuperProperties(subject: string, options?: PropertyRetrievalOptions): string[];
27
40
  /**
28
41
  * Recursively find the first path from a given property to a root property.
29
42
  * @param subject URI of a property.
30
43
  * @param path The current property path.
31
44
  * @param backtrack Set of URIs that have already been visited.
45
+ * @param options Optional options for retrieving properties.
32
46
  * @returns The first path that is found from the given property to a root class.
33
47
  */
34
48
  private _getRootPropertyPath;
35
49
  /**
36
50
  * Get the first discovered path from a given property to a root property.
37
51
  * @param subject URI of a property.
52
+ * @param options Optional options for retrieving properties.
38
53
  * @returns A string array containing the first path that is found from the given property to a root property.
39
54
  */
40
- getRootPropertiesPath(subject: string): string[];
55
+ getRootPropertiesPath(subject: string, options?: PropertyRetrievalOptions): string[];
41
56
  /**
42
57
  * Indicate if there are sub properties of a given property.
43
58
  * @param subject URI of a property.
59
+ * @param options Optional options for retrieving properties.
44
60
  * @returns true if the property has sub properties, false otherwise.
45
61
  */
46
- hasSubProperties(subject: string): boolean;
62
+ hasSubProperties(subject: string, options?: PropertyRetrievalOptions): boolean;
47
63
  /**
48
64
  * Get the sub properties of a given property or all root properties.
49
65
  * @param subject URI of a property or undefined to get all root properties.
66
+ * @param options Optional options for retrieving properties.
50
67
  * @returns An array of sub properties of the given property, an empty array if the property has no sub properties.
51
68
  */
52
- getSubProperties(subject?: string): string[];
69
+ getSubProperties(subject?: string, options?: PropertyRetrievalOptions): string[];
53
70
  /**
54
71
  * Get all properties from the repository that have no super properties.
72
+ * @param options Optional options for retrieving properties.
55
73
  * @returns An array of root properties in the repository.
56
74
  */
57
- getRootProperties(): string[];
75
+ getRootProperties(options?: PropertyRetrievalOptions): string[];
58
76
  /**
59
77
  * Indicate if there is an equivalent property of a given property.
60
- * @param subject URI of a property.
78
+ * @param uri URI of a property.
61
79
  * @returns true if the property has an equivalent property, false otherwise.
62
80
  */
63
81
  hasEquivalentProperty(uri: string): boolean;
@@ -74,3 +92,4 @@ export declare class PropertyRepository extends ResourceRepository {
74
92
  */
75
93
  getRange(uri: string): string;
76
94
  }
95
+ export {};
@@ -20,15 +20,30 @@ class PropertyRepository extends resource_repository_1.ResourceRepository {
20
20
  */
21
21
  this.rangePredicate = ontologies_1.rdfs.range;
22
22
  }
23
+ _skip(node, options) {
24
+ if (node.termType != "NamedNode") {
25
+ return true;
26
+ }
27
+ if ((options === null || options === void 0 ? void 0 : options.predicate) || (options === null || options === void 0 ? void 0 : options.object)) {
28
+ const s = n3.DataFactory.namedNode(node.value);
29
+ const p = options.predicate ? n3.DataFactory.namedNode(options.predicate) : undefined;
30
+ const o = options.object ? n3.DataFactory.namedNode(options.object) : undefined;
31
+ if (this.store.match(s, p, o).size == 0) {
32
+ return true;
33
+ }
34
+ }
35
+ return false;
36
+ }
23
37
  /**
24
38
  * Get all properties in the repository.
39
+ * @param options Optional options for retrieving properties.
25
40
  * @returns A list of all properties in the repository.
26
41
  */
27
- getProperties() {
42
+ getProperties(options) {
28
43
  const result = new Set();
29
44
  for (let q of this.store.match(null, ontologies_1.rdf.type, ontologies_1.rdf.Property)) {
30
45
  const s = q.subject;
31
- if (s.termType != "NamedNode") {
46
+ if (this._skip(s, options)) {
32
47
  continue;
33
48
  }
34
49
  result.add(s.value);
@@ -38,9 +53,10 @@ class PropertyRepository extends resource_repository_1.ResourceRepository {
38
53
  /**
39
54
  * Get the super properties of a given property.
40
55
  * @param subject URI of a property.
56
+ * @param options Optional options for retrieving properties.
41
57
  * @returns An array of super properties of the given property, an empty array if the property has no super properties.
42
58
  */
43
- getSuperProperties(subject) {
59
+ getSuperProperties(subject, options) {
44
60
  const result = [];
45
61
  const s = n3.DataFactory.namedNode(subject);
46
62
  for (let q of this.store.match(s, ontologies_1.rdfs.subPropertyOf, null)) {
@@ -57,9 +73,10 @@ class PropertyRepository extends resource_repository_1.ResourceRepository {
57
73
  * @param subject URI of a property.
58
74
  * @param path The current property path.
59
75
  * @param backtrack Set of URIs that have already been visited.
76
+ * @param options Optional options for retrieving properties.
60
77
  * @returns The first path that is found from the given property to a root class.
61
78
  */
62
- _getRootPropertyPath(subject, path, backtrack) {
79
+ _getRootPropertyPath(subject, path, backtrack, options) {
63
80
  const superClasses = this.getSuperProperties(subject);
64
81
  for (let o of superClasses.filter(o => !backtrack.has(o))) {
65
82
  return this._getRootPropertyPath(o, [...path, o], backtrack);
@@ -69,17 +86,19 @@ class PropertyRepository extends resource_repository_1.ResourceRepository {
69
86
  /**
70
87
  * Get the first discovered path from a given property to a root property.
71
88
  * @param subject URI of a property.
89
+ * @param options Optional options for retrieving properties.
72
90
  * @returns A string array containing the first path that is found from the given property to a root property.
73
91
  */
74
- getRootPropertiesPath(subject) {
92
+ getRootPropertiesPath(subject, options) {
75
93
  return this._getRootPropertyPath(subject, [], new Set());
76
94
  }
77
95
  /**
78
96
  * Indicate if there are sub properties of a given property.
79
97
  * @param subject URI of a property.
98
+ * @param options Optional options for retrieving properties.
80
99
  * @returns true if the property has sub properties, false otherwise.
81
100
  */
82
- hasSubProperties(subject) {
101
+ hasSubProperties(subject, options) {
83
102
  const o = n3.DataFactory.namedNode(subject);
84
103
  for (let _q of this.store.match(null, ontologies_1.rdfs.subPropertyOf, o)) {
85
104
  return true;
@@ -89,9 +108,10 @@ class PropertyRepository extends resource_repository_1.ResourceRepository {
89
108
  /**
90
109
  * Get the sub properties of a given property or all root properties.
91
110
  * @param subject URI of a property or undefined to get all root properties.
111
+ * @param options Optional options for retrieving properties.
92
112
  * @returns An array of sub properties of the given property, an empty array if the property has no sub properties.
93
113
  */
94
- getSubProperties(subject) {
114
+ getSubProperties(subject, options) {
95
115
  if (subject) {
96
116
  const result = new Set();
97
117
  const o = n3.DataFactory.namedNode(subject);
@@ -110,9 +130,10 @@ class PropertyRepository extends resource_repository_1.ResourceRepository {
110
130
  }
111
131
  /**
112
132
  * Get all properties from the repository that have no super properties.
133
+ * @param options Optional options for retrieving properties.
113
134
  * @returns An array of root properties in the repository.
114
135
  */
115
- getRootProperties() {
136
+ getRootProperties(options) {
116
137
  const properties = new Set();
117
138
  const subproperties = new Set();
118
139
  for (let q of this.store.match(null, ontologies_1.rdf.type, ontologies_1.rdf.Property)) {
@@ -136,7 +157,7 @@ class PropertyRepository extends resource_repository_1.ResourceRepository {
136
157
  }
137
158
  /**
138
159
  * Indicate if there is an equivalent property of a given property.
139
- * @param subject URI of a property.
160
+ * @param uri URI of a property.
140
161
  * @returns true if the property has an equivalent property, false otherwise.
141
162
  */
142
163
  hasEquivalentProperty(uri) {
@@ -1 +1 @@
1
- {"version":3,"file":"property-repository.js","sourceRoot":"","sources":["../../src/rdf/property-repository.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,8CAA+C;AAE/C,+DAA2D;AAE3D;;GAEG;AACH,MAAa,kBAAmB,SAAQ,wCAAkB;IAWtD,YAAY,KAAe;QAAI,KAAK,CAAC,KAAK,CAAC,CAAC;QAV5C;;WAEG;QACI,oBAAe,GAAG,iBAAI,CAAC,MAAM,CAAC;QAErC;;WAEG;QACI,mBAAc,GAAG,iBAAI,CAAC,KAAK,CAAC;IAEU,CAAC;IAE9C;;;OAGG;IACH,aAAa;QACT,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;QAEjC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,gBAAG,CAAC,IAAI,EAAE,gBAAG,CAAC,QAAQ,CAAC,EAAE;YAC1D,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YAEpB,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,EAAE;gBAC3B,SAAS;aACZ;YAED,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SACvB;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,OAAe;QAC9B,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAE5C,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAI,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE;YACzD,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;YAEnB,IAAI,CAAC,CAAC,QAAQ,IAA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