@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
package/out/index.d.ts CHANGED
File without changes
package/out/index.js CHANGED
@@ -775,7 +775,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
775
775
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
776
776
 
777
777
  "use strict";
778
- eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ResourceRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst uri_1 = __webpack_require__(/*! ./uri */ \"./src/rdf/uri.ts\");\n/**\n * A repository for retrieving resources from graphs.\n */\nclass ResourceRepository {\n constructor(store) {\n this.store = store;\n }\n /**\n * Inidiates if a node should not be included in the result of a definition query.\n * @param graphUris URIs of the graphs to search.\n * @param subject The focus node.\n * @param options Definition query options.\n * @param optionDefaults Custom default values for the query options.\n * @returns\n */\n skip(graphUris, subject, options, optionDefaults = { includeBlankNodes: false, includeReferenced: false }) {\n const opts = { ...optionDefaults, ...options };\n if (!opts.includeBlankNodes && subject.termType != \"NamedNode\") {\n // We are only interested in named nodes.\n return true;\n }\n if (!opts.includeReferenced && !this.hasSubject(graphUris, subject)) {\n // Skip the node if it is not explicitly defined in the graph as a subject.\n return true;\n }\n if (opts?.definedBy !== undefined) {\n const isDefined = this.isDefinedBy(graphUris, subject, opts.definedBy);\n // Do not skip the node if it has a different namespace but is *explicitly* defined by the given URI.\n if (opts.definedBy === null && isDefined || opts.definedBy !== null && !isDefined) {\n return true;\n }\n }\n else if (opts?.notDefinedBy !== undefined) {\n for (const source of opts.notDefinedBy) {\n if (this.isDefinedBy(graphUris, subject, source)) {\n return true;\n }\n }\n }\n return false;\n }\n /**\n * Indicate if a given URI exists as the subject of a triple in the graph.\n * @param graphUris URIs of the graphs to search.\n * @param subjectUri URI of the subject to search for.\n * @returns true if the URI is a subject, false otherwise.\n */\n hasSubject(graphUris, subjectUri) {\n let s;\n if (typeof subjectUri === \"string\") {\n s = n3.DataFactory.namedNode(subjectUri);\n }\n else if (subjectUri.termType !== \"Literal\") {\n s = subjectUri;\n }\n if (s) {\n for (let _ of this.store.match(graphUris, s, null, null, false)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Indicate if a node is explicitly defined by the given URI using the `rdfs:isDefinedBy` property, or implicitly by sharing the same namespace.\n * @param graphUris URIs of the graphs to search.\n * @param node A named node to check if it is defined by the given URI.\n * @param definedBy URI of the vocabulary that defines the resource (rdfs:isDefinedBy). Provide `null` to only return resources that have no `rdfs:isDefinedBy` property.\n * @returns `true` if the node is defined by the given URI, `false` otherwise.\n */\n isDefinedBy(graphUris, node, definedBy) {\n const s = node;\n if (definedBy === null) {\n // If there is no definedBy URI, we assume that the resource is not\n // explicitly defined by any ontology.\n for (let _ of this.store.match(graphUris, s, ontologies_1.rdfs.isDefinedBy, null)) {\n return true;\n }\n }\n else {\n // We assume that a resource is defined by an ontology if it starts with the namespace of the ontology.\n if (node.value.startsWith(definedBy)) {\n return true;\n }\n // If the ontology is something like <http://purl.obolibrary.org/obo/bfo.owl> or <http://www.w3.org/ns/prov#>\n // and the subject is <http://purl.obolibrary.org/obo/BFO_0000001> or <http://www.w3.org/ns/prov#Entity>\n // then we assume that it is defined by the ontology. The OBO case shows that we need to remove the file\n // name in oder to be able to compare the namespace URIs.\n const ontologyNamespace = uri_1.Uri.getNormalizedUri(uri_1.Uri.getNamespaceUri(definedBy));\n const subjectNamespace = uri_1.Uri.getNormalizedUri(uri_1.Uri.getNamespaceUri(node.value));\n if (subjectNamespace === ontologyNamespace) {\n return true;\n }\n const o = n3.DataFactory.namedNode(uri_1.Uri.getNormalizedUri(definedBy));\n // The explicit annotation of the definition source has precedence over heuristic checks.\n for (let q of this.store.match(graphUris, s, ontologies_1.rdfs.isDefinedBy, null)) {\n if (uri_1.Uri.getNormalizedUri(q.object.value) === o.value) {\n return true;\n }\n }\n // A blank node is defined in the namespace if it is the object of a triple that is defined by the URI.\n if (s.termType === \"BlankNode\") {\n for (let q of this.store.match(graphUris, null, null, s, false)) {\n return this.isDefinedBy(graphUris, q.subject, definedBy);\n }\n }\n }\n return false;\n }\n /**\n * Indicate if a resource has a given type in the graph.\n * @param graphUris URIs of the graphs to search.\n * @param subjectUri URI or blank node id of the subject to match.\n * @param typeUri URI of the type to match.\n * @param options Optional query parameters.\n * @returns `true` if the resource has the type, `false` otherwise.\n */\n hasType(graphUris, subjectUri, typeUri, options) {\n const o = n3.DataFactory.namedNode(typeUri);\n for (let _ of this.store.match(graphUris, n3.DataFactory.namedNode(subjectUri), ontologies_1.rdf.type, o, options?.includeInferred)) {\n return true;\n }\n for (let _ of this.store.match(graphUris, n3.DataFactory.blankNode(subjectUri), ontologies_1.rdf.type, o, options?.includeInferred)) {\n return true;\n }\n return false;\n }\n /**\n * Get the language tags used in the object of triples with a given set of predicates.\n * @param graphUris URIs of the graphs to search.\n * @param predicateUris URIs of the predicates to match.\n * @returns An array of language tag statistics, sorted by the number of occurrences in descending order.\n */\n getLanguageStats(graphUris, predicateUris) {\n const stats = {};\n const predicates = predicateUris ? new Set(predicateUris) : undefined;\n for (let q of this.store.match(graphUris, null, null, null, false)) {\n if (q.object.termType === \"Literal\" && q.object.language && (!predicates || predicates.has(q.predicate.value))) {\n if (!stats[q.object.language]) {\n stats[q.object.language] = { language: q.object.language, totalCount: 1, predicates: new Set([q.predicate.value]) };\n }\n else {\n stats[q.object.language].totalCount++;\n stats[q.object.language].predicates.add(q.predicate.value);\n }\n }\n }\n return Object.values(stats).sort((a, b) => b.totalCount - a.totalCount);\n }\n /**\n * Get the most frequently used language tag in the object of triples with a given set of predicates.\n * @param graphUris URIs of the graphs to search.\n * @param predicateUris URIs of the predicates to match.\n */\n getPrimaryLanguageTag(graphUris, predicateUris) {\n const stats = this.getLanguageStats(graphUris, predicateUris);\n return stats[0] ? stats[0].language : undefined;\n }\n}\nexports.ResourceRepository = ResourceRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/resource-repository.ts?");
778
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ResourceRepository = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.mjs\");\nconst n3 = tslib_1.__importStar(__webpack_require__(/*! n3 */ \"./node_modules/n3/src/index.js\"));\nconst ontologies_1 = __webpack_require__(/*! ../ontologies */ \"./src/ontologies/index.ts\");\nconst uri_1 = __webpack_require__(/*! ./uri */ \"./src/rdf/uri.ts\");\n/**\n * A repository for retrieving resources from graphs.\n */\nclass ResourceRepository {\n constructor(store) {\n this.store = store;\n }\n /**\n * Inidiates if a node should not be included in the result of a definition query.\n * @param graphUris URIs of the graphs to search.\n * @param subject The focus node.\n * @param options Definition query options.\n * @param optionDefaults Custom default values for the query options.\n * @returns\n */\n skip(graphUris, subject, options, optionDefaults = { includeBlankNodes: false, includeReferenced: false }) {\n const opts = { ...optionDefaults, ...options };\n if (!opts.includeBlankNodes && subject.termType != \"NamedNode\") {\n // We are only interested in named nodes.\n return true;\n }\n if (!opts.includeReferenced && !this.hasSubject(graphUris, subject)) {\n // Skip the node if it is not explicitly defined in the graph as a subject.\n return true;\n }\n if (opts?.definedBy !== undefined) {\n const isDefined = this.isDefinedBy(graphUris, subject, opts.definedBy);\n // Do not skip the node if it has a different namespace but is *explicitly* defined by the given URI.\n if (opts.definedBy === null && isDefined || opts.definedBy !== null && !isDefined) {\n return true;\n }\n }\n else if (opts?.notDefinedBy !== undefined) {\n for (const source of opts.notDefinedBy) {\n if (this.isDefinedBy(graphUris, subject, source)) {\n return true;\n }\n }\n }\n return false;\n }\n /**\n * Indicate if a given URI exists as the subject of a triple in the graph.\n * @param graphUris URIs of the graphs to search.\n * @param subjectUri URI of the subject to search for.\n * @returns true if the URI is a subject, false otherwise.\n */\n hasSubject(graphUris, subjectUri) {\n let s;\n if (typeof subjectUri === \"string\") {\n s = n3.DataFactory.namedNode(subjectUri);\n }\n else if (subjectUri.termType !== \"Literal\") {\n s = subjectUri;\n }\n if (s) {\n for (let _ of this.store.match(graphUris, s, null, null, false)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Indicate if a node is explicitly defined by the given URI using the `rdfs:isDefinedBy` property, or implicitly by sharing the same namespace.\n * @param graphUris URIs of the graphs to search.\n * @param node A named node to check if it is defined by the given URI.\n * @param definedBy URI of the vocabulary that defines the resource (rdfs:isDefinedBy). Provide `null` to only return resources that have no `rdfs:isDefinedBy` property.\n * @returns `true` if the node is defined by the given URI, `false` otherwise.\n */\n isDefinedBy(graphUris, node, definedBy) {\n const s = node;\n if (definedBy === null) {\n // If there is no definedBy URI, we assume that the resource is not\n // explicitly defined by any ontology.\n for (let _ of this.store.match(graphUris, s, ontologies_1.rdfs.isDefinedBy, null)) {\n return true;\n }\n }\n else {\n // We assume that a resource is defined by an ontology if it starts with the namespace of the ontology.\n if (node.value.startsWith(definedBy)) {\n return true;\n }\n // If the ontology is something like <http://purl.obolibrary.org/obo/bfo.owl> or <http://www.w3.org/ns/prov#>\n // and the subject is <http://purl.obolibrary.org/obo/BFO_0000001> or <http://www.w3.org/ns/prov#Entity>\n // then we assume that it is defined by the ontology. The OBO case shows that we need to remove the file\n // name in oder to be able to compare the namespace URIs.\n const ontologyNamespace = uri_1.Uri.getNormalizedUri(uri_1.Uri.getNamespaceUri(definedBy));\n const subjectNamespace = uri_1.Uri.getNormalizedUri(uri_1.Uri.getNamespaceUri(node.value));\n if (subjectNamespace === ontologyNamespace) {\n return true;\n }\n const o = n3.DataFactory.namedNode(uri_1.Uri.getNormalizedUri(definedBy));\n // The explicit annotation of the definition source has precedence over heuristic checks.\n for (let q of this.store.match(graphUris, s, ontologies_1.rdfs.isDefinedBy, null)) {\n if (uri_1.Uri.getNormalizedUri(q.object.value) === o.value) {\n return true;\n }\n }\n // A blank node is defined in the namespace if it is the object of a triple that is defined by the URI.\n if (s.termType === \"BlankNode\") {\n for (let q of this.store.match(graphUris, null, null, s, false)) {\n return this.isDefinedBy(graphUris, q.subject, definedBy);\n }\n }\n }\n return false;\n }\n /**\n * Indicate if a resource has a given type in the graph.\n * @param graphUris URIs of the graphs to search.\n * @param subjectUri URI or blank node id of the subject to match.\n * @param typeUri URI of the type to match.\n * @param options Optional query parameters.\n * @returns `true` if the resource has the type, `false` otherwise.\n */\n hasType(graphUris, subjectUri, typeUri, options) {\n const o = n3.DataFactory.namedNode(typeUri);\n for (let _ of this.store.match(graphUris, n3.DataFactory.namedNode(subjectUri), ontologies_1.rdf.type, o, options?.includeInferred)) {\n return true;\n }\n for (let _ of this.store.match(graphUris, n3.DataFactory.blankNode(subjectUri), ontologies_1.rdf.type, o, options?.includeInferred)) {\n return true;\n }\n return false;\n }\n /**\n * Get information about the usage of predicates in the document such as the frequency of use and the use of language tags.\n * @param graphUris URIs of the graphs to search.\n * @param predicateUris URIs of the predicates to match.\n */\n getPredicateUsageStats(graphUris, predicateUris = undefined) {\n const result = {};\n const predicates = predicateUris ? new Set(predicateUris) : undefined;\n for (let q of this.store.match(graphUris, null, null, null, false)) {\n if (predicates && !predicates.has(q.predicate.value)) {\n continue;\n }\n // Create stats for all predicates and add language tags for literals if available.\n let predicateStats = result[q.predicate.value];\n if (!predicateStats) {\n predicateStats = {\n predicateIri: q.predicate.value,\n subjects: new Set(),\n usageFrequency: 0,\n languageTags: {}\n };\n result[q.predicate.value] = predicateStats;\n }\n predicateStats.subjects.add(q.subject.value);\n predicateStats.usageFrequency++;\n if (q.object.termType === \"Literal\") {\n let language = q.object.language;\n if (!predicateStats.languageTags[language]) {\n predicateStats.languageTags[language] = 1;\n }\n else {\n predicateStats.languageTags[language] += 1;\n }\n }\n }\n return result;\n }\n /**\n * Get the language tags used in the object of triples with a given set of predicates.\n * @param graphUris URIs of the graphs to search.\n * @param predicateUris URIs of the predicates to match.\n * @returns An array of language tag statistics, sorted by the number of occurrences in descending order.\n */\n getLanguageTagUsageStats(graphUris) {\n const stats = {};\n for (let q of this.store.match(graphUris, null, null, null, false)) {\n if (q.object.termType === \"Literal\" && q.object.language) {\n const language = q.object.language;\n if (!stats[language]) {\n stats[language] = 1;\n }\n else {\n stats[language] += 1;\n }\n }\n }\n return stats;\n }\n /**\n * Get the most frequently used language tag in the object of triples with a given set of predicates.\n * @param graphUris URIs of the graphs to search.\n */\n getMostFrequentLanguageTag(graphUris) {\n let stats = this.getLanguageTagUsageStats(graphUris);\n let max = 0;\n let primary;\n for (let language in stats) {\n if (stats[language] > max) {\n max = stats[language];\n primary = language;\n }\n }\n return primary;\n }\n}\nexports.ResourceRepository = ResourceRepository;\n\n\n//# sourceURL=webpack://@faubulous/mentor-rdf/./src/rdf/resource-repository.ts?");
779
779
 
780
780
  /***/ }),
781
781
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -41,28 +41,39 @@ export interface TypedInstanceQueryOptions extends QueryOptions {
41
41
  includeSubTypes?: boolean;
42
42
  }
43
43
  /**
44
- * A literal value with an optional language tag.
44
+ * Maps a language tag to the number of occurrences in the document.
45
45
  */
46
- export interface LanguageTaggedLiteral {
47
- value: string;
48
- language: string | undefined;
46
+ export interface LanguageTagUsageStats {
47
+ [key: string]: number;
49
48
  }
50
49
  /**
51
- * Provides information about the usage of language tags in a document.
50
+ * Maps a predicate IRI to information about its usage in the document.
52
51
  */
53
- export interface LanguageTagInfo {
52
+ export interface PredicateUsageStats {
53
+ [key: string]: PredicateUsageInfo;
54
+ }
55
+ /**
56
+ * Information about the usage of a single predicate in a document.
57
+ */
58
+ export interface PredicateUsageInfo {
59
+ /**
60
+ * The predicate IRI.
61
+ */
62
+ predicateIri: string;
54
63
  /**
55
- * The language tag.
64
+ * The set of subjects that use the predicate.
56
65
  */
57
- language: string;
66
+ subjects: Set<string>;
58
67
  /**
59
- * The number of occurrences of the language tag in the document.
68
+ * The number of occurrences of the predicate in a document.
60
69
  */
61
- totalCount: number;
70
+ usageFrequency: number;
62
71
  /**
63
- * The predicates that have tagged values.
72
+ * Information about the language tags used in the object of triples with the predicate.
64
73
  */
65
- predicates: Set<string>;
74
+ languageTags: {
75
+ [key: string]: number;
76
+ };
66
77
  }
67
78
  /**
68
79
  * A repository for retrieving resources from graphs.
@@ -106,17 +117,22 @@ export declare class ResourceRepository {
106
117
  * @returns `true` if the resource has the type, `false` otherwise.
107
118
  */
108
119
  hasType(graphUris: string | string[] | undefined, subjectUri: string, typeUri: string, options?: QueryOptions): boolean;
120
+ /**
121
+ * Get information about the usage of predicates in the document such as the frequency of use and the use of language tags.
122
+ * @param graphUris URIs of the graphs to search.
123
+ * @param predicateUris URIs of the predicates to match.
124
+ */
125
+ getPredicateUsageStats(graphUris: string | string[] | undefined, predicateUris?: string[] | undefined): PredicateUsageStats;
109
126
  /**
110
127
  * Get the language tags used in the object of triples with a given set of predicates.
111
128
  * @param graphUris URIs of the graphs to search.
112
129
  * @param predicateUris URIs of the predicates to match.
113
130
  * @returns An array of language tag statistics, sorted by the number of occurrences in descending order.
114
131
  */
115
- getLanguageStats(graphUris: string | string[] | undefined, predicateUris: string[] | undefined): LanguageTagInfo[];
132
+ getLanguageTagUsageStats(graphUris: string | string[] | undefined): LanguageTagUsageStats;
116
133
  /**
117
134
  * Get the most frequently used language tag in the object of triples with a given set of predicates.
118
135
  * @param graphUris URIs of the graphs to search.
119
- * @param predicateUris URIs of the predicates to match.
120
136
  */
121
- getPrimaryLanguageTag(graphUris: string | string[] | undefined, predicateUris: string[] | undefined): string | undefined;
137
+ getMostFrequentLanguageTag(graphUris: string | string[] | undefined): string | undefined;
122
138
  }
File without changes
File without changes
package/out/rdf/uri.d.ts CHANGED
File without changes
File without changes
package/package.json CHANGED
@@ -1,66 +1,66 @@
1
- {
2
- "name": "@faubulous/mentor-rdf",
3
- "description": "A library for working with RDF vocabularies with support for basic RDFS and OWL inference.",
4
- "keywords": [
5
- "rdf",
6
- "rdfs",
7
- "owl",
8
- "reasoning",
9
- "inference",
10
- "ontology",
11
- "vocabulary"
12
- ],
13
- "version": "0.2.49",
14
- "private": false,
15
- "author": {
16
- "name": "Sebastian Faubel"
17
- },
18
- "main": "out/index.js",
19
- "types": "out/index.d.ts",
20
- "exports": [
21
- "./out/index.js"
22
- ],
23
- "files": [
24
- "./out"
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": "GPL",
37
- "scripts": {
38
- "prepublish": "npm run build",
39
- "compile": "tsc -p tsconfig.json",
40
- "build": "npx webpack build",
41
- "build:ontologies": "npx ts-node build-ontologies.ts",
42
- "test": "npx jest",
43
- "test:coverage": "npx jest --coverage --coverageDirectory=docs/coverage"
44
- },
45
- "devDependencies": {
46
- "@types/jest": "^29.5.4",
47
- "@types/node": "^20.5.7",
48
- "@webpack-cli/generators": "^3.0.7",
49
- "jest": "^29.7.0",
50
- "jest-environment-node": "^29.6.4",
51
- "ts-jest": "^29.1.1",
52
- "ts-loader": "^9.5.0",
53
- "ts-node": "^10.9.1",
54
- "ts-node-dev": "^2.0.0",
55
- "tslib": "^2.6.2",
56
- "typescript": "^5.6.2",
57
- "webpack": "^5.94.0",
58
- "webpack-cli": "^5.1.4"
59
- },
60
- "dependencies": {
61
- "@types/n3": "^1.16.0",
62
- "millan": "^5.3.0",
63
- "n3": "^1.17.1",
64
- "rxjs": "^7.8.1"
65
- }
66
- }
1
+ {
2
+ "name": "@faubulous/mentor-rdf",
3
+ "description": "A library for working with RDF vocabularies with support for basic RDFS and OWL inference.",
4
+ "keywords": [
5
+ "rdf",
6
+ "rdfs",
7
+ "owl",
8
+ "reasoning",
9
+ "inference",
10
+ "ontology",
11
+ "vocabulary"
12
+ ],
13
+ "version": "0.2.50",
14
+ "private": false,
15
+ "author": {
16
+ "name": "Sebastian Faubel"
17
+ },
18
+ "main": "out/index.js",
19
+ "types": "out/index.d.ts",
20
+ "exports": [
21
+ "./out/index.js"
22
+ ],
23
+ "files": [
24
+ "./out"
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": "GPL",
37
+ "scripts": {
38
+ "prepublish": "npm run build",
39
+ "compile": "tsc -p tsconfig.json",
40
+ "build": "npx webpack build",
41
+ "build:ontologies": "npx ts-node build-ontologies.ts",
42
+ "test": "npx jest",
43
+ "test:coverage": "npx jest --coverage --coverageDirectory=docs/coverage"
44
+ },
45
+ "devDependencies": {
46
+ "@types/jest": "^29.5.4",
47
+ "@types/node": "^20.5.7",
48
+ "@webpack-cli/generators": "^3.0.7",
49
+ "jest": "^29.7.0",
50
+ "jest-environment-node": "^29.6.4",
51
+ "ts-jest": "^29.1.1",
52
+ "ts-loader": "^9.5.0",
53
+ "ts-node": "^10.9.1",
54
+ "ts-node-dev": "^2.0.0",
55
+ "tslib": "^2.6.2",
56
+ "typescript": "^5.6.2",
57
+ "webpack": "^5.94.0",
58
+ "webpack-cli": "^5.1.4"
59
+ },
60
+ "dependencies": {
61
+ "@types/n3": "^1.16.0",
62
+ "millan": "^5.3.0",
63
+ "n3": "^1.17.1",
64
+ "rxjs": "^7.8.1"
65
+ }
66
+ }
package/out/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,gDAAqB"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._xsd = exports.xsd = exports._XSD = exports.XSD = exports._skos = exports.skos = exports._SKOS = exports.SKOS = exports._skos_xl = exports.skos_xl = exports._SKOS_XL = exports.SKOS_XL = exports._sh = exports.sh = exports._SH = exports.SH = exports._rdfs = exports.rdfs = exports._RDFS = exports.RDFS = exports._rdfa = exports.rdfa = exports._RDFA = exports.RDFA = exports._rdf = exports.rdf = exports._RDF = exports.RDF = exports._owl = exports.owl = exports._OWL = exports.OWL = void 0;
4
- var owl_1 = require("./owl");
5
- Object.defineProperty(exports, "OWL", { enumerable: true, get: function () { return owl_1.OWL; } });
6
- Object.defineProperty(exports, "_OWL", { enumerable: true, get: function () { return owl_1._OWL; } });
7
- Object.defineProperty(exports, "owl", { enumerable: true, get: function () { return owl_1.owl; } });
8
- Object.defineProperty(exports, "_owl", { enumerable: true, get: function () { return owl_1._owl; } });
9
- var rdf_1 = require("./rdf");
10
- Object.defineProperty(exports, "RDF", { enumerable: true, get: function () { return rdf_1.RDF; } });
11
- Object.defineProperty(exports, "_RDF", { enumerable: true, get: function () { return rdf_1._RDF; } });
12
- Object.defineProperty(exports, "rdf", { enumerable: true, get: function () { return rdf_1.rdf; } });
13
- Object.defineProperty(exports, "_rdf", { enumerable: true, get: function () { return rdf_1._rdf; } });
14
- var rdfa_1 = require("./rdfa");
15
- Object.defineProperty(exports, "RDFA", { enumerable: true, get: function () { return rdfa_1.RDFA; } });
16
- Object.defineProperty(exports, "_RDFA", { enumerable: true, get: function () { return rdfa_1._RDFA; } });
17
- Object.defineProperty(exports, "rdfa", { enumerable: true, get: function () { return rdfa_1.rdfa; } });
18
- Object.defineProperty(exports, "_rdfa", { enumerable: true, get: function () { return rdfa_1._rdfa; } });
19
- var rdfs_1 = require("./rdfs");
20
- Object.defineProperty(exports, "RDFS", { enumerable: true, get: function () { return rdfs_1.RDFS; } });
21
- Object.defineProperty(exports, "_RDFS", { enumerable: true, get: function () { return rdfs_1._RDFS; } });
22
- Object.defineProperty(exports, "rdfs", { enumerable: true, get: function () { return rdfs_1.rdfs; } });
23
- Object.defineProperty(exports, "_rdfs", { enumerable: true, get: function () { return rdfs_1._rdfs; } });
24
- var sh_1 = require("./sh");
25
- Object.defineProperty(exports, "SH", { enumerable: true, get: function () { return sh_1.SH; } });
26
- Object.defineProperty(exports, "_SH", { enumerable: true, get: function () { return sh_1._SH; } });
27
- Object.defineProperty(exports, "sh", { enumerable: true, get: function () { return sh_1.sh; } });
28
- Object.defineProperty(exports, "_sh", { enumerable: true, get: function () { return sh_1._sh; } });
29
- var skos_xl_1 = require("./skos-xl");
30
- Object.defineProperty(exports, "SKOS_XL", { enumerable: true, get: function () { return skos_xl_1.SKOS_XL; } });
31
- Object.defineProperty(exports, "_SKOS_XL", { enumerable: true, get: function () { return skos_xl_1._SKOS_XL; } });
32
- Object.defineProperty(exports, "skos_xl", { enumerable: true, get: function () { return skos_xl_1.skos_xl; } });
33
- Object.defineProperty(exports, "_skos_xl", { enumerable: true, get: function () { return skos_xl_1._skos_xl; } });
34
- var skos_1 = require("./skos");
35
- Object.defineProperty(exports, "SKOS", { enumerable: true, get: function () { return skos_1.SKOS; } });
36
- Object.defineProperty(exports, "_SKOS", { enumerable: true, get: function () { return skos_1._SKOS; } });
37
- Object.defineProperty(exports, "skos", { enumerable: true, get: function () { return skos_1.skos; } });
38
- Object.defineProperty(exports, "_skos", { enumerable: true, get: function () { return skos_1._skos; } });
39
- var xsd_1 = require("./xsd");
40
- Object.defineProperty(exports, "XSD", { enumerable: true, get: function () { return xsd_1.XSD; } });
41
- Object.defineProperty(exports, "_XSD", { enumerable: true, get: function () { return xsd_1._XSD; } });
42
- Object.defineProperty(exports, "xsd", { enumerable: true, get: function () { return xsd_1.xsd; } });
43
- Object.defineProperty(exports, "_xsd", { enumerable: true, get: function () { return xsd_1._xsd; } });
44
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ontologies/index.ts"],"names":[],"mappings":";;;AAAA,6BAA6C;AAApC,0FAAA,GAAG,OAAA;AAAE,2FAAA,IAAI,OAAA;AAAE,0FAAA,GAAG,OAAA;AAAE,2FAAA,IAAI,OAAA;AAC7B,6BAA6C;AAApC,0FAAA,GAAG,OAAA;AAAE,2FAAA,IAAI,OAAA;AAAE,0FAAA,GAAG,OAAA;AAAE,2FAAA,IAAI,OAAA;AAC7B,+BAAkD;AAAzC,4FAAA,IAAI,OAAA;AAAE,6FAAA,KAAK,OAAA;AAAE,4FAAA,IAAI,OAAA;AAAE,6FAAA,KAAK,OAAA;AACjC,+BAAkD;AAAzC,4FAAA,IAAI,OAAA;AAAE,6FAAA,KAAK,OAAA;AAAE,4FAAA,IAAI,OAAA;AAAE,6FAAA,KAAK,OAAA;AACjC,2BAAwC;AAA/B,wFAAA,EAAE,OAAA;AAAE,yFAAA,GAAG,OAAA;AAAE,wFAAA,EAAE,OAAA;AAAE,yFAAA,GAAG,OAAA;AACzB,qCAAiE;AAAxD,kGAAA,OAAO,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,kGAAA,OAAO,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAC7C,+BAAkD;AAAzC,4FAAA,IAAI,OAAA;AAAE,6FAAA,KAAK,OAAA;AAAE,4FAAA,IAAI,OAAA;AAAE,6FAAA,KAAK,OAAA;AACjC,6BAA6C;AAApC,0FAAA,GAAG,OAAA;AAAE,2FAAA,IAAI,OAAA;AAAE,0FAAA,GAAG,OAAA;AAAE,2FAAA,IAAI,OAAA"}