CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB Recovery Status: - Successfully recovered brainy.ts from compiled JavaScript - All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.) - Neural subsystem intact (562KB embedded patterns, NLP working) - Augmentation pipeline operational (20+ augmentations) - HNSW clustering system complete - Triple Intelligence compiled (needs constructor fix) - Test suite validates functionality Changes preserved: - 898 files with changes from last 3 days - 144,475 insertions - All augmentation improvements - All test coverage enhancements - Complete v3.0 feature set This is a LOCAL checkpoint only - contains recovered work after corruption incident. Created backup in .backups/brainy-full-20250910-151314.tar.gz Branch: recovery-checkpoint-20250910-151433 Date: Wed Sep 10 03:18:04 PM PDT 2025
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
/**
|
|
* Neural Entity Extractor using Brainy's NounTypes
|
|
* Uses embeddings and similarity matching for accurate type detection
|
|
*/
|
|
import { NounType } from '../types/graphTypes.js';
|
|
import { Vector } from '../coreTypes.js';
|
|
import type { Brainy } from '../brainy.js';
|
|
export interface ExtractedEntity {
|
|
text: string;
|
|
type: NounType;
|
|
position: {
|
|
start: number;
|
|
end: number;
|
|
};
|
|
confidence: number;
|
|
vector?: Vector;
|
|
metadata?: any;
|
|
}
|
|
export declare class NeuralEntityExtractor {
|
|
private brain;
|
|
private typeEmbeddings;
|
|
private initialized;
|
|
constructor(brain: Brainy | Brainy<any>);
|
|
/**
|
|
* Initialize type embeddings for neural matching
|
|
*/
|
|
private initializeTypeEmbeddings;
|
|
/**
|
|
* Extract entities from text using neural matching
|
|
*/
|
|
extract(text: string, options?: {
|
|
types?: NounType[];
|
|
confidence?: number;
|
|
includeVectors?: boolean;
|
|
neuralMatching?: boolean;
|
|
}): Promise<ExtractedEntity[]>;
|
|
/**
|
|
* Extract candidate entities using patterns
|
|
*/
|
|
private extractCandidates;
|
|
/**
|
|
* Get context-based confidence boost for type matching
|
|
*/
|
|
private getContextBoost;
|
|
/**
|
|
* Rule-based classification fallback
|
|
*/
|
|
private classifyByRules;
|
|
/**
|
|
* Get embedding for text
|
|
*/
|
|
private getEmbedding;
|
|
/**
|
|
* Calculate cosine similarity between vectors
|
|
*/
|
|
private cosineSimilarity;
|
|
/**
|
|
* Simple hash function for fallback
|
|
*/
|
|
private simpleHash;
|
|
/**
|
|
* Remove duplicate and overlapping entities
|
|
*/
|
|
private deduplicateEntities;
|
|
}
|