@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,65 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.0] - 2026-09-12
8
+
9
+ First public release on npm as **`@skaterqiang/protege-js`**.
10
+
11
+ > The unscoped name `protege-js` is unavailable: npm's name-similarity rule
12
+ > rejects it because `protegejs` (an unrelated 2018 jQuery/Prototype.js shim)
13
+ > already exists. The package is scoped to keep authorship unambiguous; the
14
+ > GitHub repository keeps the shorter name `skaterqiang/protege-js`.
15
+
16
+ ### Added
17
+
18
+ - **OWL 2 model layer** — full structural spec coverage: 38 axiom types,
19
+ 26 class-expression kinds, entities, IRIs, literals, ontology container
20
+ with signature indexes, imports / versionIRI headers.
21
+ - **Parsers (6)** — RDF/XML, Turtle (W3C 1.1), OWL 2 Functional Syntax,
22
+ Manchester Syntax, OWL/XML, SWRL text.
23
+ - **Serializers (3)** — Turtle, Functional Syntax, RDF/XML; round-trip
24
+ verified (import → structure → export → re-import loses no axioms).
25
+ - **OWL 2 RL reasoner** — forward-chaining semi-naive materialization of all
26
+ 78 W3C rules (eq / prp / cls / cax / dt / scm), with inconsistency
27
+ detection (disjoint / functional violations).
28
+ - **OWL 2 QL / EL reasoners** — minimal engines over RL rule subsets.
29
+ - **SWRL reasoner** — forward chaining with 30+ built-ins (math / string /
30
+ comparison), sharing the same TripleStore.
31
+ - **Profile validators** — `checkRL` / `checkQL` / `checkEL` compliance
32
+ checks with violation lists; `GlobalRestrictionsValidator`.
33
+ - **ReasonerQueries** — `getSubClasses` / `getInstances` / `isSubClassOf` /
34
+ `isSatisfiable`.
35
+ - **OntologyLoader** — format auto-detection (extension + content sniffing)
36
+ and transitive `owl:imports` closure with cycle guard.
37
+ - **RDFGraphToOntology** — TripleStore → OWLOntology bridge.
38
+ - **Web UI** — zero-dependency Node HTTP server with a class / property
39
+ hierarchy tree browser; optional Electron desktop shell.
40
+ - **Public API entry** — `src/index.js` with flat and namespaced exports
41
+ (`model` / `io` / `inference` / `profiles`).
42
+ - **Tests** — 281 tests via `node:test`: core model, ≥1 test per OWL 2 RL
43
+ rule (80), full-spec suites, 10 end-to-end business cases
44
+ (incl. loading real BFO / OGMS / IAO / RO-core ontologies), and an
45
+ `exports`-map regression suite.
46
+
47
+ ### Fixed
48
+
49
+ - **Deep imports now resolve without the `.js` extension.** `exports` declared
50
+ `"./src/*": "./src/*"`, but Node performs *no* extension resolution for
51
+ subpath patterns — so `require('@skaterqiang/protege-js/src/model/IRI')`, the
52
+ spelling used in 31 of the 34 documented import examples, threw
53
+ `MODULE_NOT_FOUND` for real consumers. The map now carries two sibling pattern
54
+ keys (`"./src/*.js"` and `"./src/*" → "./src/*.js"`); Node's best-match rule
55
+ picks the more specific key by suffix length, so both spellings resolve to the
56
+ same module.
57
+
58
+ The existing suite could not catch this: every other test `require`s siblings
59
+ by *relative* path, which bypasses `exports` and falls back to legacy CommonJS
60
+ resolution (where `.js` *is* appended). `test/exports-map.test.js` closes the
61
+ gap by resolving the package through its own name (Node self-reference) and by
62
+ **scraping README.md and docs/API.md for every documented import specifier**,
63
+ so the tests can never drift from the docs again.
64
+
65
+ [0.1.0]: https://github.com/skaterqiang/protege-js/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,48 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2026, skaterqiang
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ ---
28
+
29
+ Acknowledgements
30
+ ----------------
31
+
32
+ protege-js (published on npm as @skaterqiang/protege-js) is an independent
33
+ Node.js reimplementation of the non-UI core of Protégé
34
+ (https://protege.stanford.edu/), which is developed by the Stanford Center for
35
+ Biomedical Informatics Research and distributed under the BSD 2-Clause license
36
+ (Copyright (c) 2014, The Board of Trustees of Leland Stanford Junior
37
+ University). protege-js is not affiliated with, endorsed by, or sponsored by
38
+ Stanford University or the Protégé team. "Protégé" is a trademark of Stanford
39
+ University; the name "protege-js" is used for descriptive purposes only.
40
+
41
+ The OWL 2 RL rule set implements the W3C recommendation:
42
+ OWL 2 Web Ontology Language Profiles (Second Edition)
43
+ https://www.w3.org/TR/owl2-profiles/
44
+ Copyright (c) W3C (MIT, ERCIM, Keio, Beihang).
45
+
46
+ Sample ontologies under sample/ontologies/ (BFO, OGMS, IAO, RO-core) are
47
+ redistributed from the OBO Foundry under CC-BY 4.0 / CC0 1.0; see
48
+ sample/README.md for sources and attribution.
package/README.md ADDED
@@ -0,0 +1,287 @@
1
+ # Protégé JS
2
+
3
+ A zero-dependency **OWL 2 / RDF / SWRL** library for Node.js — 6 parsers,
4
+ 3 round-trip serializers, and a forward-chaining reasoner covering **all 78
5
+ W3C OWL 2 RL rules** plus QL / EL profiles.
6
+
7
+ [![CI](https://github.com/skaterqiang/protege-js/actions/workflows/ci.yml/badge.svg)](https://github.com/skaterqiang/protege-js/actions/workflows/ci.yml)
8
+ [![tests](https://img.shields.io/badge/tests-281%20passing-brightgreen)](https://github.com/skaterqiang/protege-js)
9
+ [![license](https://img.shields.io/badge/license-BSD--2--Clause-blue)](./LICENSE)
10
+ [![node](https://img.shields.io/badge/node-%3E%3D18-green)](https://nodejs.org)
11
+ [![dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](./package.json)
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @skaterqiang/protege-js
17
+ ```
18
+
19
+ ```js
20
+ // Flat imports
21
+ const { OWL2RLReasoner, TripleStore, TurtleParser, checkRL } = require('@skaterqiang/protege-js');
22
+
23
+ // Or namespaced
24
+ const protege = require('@skaterqiang/protege-js');
25
+ protege.inference.OWL2RLReasoner; // reasoners, triple store, queries
26
+ protege.io.TurtleParser; // parsers + writers + loader
27
+ protege.model.OWLClass; // entities, axioms, class expressions
28
+ protege.profiles.checkRL; // RL / QL / EL profile validators
29
+
30
+ // Deep imports also work
31
+ const { OWL2RLReasoner } = require('@skaterqiang/protege-js/src/inference/OWL2RLReasoner');
32
+ ```
33
+
34
+ > **Why the scoped name?** The unscoped name `protege-js` is rejected by npm's
35
+ > name-similarity rule because [`protegejs`](https://www.npmjs.com/package/protegejs)
36
+ > already exists — an unrelated 2018 jQuery/Prototype.js shim that happens to
37
+ > share the French word *protégé*. This package is scoped to make authorship
38
+ > unambiguous, which is exactly what npm's
39
+ > [package name guidelines](https://docs.npmjs.com/package-name-guidelines) ask
40
+ > for. The GitHub repository keeps the shorter name:
41
+ > [skaterqiang/protege-js](https://github.com/skaterqiang/protege-js).
42
+
43
+ Full API reference: [docs/API.md](docs/API.md).
44
+
45
+ ## What this is
46
+
47
+ Protégé is a large Java/Swing application (~1498 files; ~1205 are Swing UI). This
48
+ project ports the **non-UI core** to Node.js and presents it through a web UI
49
+ served by Node, which can be wrapped in an Electron desktop window.
50
+
51
+ Only the *model layer* is reimplemented — the part that is genuinely useful in
52
+ Node.js and reusable by other projects (such as Synapse). Swing views, OSGi plugin
53
+ plumbing, and the Java desktop workspace are intentionally **not** ported.
54
+
55
+ > **Attribution**: protege-js is an independent reimplementation and is **not
56
+ > affiliated with or endorsed by Stanford University or the Protégé team**.
57
+ > Protégé is a trademark of Stanford University; the name is used for
58
+ > descriptive purposes only. See [LICENSE](./LICENSE) for details. Sample
59
+ > ontologies under `sample/ontologies/` (BFO / OGMS / IAO / RO-core) come from
60
+ > the OBO Foundry under CC-BY 4.0 / CC0 1.0 — see [sample/README.md](sample/README.md).
61
+
62
+ ## Run
63
+
64
+ ```bash
65
+ # As a library (no server needed):
66
+ node -e "const {TurtleParser}=require('@skaterqiang/protege-js'); console.log(new TurtleParser().parse('@prefix ex: <http://e.org/> . ex:a ex:p ex:b .').size)"
67
+
68
+ # Web UI only (no Electron dependency needed):
69
+ npm run start:web
70
+ # then open http://localhost:8899/
71
+
72
+ # Desktop (requires electron, `npm install` first):
73
+ npm start
74
+ ```
75
+
76
+ ## Test
77
+
78
+ ```bash
79
+ npm test # 281 tests: core model + 80 OWL 2 RL rule tests + OWL 2 full-spec + 业务案例 e2e + exports map
80
+ ```
81
+
82
+ ## OWL 2 全覆盖
83
+
84
+ 完整覆盖 W3C OWL 2 规范,包括:
85
+
86
+ - **OWL 2 RL 推理**:78 条规则前向链接物化(见下文)
87
+ - **OWL 2 QL / EL 推理**:基于 RL 规则子集的最小推理机(`OWL2QLReasoner` / `OWL2ELReasoner`)
88
+ - **OWL 2 全结构规范**:38 种公理类型、26 种类表达式、SWRL 规则
89
+ - **解析器**:Functional Syntax、Turtle、RDF/XML、Manchester Syntax、OWL/XML
90
+ - **序列化器**:Functional Syntax、Turtle、RDF/XML
91
+ - **桥接**:RDFGraphToOntology(TripleStore → OWLOntology)、OntologyLoader(含 imports 闭包)
92
+ - **验证**:OWL2Profiles(RL/QL/EL profile 检查)、GlobalRestrictionsValidator
93
+ - **查询**:ReasonerQueries(getSubClasses / getInstances / isSubClassOf / isSatisfiable)
94
+ - **SWRL**:模型 + 解析器 + 求值器(含长尾 builtins)
95
+ - 详见 [docs/design/OWL2-缺口分析.md](docs/design/OWL2-缺口分析.md)(全部缺口已实施完成)
96
+
97
+ ## OWL 2 RL inference engine
98
+
99
+ A forward-chaining, semi-naive materialization engine covering **all 78 rules**
100
+ of the [OWL 2 RL profile](https://www.w3.org/TR/owl2-profiles/) (6 categories:
101
+ eq / prp / cls / cax / dt / scm). See [docs/owl2-rl/OWL2-RL-规则细则.md](docs/owl2-rl/OWL2-RL-规则细则.md)
102
+ for the full rule list with W3C references, and [docs/owl2-rl/owl2-profiles-spec.html](docs/owl2-rl/owl2-profiles-spec.html)
103
+ for the original W3C specification snapshot.
104
+
105
+ ```js
106
+ const { OWL2RLReasoner } = require('./src/inference/OWL2RLReasoner');
107
+ const r = new OWL2RLReasoner();
108
+ r.store.add('ex:A', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'ex:B');
109
+ r.store.add('ex:x', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'ex:A');
110
+ r.materialize(); // runs all 78 rules to fixpoint
111
+ r.entails('ex:x', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'ex:B'); // true
112
+ r.isConsistent(); // true / false (false-consequent rules)
113
+ ```
114
+
115
+ Files:
116
+
117
+ ```
118
+ src/inference/
119
+ TripleStore.js triple store with pattern matching + RDF-list walker
120
+ rdf.js namespace constants + literal helpers
121
+ OWL2RLReasoner.js fixpoint engine, inconsistency collector
122
+ rules/owl2rl.js the 78 OWL 2 RL rules
123
+ test/owl2rl/ 80 rule tests (>=1 per rule)
124
+ docs/owl2-rl/ W3C spec snapshot + rule catalog + Chinese细则
125
+ ```
126
+
127
+ ## OWL 2 full structural spec
128
+
129
+ Beyond the RL profile, the model layer covers the complete
130
+ [OWL 2 structural specification](https://www.w3.org/TR/owl2-syntax/):
131
+
132
+ - **38 axiom types** (every axiom in the spec): declaration, subclass, equivalent/disjoint
133
+ classes, disjoint union, property hierarchy (sub/equivalent/disjoint/inverse/chain),
134
+ property domain/range, all 7 object-property characteristics (functional,
135
+ inverse-functional, reflexive, irreflexive, symmetric, asymmetric, transitive),
136
+ functional data property, datatype definition, has-key, same/different individuals,
137
+ class/object/data property assertion (positive + negative), annotation assertion,
138
+ annotation property hierarchy + domain/range.
139
+ - **26 class expression kinds**, object and data sides: intersection, union,
140
+ complement, one-of, some/all/has-value/has-self, min/max/exact cardinality
141
+ (qualified and unqualified), data intersection/union/complement/one-of,
142
+ datatype restriction with facets.
143
+ - **SWRL rules** with class/object/data property atoms, sameAs/differentFrom
144
+ atoms, and 30+ built-ins (math, string, comparison). Forward-chaining
145
+ materialization over the same TripleStore used by OWL 2 RL.
146
+
147
+ ## Parsers
148
+
149
+ Five syntax parsers:
150
+
151
+ - **RDF/XML** — [src/io/RDFXMLParser.js](src/io/RDFXMLParser.js): classic OWL/XML,
152
+ extended to recognize disjointWith, inverseOf, sameAs, differentFrom, all
153
+ 7 property characteristics, nested class expressions (owl:Restriction /
154
+ intersectionOf / unionOf / ...), `owl:hasKey`, anonymous individuals and punning.
155
+ - **Turtle** — [src/io/TurtleParser.js](src/io/TurtleParser.js): W3C Turtle 1.1 with
156
+ `@prefix`/`@base`, SPARQL `PREFIX`/`BASE`, typed/lang literals, blank nodes,
157
+ collections, auto-typed numbers/booleans.
158
+ - **OWL 2 Functional-Style** — [src/io/FunctionalSyntaxParser.js](src/io/FunctionalSyntaxParser.js):
159
+ parses the complete functional syntax including `Prefix(...)`, `Ontology(...)`
160
+ (with imports / versionIRI), all 38 axiom forms, and all class expressions /
161
+ data ranges.
162
+ - **Manchester Syntax** — [src/io/ManchesterSyntaxParser.js](src/io/ManchesterSyntaxParser.js).
163
+ - **OWL/XML** — [src/io/OWLXMLParser.js](src/io/OWLXMLParser.js).
164
+ - **SWRL text** — [src/io/SWRLParser.js](src/io/SWRLParser.js).
165
+
166
+ ## Serializers (writers)
167
+
168
+ - **Turtle** — [src/io/TurtleWriter.js](src/io/TurtleWriter.js)
169
+ - **OWL 2 Functional-Style** — [src/io/FunctionalSyntaxWriter.js](src/io/FunctionalSyntaxWriter.js)
170
+ - **RDF/XML** — [src/io/RDFXMLWriter.js](src/io/RDFXMLWriter.js)
171
+
172
+ All three writers round-trip: Turtle/Functional/RDF/XML 导入 → 结构化 → 导出 →
173
+ 再导入不丢公理(见 sample/case4、case6、case7)。
174
+
175
+ ```js
176
+ const { TurtleParser } = require('./src/io/TurtleParser');
177
+ const { FunctionalSyntaxParser } = require('./src/io/FunctionalSyntaxParser');
178
+ const { SWRLReasoner } = require('./src/inference/SWRLReasoner');
179
+
180
+ const store = new TurtleParser().parse(`
181
+ @prefix ex: <http://example.org/> .
182
+ ex:alice a ex:Person ; ex:age 30 .
183
+ `);
184
+
185
+ const onto = new FunctionalSyntaxParser().parse(`
186
+ Prefix(ex:=<http://example.org/>)
187
+ Ontology( Declaration(Class(ex:Person)) )
188
+ `);
189
+ ```
190
+
191
+ ## Architecture
192
+
193
+ ```
194
+ main.js Electron shell (falls back to headless web server)
195
+ src/
196
+ index.js public API entry (flat + namespaced exports)
197
+ model/ org.protege.editor.owl.model equivalents
198
+ IRI.js org.semanticweb.owlapi.model.IRI
199
+ OWLEntity.js OWLClass / OWLObjectProperty / OWLDataProperty /
200
+ OWLNamedIndividual / OWLDatatype / OWLAnnotationProperty
201
+ OWLAxiom.js OWLSubClassOfAxiom, OWLDeclarationAxiom, domain/range,
202
+ class/property assertions, annotation assertions, ...
203
+ OWLClassExpression.js anonymous expressions: intersection/union/some/only/...
204
+ OWLLiteral.js org.semanticweb.owlapi.model.OWLLiteral
205
+ OWLOntology.js OWLOntology + OWLOntologyID (in-memory axiom set)
206
+ OWLModelManager.js OWLModelManager / OWLModelManagerImpl
207
+ SWRL.js SWRLRule + class/object/data property/builtin atoms
208
+ event/
209
+ OWLModelManagerEvent.js model.event.EventType + OWLModelManagerChangeEvent
210
+ hierarchy/
211
+ HierarchyProvider.js AssertedClassHierarchyProvider,
212
+ OWLObject/DataPropertyHierarchyProvider
213
+ io/
214
+ RDFXMLParser.js dependency-free RDF/XML reader (typed-node + Description style)
215
+ RDFXMLWriter.js RDF/XML serializer
216
+ TurtleParser.js W3C Turtle 1.1 reader
217
+ TurtleWriter.js Turtle serializer
218
+ FunctionalSyntaxParser.js OWL 2 functional-style reader
219
+ FunctionalSyntaxWriter.js functional-style serializer
220
+ ManchesterSyntaxParser.js Manchester Syntax reader
221
+ OWLXMLParser.js OWL/XML reader
222
+ SWRLParser.js SWRL text rule reader
223
+ RDFGraphToOntology.js TripleStore → OWLOntology bridge
224
+ OntologyLoader.js model.io.OntologyLoader (imports closure)
225
+ inference/
226
+ TripleStore.js triple store with pattern matching + RDF-list walker
227
+ rdf.js namespace constants + literal helpers
228
+ OWL2RLReasoner.js fixpoint engine, inconsistency collector (78 rules)
229
+ rules/owl2rl.js the 78 OWL 2 RL rules (eq / prp / cls / cax / dt / scm)
230
+ OWL2ProfileReasoners.js OWL2QLReasoner / OWL2ELReasoner (RL-rule subsets)
231
+ SWRLReasoner.js SWRL forward-chaining engine (30+ builtins)
232
+ ReasonerQueries.js getSubClasses / getInstances / isSubClassOf / isSatisfiable
233
+ profiles/
234
+ OWL2Profiles.js OWL 2 RL / QL / EL profile validators
235
+ validation/
236
+ GlobalRestrictionsValidator.js global-restriction checks
237
+ server/
238
+ webServer.js Node http server + JSON API (/api/load, /api/tree, /api/stats)
239
+ public/ web UI (class/property hierarchy tree browser)
240
+ test/
241
+ core.test.js node:test unit tests (model layer)
242
+ owl2rl/ 80 rule tests (>=1 per OWL 2 RL rule)
243
+ owl2/ full-spec tests: axioms / class expressions / parsers /
244
+ writers / profiles / reasoner queries / sample e2e
245
+ sample/ 10 个真实业务案例 + ontologies/ 真实公开本体
246
+ (BFO / OGMS / RO-core / IAO, OBO Foundry 官方 PURL)
247
+ ```
248
+
249
+ ## Java → JS mapping notes
250
+
251
+ | Protégé / OWLAPI (Java) | protege-js (Node) |
252
+ |------------------------------------------|--------------------------------------------|
253
+ | `org.semanticweb.owlapi.model.IRI` | `src/model/IRI.js` |
254
+ | `OWLEntity` hierarchy | `src/model/OWLEntity.js` |
255
+ | `OWLAxiom` hierarchy | `src/model/OWLAxiom.js` |
256
+ | `OWLClassExpression` | `src/model/OWLClassExpression.js` |
257
+ | `OWLOntology` / `OWLOntologyID` | `src/model/OWLOntology.js` |
258
+ | `OWLModelManager(Impl)` | `src/model/OWLModelManager.js` |
259
+ | `model.event.EventType` | `src/model/event/OWLModelManagerEvent.js` |
260
+ | `model.hierarchy.*HierarchyProvider` | `src/model/hierarchy/HierarchyProvider.js` |
261
+ | `model.io.OntologyLoader` + RDF/XML | `src/io/OntologyLoader.js`, `RDFXMLParser.js` |
262
+ | `OWLReasoner` (RL/QL/EL) | `src/inference/OWL2RLReasoner.js`, `OWL2ProfileReasoners.js` |
263
+ | `OWLReasoner` query API | `src/inference/ReasonerQueries.js` |
264
+ | `OWL2Profile` validators | `src/profiles/OWL2Profiles.js` |
265
+
266
+ ## Scope
267
+
268
+ Implemented:
269
+
270
+ - Entities, IRIs, literals, class expressions (26 kinds), full 38-axiom model
271
+ - Ontology container + signature indexes + ontology headers (imports / versionIRI)
272
+ - Asserted class / object property / data property hierarchy providers + tree JSON
273
+ - Parsers: RDF/XML, Turtle, Functional Syntax, Manchester Syntax, OWL/XML, SWRL
274
+ - Serializers: RDF/XML, Turtle, Functional Syntax (round-trip verified)
275
+ - Inference: OWL 2 RL (all 78 rules), OWL 2 QL / EL, SWRL forward-chaining,
276
+ inconsistency detection (disjoint / functional violations)
277
+ - Validation: OWL 2 RL/QL/EL profile checkers, global-restriction validator
278
+ - Query: ReasonerQueries (getSubClasses / getInstances / isSubClassOf / isSatisfiable)
279
+ - RDFGraphToOntology bridge, OntologyLoader with imports closure
280
+ - Web UI tree browser (Classes / Object Properties / Data Properties tabs)
281
+ - 10 个端到端业务案例(电商风控 / 医疗用药 / 制造 PPR / 真实 BFO-OGMS-IAO 加载 / ...)
282
+
283
+ Not implemented (out of scope for the Node core):
284
+
285
+ - Tableau-based DL reasoning (HermiT/Pellet/Openllet) — 仅提供规则式 RL/QL/EL 推理
286
+ - Editing operations, refactoring, search-importer, git integration
287
+ - Swing workspace / views / OSGi plugin system