@skaterqiang/protege-js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/LICENSE +48 -0
  3. package/README.md +287 -0
  4. package/docs/API.md +654 -0
  5. package/docs/design/OWL2-/347/274/272/345/217/243/345/210/206/346/236/220.md +140 -0
  6. package/docs/owl2-rl/OWL2-RL-/350/247/204/345/210/231/347/273/206/345/210/231.md +168 -0
  7. package/docs/owl2-rl/owl2-profiles-spec-zh.html +1914 -0
  8. package/docs/owl2-rl/owl2-profiles-spec.html +1916 -0
  9. package/docs/owl2-rl/rl_rules.json +392 -0
  10. package/main.js +46 -0
  11. package/package.json +76 -0
  12. package/sample/README.md +74 -0
  13. package/sample/case1-ecommerce-risk.js +170 -0
  14. package/sample/case10-ecommerce-customer-service.js +454 -0
  15. package/sample/case2-family-swrl.js +147 -0
  16. package/sample/case3-pharma-safety.js +132 -0
  17. package/sample/case4-knowledge-publishing.js +111 -0
  18. package/sample/case5-obda-profiles.js +153 -0
  19. package/sample/case6-medical-ontology.js +152 -0
  20. package/sample/case7-manufacturing-ppr.js +155 -0
  21. package/sample/case8-real-medical-bfo-ogms.js +353 -0
  22. package/sample/case9-real-manufacturing-iao.js +360 -0
  23. package/sample/ontologies/bfo.owl +1715 -0
  24. package/sample/ontologies/iao.owl +8532 -0
  25. package/sample/ontologies/ogms.owl +4320 -0
  26. package/sample/ontologies/ro-core.owl +1010 -0
  27. package/scripts/verify-api.js +53 -0
  28. package/src/index.js +176 -0
  29. package/src/inference/OWL2ProfileReasoners.js +67 -0
  30. package/src/inference/OWL2RLReasoner.js +65 -0
  31. package/src/inference/ReasonerQueries.js +111 -0
  32. package/src/inference/SWRLReasoner.js +409 -0
  33. package/src/inference/TripleStore.js +82 -0
  34. package/src/inference/rdf.js +83 -0
  35. package/src/inference/rules/owl2el.js +33 -0
  36. package/src/inference/rules/owl2ql.js +29 -0
  37. package/src/inference/rules/owl2rl.js +823 -0
  38. package/src/io/FunctionalSyntaxParser.js +399 -0
  39. package/src/io/FunctionalSyntaxWriter.js +180 -0
  40. package/src/io/ManchesterSyntaxParser.js +398 -0
  41. package/src/io/OWLXMLParser.js +356 -0
  42. package/src/io/OntologyLoader.js +125 -0
  43. package/src/io/RDFGraphToOntology.js +702 -0
  44. package/src/io/RDFXMLParser.js +319 -0
  45. package/src/io/RDFXMLWriter.js +196 -0
  46. package/src/io/SWRLParser.js +150 -0
  47. package/src/io/TurtleParser.js +363 -0
  48. package/src/io/TurtleWriter.js +393 -0
  49. package/src/model/IRI.js +62 -0
  50. package/src/model/OWLAxiom.js +507 -0
  51. package/src/model/OWLClassExpression.js +242 -0
  52. package/src/model/OWLEntity.js +142 -0
  53. package/src/model/OWLLiteral.js +30 -0
  54. package/src/model/OWLModelManager.js +106 -0
  55. package/src/model/OWLOntology.js +119 -0
  56. package/src/model/SWRL.js +152 -0
  57. package/src/model/event/OWLModelManagerEvent.js +33 -0
  58. package/src/model/hierarchy/HierarchyProvider.js +214 -0
  59. package/src/profiles/OWL2Profiles.js +185 -0
  60. package/src/server/public/app.js +97 -0
  61. package/src/server/public/index.html +49 -0
  62. package/src/server/webServer.js +138 -0
  63. package/src/validation/GlobalRestrictionsValidator.js +172 -0
  64. package/test/core.test.js +111 -0
  65. package/test/exports-map.test.js +165 -0
  66. package/test/owl2/axioms.test.js +160 -0
  67. package/test/owl2/classExpressions.test.js +99 -0
  68. package/test/owl2/functional-syntax-writer.test.js +65 -0
  69. package/test/owl2/functional.test.js +113 -0
  70. package/test/owl2/global-restrictions.test.js +76 -0
  71. package/test/owl2/longtail.test.js +74 -0
  72. package/test/owl2/manchester-syntax.test.js +100 -0
  73. package/test/owl2/ontology-loader-imports.test.js +62 -0
  74. package/test/owl2/owlxml-parser.test.js +112 -0
  75. package/test/owl2/profile-reasoners.test.js +108 -0
  76. package/test/owl2/profiles.test.js +66 -0
  77. package/test/owl2/rdf-graph-to-ontology.test.js +177 -0
  78. package/test/owl2/rdfxml-punning.test.js +25 -0
  79. package/test/owl2/rdfxml-writer.test.js +55 -0
  80. package/test/owl2/rdfxml.test.js +91 -0
  81. package/test/owl2/reasoner-queries.test.js +58 -0
  82. package/test/owl2/sample-e2e.test.js +195 -0
  83. package/test/owl2/swrl-parser.test.js +60 -0
  84. package/test/owl2/swrl.test.js +131 -0
  85. package/test/owl2/turtle-writer.test.js +84 -0
  86. package/test/owl2/turtle.test.js +124 -0
  87. package/test/owl2rl/cax.test.js +57 -0
  88. package/test/owl2rl/cls.test.js +210 -0
  89. package/test/owl2rl/dt.test.js +72 -0
  90. package/test/owl2rl/eq.test.js +95 -0
  91. package/test/owl2rl/prp.test.js +198 -0
  92. package/test/owl2rl/scm.test.js +203 -0
@@ -0,0 +1,507 @@
1
+ 'use strict';
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // OWLAxiom — mirrors org.semanticweb.owlapi.model.OWLAxiom
5
+ // Subset: declaration, subClassOf, subObjectPropertyOf, subDataPropertyOf,
6
+ // classAssertion, propertyAssertion, annotationAssertion, equivalentClasses,
7
+ // disjointClasses, domain, range.
8
+ // ---------------------------------------------------------------------------
9
+
10
+ const AxiomType = Object.freeze({
11
+ // 1. Declaration
12
+ DECLARATION: 'Declaration',
13
+ // 2-3. Class axioms
14
+ SUBCLASS_OF: 'SubClassOf',
15
+ EQUIVALENT_CLASSES: 'EquivalentClasses',
16
+ DISJOINT_CLASSES: 'DisjointClasses',
17
+ DISJOINT_UNION: 'DisjointUnion',
18
+ // 4-8. Object property axioms
19
+ SUB_OBJECT_PROPERTY_OF: 'SubObjectPropertyOf',
20
+ SUB_PROPERTY_CHAIN_OF: 'SubObjectPropertyChainOf',
21
+ EQUIVALENT_OBJECT_PROPERTIES: 'EquivalentObjectProperties',
22
+ DISJOINT_OBJECT_PROPERTIES: 'DisjointObjectProperties',
23
+ OBJECT_PROPERTY_DOMAIN: 'ObjectPropertyDomain',
24
+ OBJECT_PROPERTY_RANGE: 'ObjectPropertyRange',
25
+ INVERSE_OBJECT_PROPERTIES: 'InverseObjectProperties',
26
+ // 9. Functional object property
27
+ FUNCTIONAL_OBJECT_PROPERTY: 'FunctionalObjectProperty',
28
+ INVERSE_FUNCTIONAL_OBJECT_PROPERTY: 'InverseFunctionalObjectProperty',
29
+ REFLEXIVE_OBJECT_PROPERTY: 'ReflexiveObjectProperty',
30
+ IRREFLEXIVE_OBJECT_PROPERTY: 'IrreflexiveObjectProperty',
31
+ SYMMETRIC_OBJECT_PROPERTY: 'SymmetricObjectProperty',
32
+ ASYMMETRIC_OBJECT_PROPERTY: 'AsymmetricObjectProperty',
33
+ TRANSITIVE_OBJECT_PROPERTY: 'TransitiveObjectProperty',
34
+ // Data property axioms
35
+ SUB_DATA_PROPERTY_OF: 'SubDataPropertyOf',
36
+ EQUIVALENT_DATA_PROPERTIES: 'EquivalentDataProperties',
37
+ DISJOINT_DATA_PROPERTIES: 'DisjointDataProperties',
38
+ DATA_PROPERTY_DOMAIN: 'DataPropertyDomain',
39
+ DATA_PROPERTY_RANGE: 'DataPropertyRange',
40
+ FUNCTIONAL_DATA_PROPERTY: 'FunctionalDataProperty',
41
+ // Datatype definition
42
+ DATATYPE_DEFINITION: 'DatatypeDefinition',
43
+ // Has key
44
+ HAS_KEY: 'HasKey',
45
+ // Assertions
46
+ SAME_INDIVIDUAL: 'SameIndividual',
47
+ DIFFERENT_INDIVIDUALS: 'DifferentIndividuals',
48
+ CLASS_ASSERTION: 'ClassAssertion',
49
+ OBJECT_PROPERTY_ASSERTION: 'ObjectPropertyAssertion',
50
+ NEGATIVE_OBJECT_PROPERTY_ASSERTION: 'NegativeObjectPropertyAssertion',
51
+ DATA_PROPERTY_ASSERTION: 'DataPropertyAssertion',
52
+ NEGATIVE_DATA_PROPERTY_ASSERTION: 'NegativeDataPropertyAssertion',
53
+ // Annotation axioms
54
+ ANNOTATION_ASSERTION: 'AnnotationAssertion',
55
+ SUB_ANNOTATION_PROPERTY_OF: 'SubAnnotationPropertyOf',
56
+ ANNOTATION_PROPERTY_DOMAIN: 'AnnotationPropertyDomain',
57
+ ANNOTATION_PROPERTY_RANGE: 'AnnotationPropertyRange'
58
+ });
59
+
60
+ class OWLAxiom {
61
+ constructor(axiomType, annotations = []) {
62
+ this.axiomType = axiomType;
63
+ this.annotations = annotations; // OWLAnnotation[]
64
+ }
65
+
66
+ getAxiomType() { return this.axiomType; }
67
+ getAnnotations() { return this.annotations.slice(); }
68
+
69
+ entities() {
70
+ // Overridden by subclasses to return the OWLEntity[] involved.
71
+ return [];
72
+ }
73
+
74
+ equals(other) {
75
+ return other instanceof OWLAxiom && other.toString() === this.toString();
76
+ }
77
+
78
+ toString() {
79
+ return `${this.axiomType}(${this._bodyString()})`;
80
+ }
81
+
82
+ _bodyString() { return ''; }
83
+ }
84
+
85
+ class OWLDeclarationAxiom extends OWLAxiom {
86
+ constructor(entity, annotations) {
87
+ super(AxiomType.DECLARATION, annotations);
88
+ this.entity = entity;
89
+ }
90
+ entities() { return [this.entity]; }
91
+ _bodyString() { return this.entity.toString(); }
92
+ }
93
+
94
+ class OWLSubClassOfAxiom extends OWLAxiom {
95
+ constructor(subClass, superClass, annotations) {
96
+ super(AxiomType.SUBCLASS_OF, annotations);
97
+ this.subClass = subClass; // OWLClassExpression
98
+ this.superClass = superClass; // OWLClassExpression
99
+ }
100
+ entities() { return [...exprEntities(this.subClass), ...exprEntities(this.superClass)]; }
101
+ _bodyString() { return `${exprString(this.subClass)} ${exprString(this.superClass)}`; }
102
+ }
103
+
104
+ class OWLEquivalentClassesAxiom extends OWLAxiom {
105
+ constructor(classExpressions, annotations) {
106
+ super(AxiomType.EQUIVALENT_CLASSES, annotations);
107
+ this.classExpressions = classExpressions.slice();
108
+ }
109
+ entities() { return this.classExpressions.flatMap(exprEntities); }
110
+ _bodyString() { return this.classExpressions.map(exprString).join(' '); }
111
+ }
112
+
113
+ class OWLDisjointClassesAxiom extends OWLAxiom {
114
+ constructor(classExpressions, annotations) {
115
+ super(AxiomType.DISJOINT_CLASSES, annotations);
116
+ this.classExpressions = classExpressions.slice();
117
+ }
118
+ entities() { return this.classExpressions.flatMap(exprEntities); }
119
+ _bodyString() { return this.classExpressions.map(exprString).join(' '); }
120
+ }
121
+
122
+ class OWLSubObjectPropertyOfAxiom extends OWLAxiom {
123
+ constructor(subProperty, superProperty, annotations) {
124
+ super(AxiomType.SUB_OBJECT_PROPERTY_OF, annotations);
125
+ this.subProperty = subProperty;
126
+ this.superProperty = superProperty;
127
+ }
128
+ entities() { return [this.subProperty, this.superProperty]; }
129
+ _bodyString() { return `${this.subProperty} ${this.superProperty}`; }
130
+ }
131
+
132
+ class OWLSubDataPropertyOfAxiom extends OWLAxiom {
133
+ constructor(subProperty, superProperty, annotations) {
134
+ super(AxiomType.SUB_DATA_PROPERTY_OF, annotations);
135
+ this.subProperty = subProperty;
136
+ this.superProperty = superProperty;
137
+ }
138
+ entities() { return [this.subProperty, this.superProperty]; }
139
+ _bodyString() { return `${this.subProperty} ${this.superProperty}`; }
140
+ }
141
+
142
+ class OWLObjectPropertyDomainAxiom extends OWLAxiom {
143
+ constructor(property, domain, annotations) {
144
+ super(AxiomType.OBJECT_PROPERTY_DOMAIN, annotations);
145
+ this.property = property;
146
+ this.domain = domain;
147
+ }
148
+ entities() { return [this.property, ...exprEntities(this.domain)]; }
149
+ _bodyString() { return `${this.property} ${exprString(this.domain)}`; }
150
+ }
151
+
152
+ class OWLObjectPropertyRangeAxiom extends OWLAxiom {
153
+ constructor(property, range, annotations) {
154
+ super(AxiomType.OBJECT_PROPERTY_RANGE, annotations);
155
+ this.property = property;
156
+ this.range = range;
157
+ }
158
+ entities() { return [this.property, ...exprEntities(this.range)]; }
159
+ _bodyString() { return `${this.property} ${exprString(this.range)}`; }
160
+ }
161
+
162
+ class OWLDataPropertyDomainAxiom extends OWLAxiom {
163
+ constructor(property, domain, annotations) {
164
+ super(AxiomType.DATA_PROPERTY_DOMAIN, annotations);
165
+ this.property = property;
166
+ this.domain = domain;
167
+ }
168
+ entities() { return [this.property, ...exprEntities(this.domain)]; }
169
+ _bodyString() { return `${this.property} ${exprString(this.domain)}`; }
170
+ }
171
+
172
+ class OWLClassAssertionAxiom extends OWLAxiom {
173
+ constructor(individual, classExpression, annotations) {
174
+ super(AxiomType.CLASS_ASSERTION, annotations);
175
+ this.individual = individual;
176
+ this.classExpression = classExpression;
177
+ }
178
+ entities() { return [this.individual, ...exprEntities(this.classExpression)]; }
179
+ _bodyString() { return `${exprString(this.classExpression)}(${this.individual.getShortForm()})`; }
180
+ }
181
+
182
+ class OWLObjectPropertyAssertionAxiom extends OWLAxiom {
183
+ constructor(subject, property, object, annotations) {
184
+ super(AxiomType.OBJECT_PROPERTY_ASSERTION, annotations);
185
+ this.subject = subject;
186
+ this.property = property;
187
+ this.object = object;
188
+ }
189
+ entities() { return [this.subject, this.property, this.object]; }
190
+ _bodyString() { return `${this.property}(${this.subject.getShortForm()}, ${this.object.getShortForm()})`; }
191
+ }
192
+
193
+ class OWLDataPropertyAssertionAxiom extends OWLAxiom {
194
+ constructor(subject, property, literal, annotations) {
195
+ super(AxiomType.DATA_PROPERTY_ASSERTION, annotations);
196
+ this.subject = subject;
197
+ this.property = property;
198
+ this.literal = literal; // OWLLiteral
199
+ }
200
+ entities() { return [this.subject, this.property]; }
201
+ _bodyString() { return `${this.property}(${this.subject.getShortForm()}, ${this.literal})`; }
202
+ }
203
+
204
+ class OWLAnnotationAssertionAxiom extends OWLAxiom {
205
+ constructor(subject, property, value, annotations) {
206
+ super(AxiomType.ANNOTATION_ASSERTION, annotations);
207
+ this.subject = subject; // IRI
208
+ this.property = property; // OWLAnnotationProperty
209
+ this.value = value; // OWLAnnotationValue (IRI | OWLLiteral)
210
+ }
211
+ entities() { return [this.property]; }
212
+ _bodyString() { return `${this.property}(${this.subject}, ${this.value})`; }
213
+ }
214
+
215
+ // ---- New axiom classes (OWL 2 structural spec coverage) ---------------------
216
+
217
+ class OWLDisjointUnionAxiom extends OWLAxiom {
218
+ constructor(owlClass, classExpressions, annotations) {
219
+ super(AxiomType.DISJOINT_UNION, annotations);
220
+ this.owlClass = owlClass;
221
+ this.classExpressions = classExpressions.slice();
222
+ }
223
+ entities() { return [this.owlClass, ...this.classExpressions.flatMap(exprEntities)]; }
224
+ _bodyString() { return `${this.owlClass.getShortForm()} = union(${this.classExpressions.map(exprString).join(', ')})`; }
225
+ }
226
+
227
+ class OWLSubPropertyChainOfAxiom extends OWLAxiom {
228
+ constructor(propertyChain, superProperty, annotations) {
229
+ super(AxiomType.SUB_PROPERTY_CHAIN_OF, annotations);
230
+ this.propertyChain = propertyChain.slice();
231
+ this.superProperty = superProperty;
232
+ }
233
+ entities() { return [...this.propertyChain, this.superProperty]; }
234
+ _bodyString() { return `${this.propertyChain.map(String).join(' ∘ ')} → ${this.superProperty}`; }
235
+ }
236
+
237
+ class OWLEquivalentObjectPropertiesAxiom extends OWLAxiom {
238
+ constructor(properties, annotations) {
239
+ super(AxiomType.EQUIVALENT_OBJECT_PROPERTIES, annotations);
240
+ this.properties = properties.slice();
241
+ }
242
+ entities() { return this.properties; }
243
+ _bodyString() { return this.properties.map(String).join(' ≡ '); }
244
+ }
245
+
246
+ class OWLDisjointObjectPropertiesAxiom extends OWLAxiom {
247
+ constructor(properties, annotations) {
248
+ super(AxiomType.DISJOINT_OBJECT_PROPERTIES, annotations);
249
+ this.properties = properties.slice();
250
+ }
251
+ entities() { return this.properties; }
252
+ _bodyString() { return this.properties.map(String).join(' ≠ '); }
253
+ }
254
+
255
+ class OWLEquivalentDataPropertiesAxiom extends OWLAxiom {
256
+ constructor(properties, annotations) {
257
+ super(AxiomType.EQUIVALENT_DATA_PROPERTIES, annotations);
258
+ this.properties = properties.slice();
259
+ }
260
+ entities() { return this.properties; }
261
+ _bodyString() { return this.properties.map(String).join(' ≡ '); }
262
+ }
263
+
264
+ class OWLDisjointDataPropertiesAxiom extends OWLAxiom {
265
+ constructor(properties, annotations) {
266
+ super(AxiomType.DISJOINT_DATA_PROPERTIES, annotations);
267
+ this.properties = properties.slice();
268
+ }
269
+ entities() { return this.properties; }
270
+ _bodyString() { return this.properties.map(String).join(' ≠ '); }
271
+ }
272
+
273
+ class OWLDataPropertyRangeAxiom extends OWLAxiom {
274
+ constructor(property, range, annotations) {
275
+ super(AxiomType.DATA_PROPERTY_RANGE, annotations);
276
+ this.property = property;
277
+ this.range = range; // OWLDataRange
278
+ }
279
+ entities() { return [this.property]; }
280
+ _bodyString() { return `${this.property} ${exprString(this.range)}`; }
281
+ }
282
+
283
+ class OWLDatatypeDefinitionAxiom extends OWLAxiom {
284
+ constructor(datatype, dataRange, annotations) {
285
+ super(AxiomType.DATATYPE_DEFINITION, annotations);
286
+ this.datatype = datatype; // OWLDatatype
287
+ this.dataRange = dataRange; // OWLDataRange
288
+ }
289
+ entities() { return [this.datatype]; }
290
+ _bodyString() { return `${this.datatype.getShortForm()} := ${exprString(this.dataRange)}`; }
291
+ }
292
+
293
+ class OWLHasKeyAxiom extends OWLAxiom {
294
+ constructor(classExpression, propertyExpressions, annotations) {
295
+ super(AxiomType.HAS_KEY, annotations);
296
+ this.classExpression = classExpression;
297
+ this.propertyExpressions = propertyExpressions.slice();
298
+ }
299
+ entities() { return [...exprEntities(this.classExpression), ...this.propertyExpressions]; }
300
+ _bodyString() { return `${exprString(this.classExpression)} hasKey (${this.propertyExpressions.map(String).join(', ')})`; }
301
+ }
302
+
303
+ class OWLSameIndividualAxiom extends OWLAxiom {
304
+ constructor(individuals, annotations) {
305
+ super(AxiomType.SAME_INDIVIDUAL, annotations);
306
+ this.individuals = individuals.slice();
307
+ }
308
+ entities() { return this.individuals; }
309
+ _bodyString() { return this.individuals.map(i => i.getShortForm()).join(' = '); }
310
+ }
311
+
312
+ class OWLDifferentIndividualsAxiom extends OWLAxiom {
313
+ constructor(individuals, annotations) {
314
+ super(AxiomType.DIFFERENT_INDIVIDUALS, annotations);
315
+ this.individuals = individuals.slice();
316
+ }
317
+ entities() { return this.individuals; }
318
+ _bodyString() { return this.individuals.map(i => i.getShortForm()).join(' ≠ '); }
319
+ }
320
+
321
+ class OWLNegativeObjectPropertyAssertionAxiom extends OWLAxiom {
322
+ constructor(subject, property, object, annotations) {
323
+ super(AxiomType.NEGATIVE_OBJECT_PROPERTY_ASSERTION, annotations);
324
+ this.subject = subject;
325
+ this.property = property;
326
+ this.object = object;
327
+ }
328
+ entities() { return [this.subject, this.property, this.object]; }
329
+ _bodyString() { return `NOT ${this.property}(${this.subject.getShortForm()}, ${this.object.getShortForm()})`; }
330
+ }
331
+
332
+ class OWLNegativeDataPropertyAssertionAxiom extends OWLAxiom {
333
+ constructor(subject, property, literal, annotations) {
334
+ super(AxiomType.NEGATIVE_DATA_PROPERTY_ASSERTION, annotations);
335
+ this.subject = subject;
336
+ this.property = property;
337
+ this.literal = literal;
338
+ }
339
+ entities() { return [this.subject, this.property]; }
340
+ _bodyString() { return `NOT ${this.property}(${this.subject.getShortForm()}, ${this.literal})`; }
341
+ }
342
+
343
+ class OWLSubAnnotationPropertyOfAxiom extends OWLAxiom {
344
+ constructor(subProperty, superProperty, annotations) {
345
+ super(AxiomType.SUB_ANNOTATION_PROPERTY_OF, annotations);
346
+ this.subProperty = subProperty;
347
+ this.superProperty = superProperty;
348
+ }
349
+ entities() { return [this.subProperty, this.superProperty]; }
350
+ _bodyString() { return `${this.subProperty} ⊑ ${this.superProperty}`; }
351
+ }
352
+
353
+ class OWLAnnotationPropertyDomainAxiom extends OWLAxiom {
354
+ constructor(property, domain, annotations) {
355
+ super(AxiomType.ANNOTATION_PROPERTY_DOMAIN, annotations);
356
+ this.property = property;
357
+ this.domain = domain; // IRI
358
+ }
359
+ entities() { return [this.property]; }
360
+ _bodyString() { return `${this.property} domain ${this.domain}`; }
361
+ }
362
+
363
+ class OWLAnnotationPropertyRangeAxiom extends OWLAxiom {
364
+ constructor(property, range, annotations) {
365
+ super(AxiomType.ANNOTATION_PROPERTY_RANGE, annotations);
366
+ this.property = property;
367
+ this.range = range; // IRI
368
+ }
369
+ entities() { return [this.property]; }
370
+ _bodyString() { return `${this.property} range ${this.range}`; }
371
+ }
372
+
373
+ // Property-characteristic axioms (single property)
374
+ class OWLFunctionalObjectPropertyAxiom extends OWLAxiom {
375
+ constructor(property, annotations) {
376
+ super(AxiomType.FUNCTIONAL_OBJECT_PROPERTY, annotations);
377
+ this.property = property;
378
+ }
379
+ entities() { return [this.property]; }
380
+ _bodyString() { return `Functional(${this.property})`; }
381
+ }
382
+ class OWLInverseFunctionalObjectPropertyAxiom extends OWLAxiom {
383
+ constructor(property, annotations) {
384
+ super(AxiomType.INVERSE_FUNCTIONAL_OBJECT_PROPERTY, annotations);
385
+ this.property = property;
386
+ }
387
+ entities() { return [this.property]; }
388
+ _bodyString() { return `InverseFunctional(${this.property})`; }
389
+ }
390
+ class OWLReflexiveObjectPropertyAxiom extends OWLAxiom {
391
+ constructor(property, annotations) {
392
+ super(AxiomType.REFLEXIVE_OBJECT_PROPERTY, annotations);
393
+ this.property = property;
394
+ }
395
+ entities() { return [this.property]; }
396
+ _bodyString() { return `Reflexive(${this.property})`; }
397
+ }
398
+ class OWLIrreflexiveObjectPropertyAxiom extends OWLAxiom {
399
+ constructor(property, annotations) {
400
+ super(AxiomType.IRREFLEXIVE_OBJECT_PROPERTY, annotations);
401
+ this.property = property;
402
+ }
403
+ entities() { return [this.property]; }
404
+ _bodyString() { return `Irreflexive(${this.property})`; }
405
+ }
406
+ class OWLSymmetricObjectPropertyAxiom extends OWLAxiom {
407
+ constructor(property, annotations) {
408
+ super(AxiomType.SYMMETRIC_OBJECT_PROPERTY, annotations);
409
+ this.property = property;
410
+ }
411
+ entities() { return [this.property]; }
412
+ _bodyString() { return `Symmetric(${this.property})`; }
413
+ }
414
+ class OWLAsymmetricObjectPropertyAxiom extends OWLAxiom {
415
+ constructor(property, annotations) {
416
+ super(AxiomType.ASYMMETRIC_OBJECT_PROPERTY, annotations);
417
+ this.property = property;
418
+ }
419
+ entities() { return [this.property]; }
420
+ _bodyString() { return `Asymmetric(${this.property})`; }
421
+ }
422
+ class OWLTransitiveObjectPropertyAxiom extends OWLAxiom {
423
+ constructor(property, annotations) {
424
+ super(AxiomType.TRANSITIVE_OBJECT_PROPERTY, annotations);
425
+ this.property = property;
426
+ }
427
+ entities() { return [this.property]; }
428
+ _bodyString() { return `Transitive(${this.property})`; }
429
+ }
430
+ class OWLFunctionalDataPropertyAxiom extends OWLAxiom {
431
+ constructor(property, annotations) {
432
+ super(AxiomType.FUNCTIONAL_DATA_PROPERTY, annotations);
433
+ this.property = property;
434
+ }
435
+ entities() { return [this.property]; }
436
+ _bodyString() { return `Functional(${this.property})`; }
437
+ }
438
+ class OWLInverseObjectPropertiesAxiom extends OWLAxiom {
439
+ constructor(property1, property2, annotations) {
440
+ super(AxiomType.INVERSE_OBJECT_PROPERTIES, annotations);
441
+ this.property1 = property1;
442
+ this.property2 = property2;
443
+ }
444
+ entities() { return [this.property1, this.property2]; }
445
+ _bodyString() { return `${this.property1} ≡ ${this.property2}⁻`; }
446
+ }
447
+
448
+ // --- class expression helpers (expressions are plain objects) --------------
449
+
450
+ function exprEntities(expr) {
451
+ if (!expr) return [];
452
+ if (expr.getEntityType) return [expr]; // a named entity
453
+ if (Array.isArray(expr.operands)) return expr.operands.flatMap(exprEntities);
454
+ const out = [];
455
+ if (expr.filler) out.push(...exprEntities(expr.filler));
456
+ if (expr.property && expr.property.getEntityType) out.push(expr.property);
457
+ return out;
458
+ }
459
+
460
+ function exprString(expr) {
461
+ if (!expr) return '?';
462
+ if (expr.getShortForm) return expr.getShortForm();
463
+ return expr.toString ? expr.toString() : String(expr);
464
+ }
465
+
466
+ module.exports = {
467
+ AxiomType,
468
+ OWLAxiom,
469
+ OWLDeclarationAxiom,
470
+ OWLSubClassOfAxiom,
471
+ OWLEquivalentClassesAxiom,
472
+ OWLDisjointClassesAxiom,
473
+ OWLDisjointUnionAxiom,
474
+ OWLSubObjectPropertyOfAxiom,
475
+ OWLSubPropertyChainOfAxiom,
476
+ OWLEquivalentObjectPropertiesAxiom,
477
+ OWLDisjointObjectPropertiesAxiom,
478
+ OWLSubDataPropertyOfAxiom,
479
+ OWLEquivalentDataPropertiesAxiom,
480
+ OWLDisjointDataPropertiesAxiom,
481
+ OWLObjectPropertyDomainAxiom,
482
+ OWLObjectPropertyRangeAxiom,
483
+ OWLDataPropertyDomainAxiom,
484
+ OWLDataPropertyRangeAxiom,
485
+ OWLDatatypeDefinitionAxiom,
486
+ OWLHasKeyAxiom,
487
+ OWLSameIndividualAxiom,
488
+ OWLDifferentIndividualsAxiom,
489
+ OWLClassAssertionAxiom,
490
+ OWLObjectPropertyAssertionAxiom,
491
+ OWLNegativeObjectPropertyAssertionAxiom,
492
+ OWLDataPropertyAssertionAxiom,
493
+ OWLNegativeDataPropertyAssertionAxiom,
494
+ OWLAnnotationAssertionAxiom,
495
+ OWLSubAnnotationPropertyOfAxiom,
496
+ OWLAnnotationPropertyDomainAxiom,
497
+ OWLAnnotationPropertyRangeAxiom,
498
+ OWLFunctionalObjectPropertyAxiom,
499
+ OWLInverseFunctionalObjectPropertyAxiom,
500
+ OWLReflexiveObjectPropertyAxiom,
501
+ OWLIrreflexiveObjectPropertyAxiom,
502
+ OWLSymmetricObjectPropertyAxiom,
503
+ OWLAsymmetricObjectPropertyAxiom,
504
+ OWLTransitiveObjectPropertyAxiom,
505
+ OWLFunctionalDataPropertyAxiom,
506
+ OWLInverseObjectPropertiesAxiom
507
+ };