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
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
/**
|
|
* 🧠 Natural Language Query Processor - STATIC VERSION
|
|
* No runtime initialization, no memory leaks, patterns pre-built at compile time
|
|
*
|
|
* Uses static pattern matching with 220 pre-built patterns
|
|
*/
|
|
import { Vector } from '../coreTypes.js';
|
|
import { TripleQuery } from '../triple/TripleIntelligence.js';
|
|
export interface NaturalQueryIntent {
|
|
type: 'vector' | 'field' | 'graph' | 'combined';
|
|
confidence: number;
|
|
extractedTerms: {
|
|
entities?: string[];
|
|
fields?: string[];
|
|
relationships?: string[];
|
|
modifiers?: string[];
|
|
};
|
|
}
|
|
export declare class NaturalLanguageProcessor {
|
|
private queryHistory;
|
|
constructor();
|
|
/**
|
|
* No initialization needed - patterns are pre-built!
|
|
*/
|
|
init(): Promise<void>;
|
|
/**
|
|
* Process natural language query into structured Triple Intelligence query
|
|
* @param naturalQuery The natural language query string
|
|
* @param queryEmbedding Pre-computed embedding from Brainy (passed in to avoid circular dependency)
|
|
*/
|
|
processNaturalQuery(naturalQuery: string, queryEmbedding?: Vector): Promise<TripleQuery>;
|
|
/**
|
|
* Analyze query intent using keywords
|
|
*/
|
|
private analyzeIntent;
|
|
/**
|
|
* Extract field terms from query
|
|
*/
|
|
private extractFieldTerms;
|
|
/**
|
|
* Extract relationship terms
|
|
*/
|
|
private extractRelationshipTerms;
|
|
/**
|
|
* Build field constraints from extracted terms
|
|
*/
|
|
private buildFieldConstraints;
|
|
/**
|
|
* Find similar queries from history (without using Brainy)
|
|
*/
|
|
private findSimilarQueries;
|
|
/**
|
|
* Adapt a previous query for new input
|
|
*/
|
|
private adaptQuery;
|
|
/**
|
|
* Extract entities from query
|
|
*/
|
|
private extractEntities;
|
|
/**
|
|
* Build query from components
|
|
*/
|
|
private buildQuery;
|
|
}
|