@soulcraft/brainy 1.5.0 → 2.0.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.
- package/CHANGELOG.md +188 -0
- package/LICENSE +2 -2
- package/README.md +201 -596
- package/bin/brainy-interactive.js +564 -0
- package/bin/brainy-ts.js +18 -0
- package/bin/brainy.js +672 -81
- package/dist/augmentationPipeline.d.ts +48 -220
- package/dist/augmentationPipeline.js +60 -508
- package/dist/augmentationRegistry.d.ts +22 -31
- package/dist/augmentationRegistry.js +28 -79
- package/dist/augmentations/apiServerAugmentation.d.ts +108 -0
- package/dist/augmentations/apiServerAugmentation.js +502 -0
- package/dist/augmentations/batchProcessingAugmentation.d.ts +95 -0
- package/dist/augmentations/batchProcessingAugmentation.js +567 -0
- package/dist/augmentations/brainyAugmentation.d.ts +153 -0
- package/dist/augmentations/brainyAugmentation.js +145 -0
- package/dist/augmentations/cacheAugmentation.d.ts +105 -0
- package/dist/augmentations/cacheAugmentation.js +238 -0
- package/dist/augmentations/conduitAugmentations.d.ts +54 -156
- package/dist/augmentations/conduitAugmentations.js +156 -1082
- package/dist/augmentations/connectionPoolAugmentation.d.ts +62 -0
- package/dist/augmentations/connectionPoolAugmentation.js +316 -0
- package/dist/augmentations/defaultAugmentations.d.ts +53 -0
- package/dist/augmentations/defaultAugmentations.js +88 -0
- package/dist/augmentations/entityRegistryAugmentation.d.ts +126 -0
- package/dist/augmentations/entityRegistryAugmentation.js +386 -0
- package/dist/augmentations/indexAugmentation.d.ts +117 -0
- package/dist/augmentations/indexAugmentation.js +284 -0
- package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +152 -0
- package/dist/augmentations/intelligentVerbScoringAugmentation.js +554 -0
- package/dist/augmentations/metricsAugmentation.d.ts +202 -0
- package/dist/augmentations/metricsAugmentation.js +291 -0
- package/dist/augmentations/monitoringAugmentation.d.ts +94 -0
- package/dist/augmentations/monitoringAugmentation.js +227 -0
- package/dist/augmentations/neuralImport.d.ts +50 -117
- package/dist/augmentations/neuralImport.js +255 -629
- package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +52 -0
- package/dist/augmentations/requestDeduplicatorAugmentation.js +162 -0
- package/dist/augmentations/serverSearchAugmentations.d.ts +43 -22
- package/dist/augmentations/serverSearchAugmentations.js +125 -72
- package/dist/augmentations/storageAugmentation.d.ts +54 -0
- package/dist/augmentations/storageAugmentation.js +93 -0
- package/dist/augmentations/storageAugmentations.d.ts +96 -0
- package/dist/augmentations/storageAugmentations.js +182 -0
- package/dist/augmentations/synapseAugmentation.d.ts +156 -0
- package/dist/augmentations/synapseAugmentation.js +312 -0
- package/dist/augmentations/walAugmentation.d.ts +108 -0
- package/dist/augmentations/walAugmentation.js +515 -0
- package/dist/brainyData.d.ts +404 -130
- package/dist/brainyData.js +1331 -853
- package/dist/chat/BrainyChat.d.ts +16 -8
- package/dist/chat/BrainyChat.js +60 -32
- package/dist/chat/ChatCLI.d.ts +1 -1
- package/dist/chat/ChatCLI.js +6 -6
- package/dist/cli/catalog.d.ts +3 -3
- package/dist/cli/catalog.js +116 -70
- package/dist/cli/commands/core.d.ts +61 -0
- package/dist/cli/commands/core.js +348 -0
- package/dist/cli/commands/neural.d.ts +25 -0
- package/dist/cli/commands/neural.js +508 -0
- package/dist/cli/commands/utility.d.ts +37 -0
- package/dist/cli/commands/utility.js +276 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +167 -0
- package/dist/cli/interactive.d.ts +164 -0
- package/dist/cli/interactive.js +542 -0
- package/dist/cortex/neuralImport.js +5 -5
- package/dist/critical/model-guardian.js +11 -4
- package/dist/embeddings/lightweight-embedder.d.ts +23 -0
- package/dist/embeddings/lightweight-embedder.js +136 -0
- package/dist/embeddings/universal-memory-manager.d.ts +38 -0
- package/dist/embeddings/universal-memory-manager.js +206 -0
- package/dist/embeddings/worker-embedding.d.ts +7 -0
- package/dist/embeddings/worker-embedding.js +77 -0
- package/dist/embeddings/worker-manager.d.ts +28 -0
- package/dist/embeddings/worker-manager.js +162 -0
- package/dist/examples/basicUsage.js +7 -7
- package/dist/graph/pathfinding.d.ts +78 -0
- package/dist/graph/pathfinding.js +393 -0
- package/dist/hnsw/hnswIndex.d.ts +13 -0
- package/dist/hnsw/hnswIndex.js +35 -0
- package/dist/hnsw/hnswIndexOptimized.d.ts +1 -0
- package/dist/hnsw/hnswIndexOptimized.js +3 -0
- package/dist/index.d.ts +9 -11
- package/dist/index.js +21 -11
- package/dist/indices/fieldIndex.d.ts +76 -0
- package/dist/indices/fieldIndex.js +357 -0
- package/dist/mcp/brainyMCPAdapter.js +3 -2
- package/dist/mcp/mcpAugmentationToolset.js +11 -17
- package/dist/neural/embeddedPatterns.d.ts +41 -0
- package/dist/neural/embeddedPatterns.js +4044 -0
- package/dist/neural/naturalLanguageProcessor.d.ts +94 -0
- package/dist/neural/naturalLanguageProcessor.js +317 -0
- package/dist/neural/naturalLanguageProcessorStatic.d.ts +64 -0
- package/dist/neural/naturalLanguageProcessorStatic.js +151 -0
- package/dist/neural/neuralAPI.d.ts +255 -0
- package/dist/neural/neuralAPI.js +612 -0
- package/dist/neural/patternLibrary.d.ts +101 -0
- package/dist/neural/patternLibrary.js +313 -0
- package/dist/neural/patterns.d.ts +27 -0
- package/dist/neural/patterns.js +68 -0
- package/dist/neural/staticPatternMatcher.d.ts +35 -0
- package/dist/neural/staticPatternMatcher.js +153 -0
- package/dist/scripts/precomputePatternEmbeddings.d.ts +19 -0
- package/dist/scripts/precomputePatternEmbeddings.js +100 -0
- package/dist/storage/adapters/fileSystemStorage.d.ts +5 -0
- package/dist/storage/adapters/fileSystemStorage.js +20 -0
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +5 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +16 -0
- package/dist/storage/enhancedClearOperations.d.ts +83 -0
- package/dist/storage/enhancedClearOperations.js +345 -0
- package/dist/storage/storageFactory.js +31 -27
- package/dist/triple/TripleIntelligence.d.ts +134 -0
- package/dist/triple/TripleIntelligence.js +548 -0
- package/dist/types/augmentations.d.ts +45 -344
- package/dist/types/augmentations.js +5 -2
- package/dist/types/brainyDataInterface.d.ts +20 -10
- package/dist/types/graphTypes.d.ts +46 -0
- package/dist/types/graphTypes.js +16 -2
- package/dist/utils/BoundedRegistry.d.ts +29 -0
- package/dist/utils/BoundedRegistry.js +54 -0
- package/dist/utils/embedding.js +20 -3
- package/dist/utils/hybridModelManager.js +10 -5
- package/dist/utils/metadataFilter.d.ts +33 -19
- package/dist/utils/metadataFilter.js +58 -23
- package/dist/utils/metadataIndex.d.ts +37 -6
- package/dist/utils/metadataIndex.js +427 -64
- package/dist/utils/requestDeduplicator.d.ts +10 -0
- package/dist/utils/requestDeduplicator.js +24 -0
- package/dist/utils/unifiedCache.d.ts +103 -0
- package/dist/utils/unifiedCache.js +311 -0
- package/package.json +43 -128
- package/scripts/ensure-models.js +108 -0
- package/scripts/prepare-models.js +387 -0
- package/OFFLINE_MODELS.md +0 -56
- package/dist/intelligence/neuralEngine.d.ts +0 -207
- package/dist/intelligence/neuralEngine.js +0 -706
- package/dist/utils/modelLoader.d.ts +0 -32
- package/dist/utils/modelLoader.js +0 -219
- package/dist/utils/modelManager.d.ts +0 -77
- package/dist/utils/modelManager.js +0 -219
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Index Augmentation - Optional Metadata Indexing
|
|
3
|
+
*
|
|
4
|
+
* Replaces the hardcoded MetadataIndex in BrainyData with an optional augmentation.
|
|
5
|
+
* Provides O(1) metadata filtering and field lookups.
|
|
6
|
+
*
|
|
7
|
+
* Zero-config: Automatically enabled for better search performance
|
|
8
|
+
* Can be disabled or customized via augmentation registry
|
|
9
|
+
*/
|
|
10
|
+
import { BaseAugmentation } from './brainyAugmentation.js';
|
|
11
|
+
import { MetadataIndexManager } from '../utils/metadataIndex.js';
|
|
12
|
+
/**
|
|
13
|
+
* IndexAugmentation - Makes metadata indexing optional and pluggable
|
|
14
|
+
*
|
|
15
|
+
* Features:
|
|
16
|
+
* - O(1) metadata field lookups
|
|
17
|
+
* - Fast pre-filtering for searches
|
|
18
|
+
* - Automatic index maintenance
|
|
19
|
+
* - Zero-config with smart defaults
|
|
20
|
+
*/
|
|
21
|
+
export class IndexAugmentation extends BaseAugmentation {
|
|
22
|
+
constructor(config = {}) {
|
|
23
|
+
super();
|
|
24
|
+
this.name = 'index';
|
|
25
|
+
this.timing = 'after';
|
|
26
|
+
this.operations = ['add', 'updateMetadata', 'delete', 'clear', 'all'];
|
|
27
|
+
this.priority = 60; // Run after data operations
|
|
28
|
+
this.metadataIndex = null;
|
|
29
|
+
this.flushTimer = null;
|
|
30
|
+
this.config = {
|
|
31
|
+
enabled: true,
|
|
32
|
+
maxFieldValues: 1000,
|
|
33
|
+
autoRebuild: true,
|
|
34
|
+
rebuildThreshold: 0.3, // Rebuild if 30% inconsistent
|
|
35
|
+
flushInterval: 30000, // Flush every 30 seconds
|
|
36
|
+
...config
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async onInitialize() {
|
|
40
|
+
if (!this.config.enabled) {
|
|
41
|
+
this.log('Index augmentation disabled by configuration');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Get storage from context
|
|
45
|
+
const storage = this.context?.storage;
|
|
46
|
+
if (!storage) {
|
|
47
|
+
this.log('No storage available, index augmentation inactive', 'warn');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Initialize metadata index
|
|
51
|
+
this.metadataIndex = new MetadataIndexManager(storage, {
|
|
52
|
+
maxIndexSize: this.config.maxIndexSize || 10000
|
|
53
|
+
});
|
|
54
|
+
// Check if we need to rebuild
|
|
55
|
+
if (this.config.autoRebuild) {
|
|
56
|
+
const stats = await this.metadataIndex.getStats();
|
|
57
|
+
if (stats.totalEntries === 0) {
|
|
58
|
+
// Check if storage has data but index is empty
|
|
59
|
+
try {
|
|
60
|
+
const storageStats = await storage.getStatistics?.();
|
|
61
|
+
if (storageStats && storageStats.totalNouns > 0) {
|
|
62
|
+
this.log('Rebuilding metadata index for existing data...');
|
|
63
|
+
await this.metadataIndex.rebuild();
|
|
64
|
+
const newStats = await this.metadataIndex.getStats();
|
|
65
|
+
this.log(`Index rebuilt: ${newStats.totalEntries} entries, ${newStats.fieldsIndexed.length} fields`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
this.log('Could not check storage statistics', 'info');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Start flush timer
|
|
74
|
+
if (this.config.flushInterval && this.config.flushInterval > 0) {
|
|
75
|
+
this.startFlushTimer();
|
|
76
|
+
}
|
|
77
|
+
this.log('Index augmentation initialized');
|
|
78
|
+
}
|
|
79
|
+
async onShutdown() {
|
|
80
|
+
// Stop flush timer
|
|
81
|
+
if (this.flushTimer) {
|
|
82
|
+
clearInterval(this.flushTimer);
|
|
83
|
+
this.flushTimer = null;
|
|
84
|
+
}
|
|
85
|
+
// Flush index one last time
|
|
86
|
+
if (this.metadataIndex) {
|
|
87
|
+
try {
|
|
88
|
+
await this.metadataIndex.flush();
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.log('Error flushing index during shutdown', 'warn');
|
|
92
|
+
}
|
|
93
|
+
this.metadataIndex = null;
|
|
94
|
+
}
|
|
95
|
+
this.log('Index augmentation shut down');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Execute augmentation - maintain index on data operations
|
|
99
|
+
*/
|
|
100
|
+
async execute(operation, params, next) {
|
|
101
|
+
// Execute the operation first
|
|
102
|
+
const result = await next();
|
|
103
|
+
// If index is disabled, just return
|
|
104
|
+
if (!this.metadataIndex || !this.config.enabled) {
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
// Handle index updates after operation completes
|
|
108
|
+
switch (operation) {
|
|
109
|
+
case 'add':
|
|
110
|
+
await this.handleAdd(params);
|
|
111
|
+
break;
|
|
112
|
+
case 'updateMetadata':
|
|
113
|
+
await this.handleUpdate(params);
|
|
114
|
+
break;
|
|
115
|
+
case 'delete':
|
|
116
|
+
await this.handleDelete(params);
|
|
117
|
+
break;
|
|
118
|
+
case 'clear':
|
|
119
|
+
await this.handleClear();
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Handle add operation - index new metadata
|
|
126
|
+
*/
|
|
127
|
+
async handleAdd(params) {
|
|
128
|
+
if (!this.metadataIndex)
|
|
129
|
+
return;
|
|
130
|
+
const { id, metadata } = params;
|
|
131
|
+
if (id && metadata) {
|
|
132
|
+
await this.metadataIndex.addToIndex(id, metadata);
|
|
133
|
+
this.log(`Indexed metadata for ${id}`, 'info');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Handle update operation - reindex metadata
|
|
138
|
+
*/
|
|
139
|
+
async handleUpdate(params) {
|
|
140
|
+
if (!this.metadataIndex)
|
|
141
|
+
return;
|
|
142
|
+
const { id, oldMetadata, newMetadata } = params;
|
|
143
|
+
// Remove old metadata
|
|
144
|
+
if (id && oldMetadata) {
|
|
145
|
+
await this.metadataIndex.removeFromIndex(id, oldMetadata);
|
|
146
|
+
}
|
|
147
|
+
// Add new metadata
|
|
148
|
+
if (id && newMetadata) {
|
|
149
|
+
await this.metadataIndex.addToIndex(id, newMetadata);
|
|
150
|
+
this.log(`Reindexed metadata for ${id}`, 'info');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Handle delete operation - remove from index
|
|
155
|
+
*/
|
|
156
|
+
async handleDelete(params) {
|
|
157
|
+
if (!this.metadataIndex)
|
|
158
|
+
return;
|
|
159
|
+
const { id, metadata } = params;
|
|
160
|
+
if (id && metadata) {
|
|
161
|
+
await this.metadataIndex.removeFromIndex(id, metadata);
|
|
162
|
+
this.log(`Removed ${id} from index`, 'info');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Handle clear operation - clear index
|
|
167
|
+
*/
|
|
168
|
+
async handleClear() {
|
|
169
|
+
if (!this.metadataIndex)
|
|
170
|
+
return;
|
|
171
|
+
// Clear the index when all data is cleared (rebuild effectively clears it)
|
|
172
|
+
await this.metadataIndex.rebuild();
|
|
173
|
+
this.log('Index cleared due to clear operation');
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Start periodic flush timer
|
|
177
|
+
*/
|
|
178
|
+
startFlushTimer() {
|
|
179
|
+
if (this.flushTimer)
|
|
180
|
+
return;
|
|
181
|
+
this.flushTimer = setInterval(async () => {
|
|
182
|
+
if (this.metadataIndex) {
|
|
183
|
+
try {
|
|
184
|
+
await this.metadataIndex.flush();
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
this.log('Error during periodic index flush', 'warn');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, this.config.flushInterval);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get IDs that match metadata filter (for pre-filtering)
|
|
194
|
+
*/
|
|
195
|
+
async getIdsForFilter(filter) {
|
|
196
|
+
if (!this.metadataIndex)
|
|
197
|
+
return [];
|
|
198
|
+
return this.metadataIndex.getIdsForFilter(filter);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get available values for a field
|
|
202
|
+
*/
|
|
203
|
+
async getFilterValues(field) {
|
|
204
|
+
if (!this.metadataIndex)
|
|
205
|
+
return [];
|
|
206
|
+
return this.metadataIndex.getFilterValues(field);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get all indexed fields
|
|
210
|
+
*/
|
|
211
|
+
async getFilterFields() {
|
|
212
|
+
if (!this.metadataIndex)
|
|
213
|
+
return [];
|
|
214
|
+
return this.metadataIndex.getFilterFields();
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get index statistics
|
|
218
|
+
*/
|
|
219
|
+
async getStats() {
|
|
220
|
+
if (!this.metadataIndex) {
|
|
221
|
+
return {
|
|
222
|
+
enabled: false,
|
|
223
|
+
totalEntries: 0,
|
|
224
|
+
fieldsIndexed: [],
|
|
225
|
+
memoryUsage: 0
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const stats = await this.metadataIndex.getStats();
|
|
229
|
+
return {
|
|
230
|
+
enabled: true,
|
|
231
|
+
...stats
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Rebuild the index from storage
|
|
236
|
+
*/
|
|
237
|
+
async rebuild() {
|
|
238
|
+
if (!this.metadataIndex) {
|
|
239
|
+
throw new Error('Index augmentation is not initialized');
|
|
240
|
+
}
|
|
241
|
+
this.log('Rebuilding metadata index...');
|
|
242
|
+
await this.metadataIndex.rebuild();
|
|
243
|
+
const stats = await this.metadataIndex.getStats();
|
|
244
|
+
this.log(`Index rebuilt: ${stats.totalEntries} entries, ${stats.fieldsIndexed.length} fields`);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Flush index to storage
|
|
248
|
+
*/
|
|
249
|
+
async flush() {
|
|
250
|
+
if (this.metadataIndex) {
|
|
251
|
+
await this.metadataIndex.flush();
|
|
252
|
+
this.log('Index flushed to storage', 'info');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Add entry to index (public method for direct access)
|
|
257
|
+
*/
|
|
258
|
+
async addToIndex(id, metadata) {
|
|
259
|
+
if (!this.metadataIndex)
|
|
260
|
+
return;
|
|
261
|
+
await this.metadataIndex.addToIndex(id, metadata);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Remove entry from index (public method for direct access)
|
|
265
|
+
*/
|
|
266
|
+
async removeFromIndex(id, metadata) {
|
|
267
|
+
if (!this.metadataIndex)
|
|
268
|
+
return;
|
|
269
|
+
await this.metadataIndex.removeFromIndex(id, metadata);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Get the underlying MetadataIndexManager instance
|
|
273
|
+
*/
|
|
274
|
+
getMetadataIndex() {
|
|
275
|
+
return this.metadataIndex;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Factory function for zero-config index augmentation
|
|
280
|
+
*/
|
|
281
|
+
export function createIndexAugmentation(config) {
|
|
282
|
+
return new IndexAugmentation(config);
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=indexAugmentation.js.map
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intelligent Verb Scoring Augmentation
|
|
3
|
+
*
|
|
4
|
+
* Enhances relationship quality through intelligent semantic scoring
|
|
5
|
+
* Provides context-aware relationship weights based on:
|
|
6
|
+
* - Semantic proximity of connected entities
|
|
7
|
+
* - Frequency-based amplification
|
|
8
|
+
* - Temporal decay modeling
|
|
9
|
+
* - Adaptive learning from usage patterns
|
|
10
|
+
*
|
|
11
|
+
* Critical for enterprise knowledge graphs with millions of relationships
|
|
12
|
+
*/
|
|
13
|
+
import { BaseAugmentation } from './brainyAugmentation.js';
|
|
14
|
+
interface VerbScoringConfig {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
enableSemanticScoring?: boolean;
|
|
17
|
+
semanticThreshold?: number;
|
|
18
|
+
semanticWeight?: number;
|
|
19
|
+
enableFrequencyAmplification?: boolean;
|
|
20
|
+
frequencyDecay?: number;
|
|
21
|
+
maxFrequencyBoost?: number;
|
|
22
|
+
enableTemporalDecay?: boolean;
|
|
23
|
+
temporalDecayRate?: number;
|
|
24
|
+
temporalWindow?: number;
|
|
25
|
+
enableAdaptiveLearning?: boolean;
|
|
26
|
+
learningRate?: number;
|
|
27
|
+
confidenceThreshold?: number;
|
|
28
|
+
minWeight?: number;
|
|
29
|
+
maxWeight?: number;
|
|
30
|
+
baseWeight?: number;
|
|
31
|
+
}
|
|
32
|
+
interface RelationshipMetrics {
|
|
33
|
+
count: number;
|
|
34
|
+
totalWeight: number;
|
|
35
|
+
averageWeight: number;
|
|
36
|
+
lastUpdated: number;
|
|
37
|
+
semanticScore: number;
|
|
38
|
+
frequencyScore: number;
|
|
39
|
+
temporalScore: number;
|
|
40
|
+
confidenceScore: number;
|
|
41
|
+
}
|
|
42
|
+
interface ScoringMetrics {
|
|
43
|
+
relationshipsScored: number;
|
|
44
|
+
averageSemanticScore: number;
|
|
45
|
+
averageFrequencyScore: number;
|
|
46
|
+
averageTemporalScore: number;
|
|
47
|
+
averageConfidenceScore: number;
|
|
48
|
+
adaptiveAdjustments: number;
|
|
49
|
+
computationTimeMs: number;
|
|
50
|
+
}
|
|
51
|
+
export declare class IntelligentVerbScoringAugmentation extends BaseAugmentation {
|
|
52
|
+
name: string;
|
|
53
|
+
timing: "around";
|
|
54
|
+
operations: ("addVerb" | "relate")[];
|
|
55
|
+
priority: number;
|
|
56
|
+
get enabled(): boolean;
|
|
57
|
+
private config;
|
|
58
|
+
private relationshipStats;
|
|
59
|
+
private metrics;
|
|
60
|
+
private scoringInstance;
|
|
61
|
+
constructor(config?: VerbScoringConfig);
|
|
62
|
+
protected onInitialize(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get this augmentation instance for API compatibility
|
|
65
|
+
* Used by BrainyData to access scoring methods
|
|
66
|
+
*/
|
|
67
|
+
getScoring(): IntelligentVerbScoringAugmentation;
|
|
68
|
+
shouldExecute(operation: string, params: any): boolean;
|
|
69
|
+
execute<T = any>(operation: string, params: any, next: () => Promise<T>): Promise<T>;
|
|
70
|
+
private calculateIntelligentWeight;
|
|
71
|
+
private calculateSemanticScore;
|
|
72
|
+
/**
|
|
73
|
+
* Detect noun type using neural taxonomy matching
|
|
74
|
+
*/
|
|
75
|
+
private detectNounType;
|
|
76
|
+
/**
|
|
77
|
+
* Calculate taxonomy-based similarity boost
|
|
78
|
+
*/
|
|
79
|
+
private calculateTaxonomyBoost;
|
|
80
|
+
private calculateCosineSimilarity;
|
|
81
|
+
private calculateFrequencyScore;
|
|
82
|
+
private calculateTemporalScore;
|
|
83
|
+
private calculateContextScore;
|
|
84
|
+
private updateRelationshipLearning;
|
|
85
|
+
private getConfidenceScore;
|
|
86
|
+
private getScoringMethodsUsed;
|
|
87
|
+
private storeDetailedScoring;
|
|
88
|
+
private updateMetrics;
|
|
89
|
+
/**
|
|
90
|
+
* Get intelligent verb scoring statistics
|
|
91
|
+
*/
|
|
92
|
+
getStats(): ScoringMetrics & {
|
|
93
|
+
totalRelationships: number;
|
|
94
|
+
averageConfidence: number;
|
|
95
|
+
highConfidenceRelationships: number;
|
|
96
|
+
learningEfficiency: number;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Export relationship statistics for analysis
|
|
100
|
+
*/
|
|
101
|
+
exportRelationshipStats(): Array<{
|
|
102
|
+
relationship: string;
|
|
103
|
+
metrics: RelationshipMetrics;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Import relationship statistics from previous sessions
|
|
107
|
+
*/
|
|
108
|
+
importRelationshipStats(stats: Array<{
|
|
109
|
+
relationship: string;
|
|
110
|
+
metrics: RelationshipMetrics;
|
|
111
|
+
}>): void;
|
|
112
|
+
/**
|
|
113
|
+
* Get learning statistics for monitoring and debugging
|
|
114
|
+
* Required for BrainyData.getVerbScoringStats()
|
|
115
|
+
*/
|
|
116
|
+
getLearningStats(): {
|
|
117
|
+
totalRelationships: number;
|
|
118
|
+
averageConfidence: number;
|
|
119
|
+
feedbackCount: number;
|
|
120
|
+
topRelationships: Array<{
|
|
121
|
+
relationship: string;
|
|
122
|
+
count: number;
|
|
123
|
+
averageWeight: number;
|
|
124
|
+
}>;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Export learning data for backup or analysis
|
|
128
|
+
* Required for BrainyData.exportVerbScoringLearningData()
|
|
129
|
+
*/
|
|
130
|
+
exportLearningData(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Import learning data from backup
|
|
133
|
+
* Required for BrainyData.importVerbScoringLearningData()
|
|
134
|
+
*/
|
|
135
|
+
importLearningData(jsonData: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Provide feedback on a relationship's weight
|
|
138
|
+
* Required for BrainyData.provideVerbScoringFeedback()
|
|
139
|
+
*/
|
|
140
|
+
provideFeedback(sourceId: string, targetId: string, relationType: string, feedback: number, feedbackType?: 'correction' | 'validation' | 'enhancement'): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Compute intelligent scores for a verb relationship
|
|
143
|
+
* Used internally during verb creation
|
|
144
|
+
*/
|
|
145
|
+
computeVerbScores(sourceNoun: any, targetNoun: any, relationType: string): Promise<{
|
|
146
|
+
weight: number;
|
|
147
|
+
confidence: number;
|
|
148
|
+
reasoning: string[];
|
|
149
|
+
}>;
|
|
150
|
+
protected onShutdown(): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
export {};
|