@unrdf/knowledge-engine 5.0.1 → 26.4.3
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.
- package/package.json +13 -7
- package/src/ai-enhanced-search.mjs +371 -0
- package/src/anomaly-detector.mjs +226 -0
- package/src/artifact-generator.mjs +251 -0
- package/src/browser.mjs +1 -1
- package/src/chatman/disruption-arithmetic.mjs +140 -0
- package/src/chatman/market-dynamics.mjs +140 -0
- package/src/chatman/organizational-dynamics.mjs +140 -0
- package/src/chatman/strategic-dynamics.mjs +140 -0
- package/src/chatman-config-loader.mjs +282 -0
- package/src/chatman-engine.mjs +431 -0
- package/src/chatman-operator.mjs +342 -0
- package/src/dark-field-detector.mjs +312 -0
- package/src/formation-theorems.mjs +345 -0
- package/src/index.mjs +20 -2
- package/src/knowledge-hook-manager.mjs +1 -1
- package/src/lockchain-writer-browser.mjs +2 -2
- package/src/observability.mjs +40 -4
- package/src/query-optimizer.mjs +1 -1
- package/src/resolution-layer.mjs +1 -1
- package/src/transaction.mjs +11 -9
- package/README.md +0 -84
- package/src/browser-shims.mjs +0 -343
- package/src/canonicalize.mjs +0 -414
- package/src/condition-cache.mjs +0 -109
- package/src/condition-evaluator.mjs +0 -722
- package/src/dark-matter-core.mjs +0 -742
- package/src/define-hook.mjs +0 -213
- package/src/effect-sandbox-browser.mjs +0 -283
- package/src/effect-sandbox-worker.mjs +0 -170
- package/src/effect-sandbox.mjs +0 -517
- package/src/engines/index.mjs +0 -11
- package/src/engines/rdf-engine.mjs +0 -299
- package/src/file-resolver.mjs +0 -387
- package/src/hook-executor-batching.mjs +0 -277
- package/src/hook-executor.mjs +0 -870
- package/src/hook-management.mjs +0 -150
- package/src/ken-parliment.mjs +0 -119
- package/src/ken.mjs +0 -149
- package/src/knowledge-engine/builtin-rules.mjs +0 -190
- package/src/knowledge-engine/inference-engine.mjs +0 -418
- package/src/knowledge-engine/knowledge-engine.mjs +0 -317
- package/src/knowledge-engine/pattern-dsl.mjs +0 -142
- package/src/knowledge-engine/pattern-matcher.mjs +0 -215
- package/src/knowledge-engine/rules.mjs +0 -184
- package/src/knowledge-engine.mjs +0 -319
- package/src/knowledge-hook-engine.mjs +0 -360
- package/src/knowledge-substrate-core.mjs +0 -927
- package/src/lite.mjs +0 -222
- package/src/lockchain-writer.mjs +0 -602
- package/src/monitoring/andon-signals.mjs +0 -775
- package/src/parse.mjs +0 -290
- package/src/performance-optimizer.mjs +0 -678
- package/src/policy-pack.mjs +0 -572
- package/src/query-cache.mjs +0 -116
- package/src/query.mjs +0 -306
- package/src/reason.mjs +0 -350
- package/src/schemas.mjs +0 -1063
- package/src/security/error-sanitizer.mjs +0 -257
- package/src/security/path-validator.mjs +0 -194
- package/src/security/sandbox-restrictions.mjs +0 -331
- package/src/security-validator.mjs +0 -389
- package/src/store-cache.mjs +0 -137
- package/src/telemetry.mjs +0 -167
- package/src/utils/adaptive-monitor.mjs +0 -746
- package/src/utils/circuit-breaker.mjs +0 -513
- package/src/utils/edge-case-handler.mjs +0 -503
- package/src/utils/memory-manager.mjs +0 -498
- package/src/utils/ring-buffer.mjs +0 -282
- package/src/validate.mjs +0 -319
- package/src/validators/index.mjs +0 -338
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Rule Definition and Compilation
|
|
3
|
-
* @module @unrdf/knowledge-engine/rules
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {import('n3').Quad} Quad
|
|
10
|
-
* @typedef {import('n3').Term} Term
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Rule pattern schema - describes what to match
|
|
15
|
-
*/
|
|
16
|
-
const PatternSchema = z.object({
|
|
17
|
-
subject: z.union([z.string(), z.object({ value: z.string() })]),
|
|
18
|
-
predicate: z.union([z.string(), z.object({ value: z.string() })]),
|
|
19
|
-
object: z.union([z.string(), z.object({ value: z.string() })]),
|
|
20
|
-
graph: z.union([z.string(), z.object({ value: z.string() })]).optional(),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Consequent schema - describes what to infer
|
|
25
|
-
*/
|
|
26
|
-
const ConsequentSchema = z.object({
|
|
27
|
-
subject: z.union([z.string(), z.object({ value: z.string() })]),
|
|
28
|
-
predicate: z.union([z.string(), z.object({ value: z.string() })]),
|
|
29
|
-
object: z.union([z.string(), z.object({ value: z.string() })]),
|
|
30
|
-
graph: z.union([z.string(), z.object({ value: z.string() })]).optional(),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Rule configuration schema
|
|
35
|
-
*/
|
|
36
|
-
const RuleConfigSchema = z.object({
|
|
37
|
-
name: z.string().min(1, 'Rule name is required'),
|
|
38
|
-
description: z.string().optional(),
|
|
39
|
-
pattern: z.union([PatternSchema, z.array(PatternSchema)]),
|
|
40
|
-
consequent: z.union([ConsequentSchema, z.array(ConsequentSchema)]),
|
|
41
|
-
salience: z.number().int().min(0).max(100).default(50),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* In-memory rule registry
|
|
46
|
-
*/
|
|
47
|
-
const ruleRegistry = new Map();
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Define an inference rule
|
|
51
|
-
*
|
|
52
|
-
* @param {Object} config - Rule configuration
|
|
53
|
-
* @param {string} config.name - Rule identifier
|
|
54
|
-
* @param {string} [config.description] - Rule description
|
|
55
|
-
* @param {Object|Object[]} config.pattern - SPARQL-like pattern to match
|
|
56
|
-
* @param {Object|Object[]} config.consequent - Quads to infer when pattern matches
|
|
57
|
-
* @param {number} [config.salience=50] - Priority (0-100, higher = earlier execution)
|
|
58
|
-
* @returns {Object} Compiled rule
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* const rule = defineRule({
|
|
62
|
-
* name: 'rdfs:subClassOf',
|
|
63
|
-
* pattern: [
|
|
64
|
-
* { subject: '?class', predicate: 'rdfs:subClassOf', object: '?superClass' },
|
|
65
|
-
* { subject: '?instance', predicate: 'rdf:type', object: '?class' }
|
|
66
|
-
* ],
|
|
67
|
-
* consequent: { subject: '?instance', predicate: 'rdf:type', object: '?superClass' },
|
|
68
|
-
* salience: 80
|
|
69
|
-
* });
|
|
70
|
-
*/
|
|
71
|
-
export function defineRule(config) {
|
|
72
|
-
const validated = RuleConfigSchema.parse(config);
|
|
73
|
-
|
|
74
|
-
const rule = {
|
|
75
|
-
name: validated.name,
|
|
76
|
-
description: validated.description || '',
|
|
77
|
-
pattern: Array.isArray(validated.pattern) ? validated.pattern : [validated.pattern],
|
|
78
|
-
consequent: Array.isArray(validated.consequent) ? validated.consequent : [validated.consequent],
|
|
79
|
-
salience: validated.salience,
|
|
80
|
-
compiled: false,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
ruleRegistry.set(rule.name, rule);
|
|
84
|
-
return rule;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Compile a rule for execution (prepare pattern matching)
|
|
89
|
-
*
|
|
90
|
-
* @param {Object} rule - Rule to compile
|
|
91
|
-
* @returns {Object} Compiled rule with pattern matchers
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* const rule = defineRule({ name: 'test', pattern: {...}, consequent: {...} });
|
|
95
|
-
* const compiled = compileRule(rule);
|
|
96
|
-
*/
|
|
97
|
-
export function compileRule(rule) {
|
|
98
|
-
if (rule.compiled) {
|
|
99
|
-
return rule;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const compiledPatterns = rule.pattern.map(p => ({
|
|
103
|
-
subject: normalizePattern(p.subject),
|
|
104
|
-
predicate: normalizePattern(p.predicate),
|
|
105
|
-
object: normalizePattern(p.object),
|
|
106
|
-
graph: p.graph ? normalizePattern(p.graph) : null,
|
|
107
|
-
}));
|
|
108
|
-
|
|
109
|
-
const compiledConsequents = rule.consequent.map(c => ({
|
|
110
|
-
subject: normalizePattern(c.subject),
|
|
111
|
-
predicate: normalizePattern(c.predicate),
|
|
112
|
-
object: normalizePattern(c.object),
|
|
113
|
-
graph: c.graph ? normalizePattern(c.graph) : null,
|
|
114
|
-
}));
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
...rule,
|
|
118
|
-
pattern: compiledPatterns,
|
|
119
|
-
consequent: compiledConsequents,
|
|
120
|
-
compiled: true,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Normalize a pattern element (convert strings to terms, detect variables)
|
|
126
|
-
*
|
|
127
|
-
* @param {string|Object} element - Pattern element
|
|
128
|
-
* @returns {Object} Normalized element with type and value
|
|
129
|
-
*/
|
|
130
|
-
function normalizePattern(element) {
|
|
131
|
-
if (typeof element === 'object' && element.value) {
|
|
132
|
-
return element;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const str = String(element);
|
|
136
|
-
|
|
137
|
-
if (str.startsWith('?')) {
|
|
138
|
-
return { type: 'variable', value: str };
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (str.startsWith('http://') || str.startsWith('https://')) {
|
|
142
|
-
return { type: 'namedNode', value: str };
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (str.includes(':')) {
|
|
146
|
-
return { type: 'prefixed', value: str };
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return { type: 'literal', value: str };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Retrieve a rule by name
|
|
154
|
-
*
|
|
155
|
-
* @param {string} name - Rule name
|
|
156
|
-
* @returns {Object|null} Rule or null if not found
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* const rule = getRule('rdfs:subClassOf');
|
|
160
|
-
*/
|
|
161
|
-
export function getRule(name) {
|
|
162
|
-
return ruleRegistry.get(name) || null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Get all registered rules
|
|
167
|
-
*
|
|
168
|
-
* @returns {Object[]} Array of all rules
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* const allRules = getAllRules();
|
|
172
|
-
*/
|
|
173
|
-
export function getAllRules() {
|
|
174
|
-
return Array.from(ruleRegistry.values());
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Clear all registered rules (useful for testing)
|
|
179
|
-
*
|
|
180
|
-
* @returns {void}
|
|
181
|
-
*/
|
|
182
|
-
export function clearRules() {
|
|
183
|
-
ruleRegistry.clear();
|
|
184
|
-
}
|
package/src/knowledge-engine.mjs
DELETED
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Main entry point for the Knowledge Engine.
|
|
3
|
-
* @module knowledge-engine
|
|
4
|
-
*
|
|
5
|
-
* A comprehensive RDF processing engine that provides:
|
|
6
|
-
* - Parsing and serialization (Turtle, N-Quads, JSON-LD)
|
|
7
|
-
* - SPARQL querying with Comunica
|
|
8
|
-
* - SHACL validation
|
|
9
|
-
* - N3 reasoning with eyereasoner
|
|
10
|
-
* - Canonicalization and isomorphism checks
|
|
11
|
-
* - Transaction management with hooks and receipts
|
|
12
|
-
*
|
|
13
|
-
* @version 1.0.0
|
|
14
|
-
* @license MIT
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// Core parsing and serialization
|
|
18
|
-
export {
|
|
19
|
-
parseTurtle,
|
|
20
|
-
toTurtle,
|
|
21
|
-
toNQuads,
|
|
22
|
-
parseJsonLd,
|
|
23
|
-
toJsonLd,
|
|
24
|
-
} from './knowledge-engine/parse.mjs';
|
|
25
|
-
|
|
26
|
-
// SPARQL querying
|
|
27
|
-
export {
|
|
28
|
-
query,
|
|
29
|
-
select,
|
|
30
|
-
ask,
|
|
31
|
-
construct,
|
|
32
|
-
describe,
|
|
33
|
-
update,
|
|
34
|
-
getQueryStats,
|
|
35
|
-
} from './knowledge-engine/query.mjs';
|
|
36
|
-
|
|
37
|
-
// SHACL validation
|
|
38
|
-
export {
|
|
39
|
-
validateShacl,
|
|
40
|
-
validateShaclMultiple,
|
|
41
|
-
formatValidationReport,
|
|
42
|
-
hasValidationErrors,
|
|
43
|
-
getValidationErrors,
|
|
44
|
-
getValidationWarnings,
|
|
45
|
-
} from './knowledge-engine/validate.mjs';
|
|
46
|
-
|
|
47
|
-
// N3 reasoning
|
|
48
|
-
export {
|
|
49
|
-
reason,
|
|
50
|
-
reasonMultiple,
|
|
51
|
-
extractInferred,
|
|
52
|
-
getReasoningStats,
|
|
53
|
-
validateRules,
|
|
54
|
-
createReasoningSession,
|
|
55
|
-
} from './knowledge-engine/reason.mjs';
|
|
56
|
-
|
|
57
|
-
// Canonicalization and isomorphism
|
|
58
|
-
export {
|
|
59
|
-
canonicalize,
|
|
60
|
-
isIsomorphic,
|
|
61
|
-
getCanonicalHash,
|
|
62
|
-
groupByIsomorphism,
|
|
63
|
-
findDuplicates,
|
|
64
|
-
getCanonicalizationStats,
|
|
65
|
-
createCanonicalizationSession,
|
|
66
|
-
} from './knowledge-engine/canonicalize.mjs';
|
|
67
|
-
|
|
68
|
-
// Transaction management
|
|
69
|
-
export { TransactionManager, printReceipt } from './knowledge-engine/transaction.mjs';
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Create a complete knowledge engine instance with all capabilities.
|
|
73
|
-
* @param {Object} [options] - Engine options
|
|
74
|
-
* @param {string} [options.baseIRI] - Base IRI for parsing
|
|
75
|
-
* @param {boolean} [options.strictMode] - Enable strict validation mode
|
|
76
|
-
* @param {number} [options.maxHooks] - Maximum number of transaction hooks
|
|
77
|
-
* @returns {Object} Knowledge engine instance
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* const engine = createKnowledgeEngine({
|
|
81
|
-
* baseIRI: 'http://example.org/',
|
|
82
|
-
* strictMode: true
|
|
83
|
-
* });
|
|
84
|
-
*
|
|
85
|
-
* // Parse data
|
|
86
|
-
* const store = await engine.parseTurtle(ttl);
|
|
87
|
-
*
|
|
88
|
-
* // Query data
|
|
89
|
-
* const results = await engine.query(store, 'SELECT ?s ?o WHERE { ?s ?p ?o }');
|
|
90
|
-
*
|
|
91
|
-
* // Validate data
|
|
92
|
-
* const report = engine.validateShacl(store, shapes);
|
|
93
|
-
*
|
|
94
|
-
* // Reason over data
|
|
95
|
-
* const reasoned = await engine.reason(store, rules);
|
|
96
|
-
*
|
|
97
|
-
* // Canonicalize data
|
|
98
|
-
* const canonical = await engine.canonicalize(store);
|
|
99
|
-
*
|
|
100
|
-
* // Manage transactions
|
|
101
|
-
* const tx = new engine.TransactionManager();
|
|
102
|
-
* const result = await tx.apply(store, delta);
|
|
103
|
-
*/
|
|
104
|
-
export function createKnowledgeEngine(options = {}) {
|
|
105
|
-
const { baseIRI = 'http://example.org/', strictMode = false, maxHooks = 100 } = options;
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
// Core options
|
|
109
|
-
baseIRI,
|
|
110
|
-
strictMode,
|
|
111
|
-
maxHooks,
|
|
112
|
-
|
|
113
|
-
// Parsing and serialization
|
|
114
|
-
async parseTurtle(ttl) {
|
|
115
|
-
const { parseTurtle } = await import('./knowledge-engine/parse.mjs');
|
|
116
|
-
return parseTurtle(ttl, baseIRI);
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
async toTurtle(store, options = {}) {
|
|
120
|
-
const { toTurtle } = await import('./knowledge-engine/parse.mjs');
|
|
121
|
-
return toTurtle(store, options);
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
async toNQuads(store, options = {}) {
|
|
125
|
-
const { toNQuads } = await import('./knowledge-engine/parse.mjs');
|
|
126
|
-
return toNQuads(store, options);
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
async parseJsonLd(jsonld, options = {}) {
|
|
130
|
-
const { parseJsonLd } = await import('./knowledge-engine/parse.mjs');
|
|
131
|
-
return parseJsonLd(jsonld, { baseIRI, ...options });
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
async toJsonLd(store, options = {}) {
|
|
135
|
-
const { toJsonLd } = await import('./knowledge-engine/parse.mjs');
|
|
136
|
-
return toJsonLd(store, options);
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
// SPARQL querying
|
|
140
|
-
async query(store, sparql, options = {}) {
|
|
141
|
-
const { query } = await import('./knowledge-engine/query.mjs');
|
|
142
|
-
return query(store, sparql, options);
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
async select(store, sparql, options = {}) {
|
|
146
|
-
const { select } = await import('./knowledge-engine/query.mjs');
|
|
147
|
-
return select(store, sparql, options);
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
async ask(store, sparql, options = {}) {
|
|
151
|
-
const { ask } = await import('./knowledge-engine/query.mjs');
|
|
152
|
-
return ask(store, sparql, options);
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
async construct(store, sparql, options = {}) {
|
|
156
|
-
const { construct } = await import('./knowledge-engine/query.mjs');
|
|
157
|
-
return construct(store, sparql, options);
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
async describe(store, sparql, options = {}) {
|
|
161
|
-
const { describe } = await import('./knowledge-engine/query.mjs');
|
|
162
|
-
return describe(store, sparql, options);
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
async update(store, sparql, options = {}) {
|
|
166
|
-
const { update } = await import('./knowledge-engine/query.mjs');
|
|
167
|
-
return update(store, sparql, options);
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
async getQueryStats(store, sparql, options = {}) {
|
|
171
|
-
const { getQueryStats } = await import('./knowledge-engine/query.mjs');
|
|
172
|
-
return getQueryStats(store, sparql, options);
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
// SHACL validation
|
|
176
|
-
async validateShacl(store, shapes, options = {}) {
|
|
177
|
-
const { validateShacl } = await import('./knowledge-engine/validate.mjs');
|
|
178
|
-
return validateShacl(store, shapes, options);
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
async validateShaclMultiple(store, shapesList, options = {}) {
|
|
182
|
-
const { validateShaclMultiple } = await import('./knowledge-engine/validate.mjs');
|
|
183
|
-
return validateShaclMultiple(store, shapesList, options);
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
async formatValidationReport(validationResult, options = {}) {
|
|
187
|
-
const { formatValidationReport } = await import('./knowledge-engine/validate.mjs');
|
|
188
|
-
return formatValidationReport(validationResult, options);
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
async hasValidationErrors(validationResult) {
|
|
192
|
-
const { hasValidationErrors } = await import('./knowledge-engine/validate.mjs');
|
|
193
|
-
return hasValidationErrors(validationResult);
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
async getValidationErrors(validationResult) {
|
|
197
|
-
const { getValidationErrors } = await import('./knowledge-engine/validate.mjs');
|
|
198
|
-
return getValidationErrors(validationResult);
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
async getValidationWarnings(validationResult) {
|
|
202
|
-
const { getValidationWarnings } = await import('./knowledge-engine/validate.mjs');
|
|
203
|
-
return getValidationWarnings(validationResult);
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
// N3 reasoning
|
|
207
|
-
async reason(store, rules, options = {}) {
|
|
208
|
-
const { reason } = await import('./knowledge-engine/reason.mjs');
|
|
209
|
-
return reason(store, rules, options);
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
async reasonMultiple(store, rulesList, options = {}) {
|
|
213
|
-
const { reasonMultiple } = await import('./knowledge-engine/reason.mjs');
|
|
214
|
-
return reasonMultiple(store, rulesList, options);
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
async extractInferred(originalStore, reasonedStore) {
|
|
218
|
-
const { extractInferred } = await import('./knowledge-engine/reason.mjs');
|
|
219
|
-
return extractInferred(originalStore, reasonedStore);
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
async getReasoningStats(originalStore, reasonedStore) {
|
|
223
|
-
const { getReasoningStats } = await import('./knowledge-engine/reason.mjs');
|
|
224
|
-
return getReasoningStats(originalStore, reasonedStore);
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
async validateRules(rules) {
|
|
228
|
-
const { validateRules } = await import('./knowledge-engine/reason.mjs');
|
|
229
|
-
return validateRules(rules);
|
|
230
|
-
},
|
|
231
|
-
|
|
232
|
-
async createReasoningSession(initialStore, rules, options = {}) {
|
|
233
|
-
const { createReasoningSession } = await import('./knowledge-engine/reason.mjs');
|
|
234
|
-
return createReasoningSession(initialStore, rules, options);
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
// Canonicalization and isomorphism
|
|
238
|
-
async canonicalize(store, options = {}) {
|
|
239
|
-
const { canonicalize } = await import('./knowledge-engine/canonicalize.mjs');
|
|
240
|
-
return canonicalize(store, options);
|
|
241
|
-
},
|
|
242
|
-
|
|
243
|
-
async isIsomorphic(storeA, storeB, options = {}) {
|
|
244
|
-
const { isIsomorphic } = await import('./knowledge-engine/canonicalize.mjs');
|
|
245
|
-
return isIsomorphic(storeA, storeB, options);
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
async getCanonicalHash(store, options = {}) {
|
|
249
|
-
const { getCanonicalHash } = await import('./knowledge-engine/canonicalize.mjs');
|
|
250
|
-
return getCanonicalHash(store, options);
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
async groupByIsomorphism(stores, options = {}) {
|
|
254
|
-
const { groupByIsomorphism } = await import('./knowledge-engine/canonicalize.mjs');
|
|
255
|
-
return groupByIsomorphism(stores, options);
|
|
256
|
-
},
|
|
257
|
-
|
|
258
|
-
async findDuplicates(stores, options = {}) {
|
|
259
|
-
const { findDuplicates } = await import('./knowledge-engine/canonicalize.mjs');
|
|
260
|
-
return findDuplicates(stores, options);
|
|
261
|
-
},
|
|
262
|
-
|
|
263
|
-
async getCanonicalizationStats(store, options = {}) {
|
|
264
|
-
const { getCanonicalizationStats } = await import('./knowledge-engine/canonicalize.mjs');
|
|
265
|
-
return getCanonicalizationStats(store, options);
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
async createCanonicalizationSession(options = {}) {
|
|
269
|
-
const { createCanonicalizationSession } = await import('./knowledge-engine/canonicalize.mjs');
|
|
270
|
-
return createCanonicalizationSession(options);
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
// Transaction management
|
|
274
|
-
async getTransactionManagerClass() {
|
|
275
|
-
const { TransactionManager } = await import('./knowledge-engine/transaction.mjs');
|
|
276
|
-
return TransactionManager;
|
|
277
|
-
},
|
|
278
|
-
|
|
279
|
-
async createTransactionManager(options = {}) {
|
|
280
|
-
const { TransactionManager } = await import('./knowledge-engine/transaction.mjs');
|
|
281
|
-
return new TransactionManager({
|
|
282
|
-
strictMode,
|
|
283
|
-
maxHooks,
|
|
284
|
-
...options,
|
|
285
|
-
});
|
|
286
|
-
},
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Utility function to create a simple knowledge engine with default settings.
|
|
292
|
-
* @param {string} [baseIRI] - Base IRI for parsing
|
|
293
|
-
* @returns {Object} Simple knowledge engine instance
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
* const engine = createSimpleEngine('http://example.org/');
|
|
297
|
-
* const store = await engine.parseTurtle(ttl);
|
|
298
|
-
* const results = await engine.query(store, 'SELECT * WHERE { ?s ?p ?o }');
|
|
299
|
-
*/
|
|
300
|
-
export function createSimpleEngine(baseIRI = 'http://example.org/') {
|
|
301
|
-
return createKnowledgeEngine({ baseIRI });
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Utility function to create a strict knowledge engine with validation enabled.
|
|
306
|
-
* @param {string} [baseIRI] - Base IRI for parsing
|
|
307
|
-
* @returns {Object} Strict knowledge engine instance
|
|
308
|
-
*
|
|
309
|
-
* @example
|
|
310
|
-
* const engine = createStrictEngine('http://example.org/');
|
|
311
|
-
* // All operations will use strict validation
|
|
312
|
-
*/
|
|
313
|
-
export function createStrictEngine(baseIRI = 'http://example.org/') {
|
|
314
|
-
return createKnowledgeEngine({
|
|
315
|
-
baseIRI,
|
|
316
|
-
strictMode: true,
|
|
317
|
-
maxHooks: 50,
|
|
318
|
-
});
|
|
319
|
-
}
|