chore: recovery checkpoint - v3.0 API successfully recovered
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
This commit is contained in:
parent
f65455fb22
commit
8ff382ca3b
895 changed files with 143654 additions and 28268 deletions
185
.recovery-workspace/dist-backup-20250910-141917/neural/naturalLanguageProcessor.d.ts
vendored
Normal file
185
.recovery-workspace/dist-backup-20250910-141917/neural/naturalLanguageProcessor.d.ts
vendored
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
/**
|
||||
* 🧠 Natural Language Query Processor
|
||||
* Auto-breaks down natural language into structured Triple Intelligence queries
|
||||
*
|
||||
* Uses all of Brainy's sophisticated features:
|
||||
* - Embedding model for semantic understanding
|
||||
* - Pattern library with 100+ research-based patterns
|
||||
* - Entity Registry for concept mapping
|
||||
* - Progressive learning from usage
|
||||
*/
|
||||
import { TripleQuery } from '../triple/TripleIntelligence.js';
|
||||
import { Brainy } from '../brainy.js';
|
||||
export interface NaturalQueryIntent {
|
||||
type: 'vector' | 'field' | 'graph' | 'combined';
|
||||
primaryIntent: 'search' | 'filter' | 'aggregate' | 'navigate' | 'compare' | 'explain';
|
||||
confidence: number;
|
||||
extractedTerms: {
|
||||
searchTerms?: string[];
|
||||
fields?: Record<string, any>;
|
||||
connections?: {
|
||||
entities: string[];
|
||||
relationships: string[];
|
||||
};
|
||||
filters?: Record<string, any>;
|
||||
modifiers?: {
|
||||
recent?: boolean;
|
||||
popular?: boolean;
|
||||
limit?: number;
|
||||
boost?: string;
|
||||
sortBy?: string;
|
||||
groupBy?: string;
|
||||
};
|
||||
};
|
||||
context?: {
|
||||
domain?: string;
|
||||
temporalScope?: 'past' | 'present' | 'future' | 'all';
|
||||
complexity?: 'simple' | 'moderate' | 'complex';
|
||||
};
|
||||
}
|
||||
export declare class NaturalLanguageProcessor {
|
||||
private brain;
|
||||
private patternLibrary;
|
||||
private queryHistory;
|
||||
private initialized;
|
||||
private embeddingCache;
|
||||
constructor(brain: Brainy);
|
||||
/**
|
||||
* Get embedding using add/get/delete pattern
|
||||
*/
|
||||
private getEmbedding;
|
||||
/**
|
||||
* Initialize the pattern library (lazy loading)
|
||||
*/
|
||||
private ensureInitialized;
|
||||
/**
|
||||
* 🎯 MAIN METHOD: Convert natural language to Triple Intelligence query
|
||||
*/
|
||||
processNaturalQuery(naturalQuery: string): Promise<TripleQuery>;
|
||||
/**
|
||||
* Hybrid parse when pattern matching fails
|
||||
*/
|
||||
private hybridParse;
|
||||
/**
|
||||
* Analyze intent using keywords and structure with enhanced classification
|
||||
*/
|
||||
private analyzeIntent;
|
||||
/**
|
||||
* Detect the domain of the query
|
||||
*/
|
||||
private detectDomain;
|
||||
/**
|
||||
* Detect temporal scope in query
|
||||
*/
|
||||
private detectTemporalScope;
|
||||
/**
|
||||
* Assess query complexity
|
||||
*/
|
||||
private assessComplexity;
|
||||
/**
|
||||
* Step 2: Use neural analysis to decompose complex queries
|
||||
*/
|
||||
private decomposeQuery;
|
||||
/**
|
||||
* Step 3: Map concepts using Entity Registry and taxonomy
|
||||
*/
|
||||
private mapConcepts;
|
||||
/**
|
||||
* Step 4: Construct final Triple Intelligence query
|
||||
*/
|
||||
private constructTripleQuery;
|
||||
/**
|
||||
* Initialize pattern recognition for common query types
|
||||
*/
|
||||
private initializePatterns;
|
||||
/**
|
||||
* Detect field query patterns
|
||||
*/
|
||||
private hasFieldPatterns;
|
||||
/**
|
||||
* Detect connection query patterns
|
||||
*/
|
||||
private hasConnectionPatterns;
|
||||
/**
|
||||
* Extract terms and modifiers from query
|
||||
*/
|
||||
private extractTerms;
|
||||
/**
|
||||
* Find entity matches using Brainy's search capabilities
|
||||
*/
|
||||
private findEntityMatches;
|
||||
/**
|
||||
* Check if term is a known field name
|
||||
*/
|
||||
private isKnownField;
|
||||
/**
|
||||
* Map colloquial terms to actual field names
|
||||
*/
|
||||
private mapToFieldName;
|
||||
/**
|
||||
* Find similar successful queries from history
|
||||
* Uses Brainy's vector search to find semantically similar previous queries
|
||||
*/
|
||||
private findSimilarQueries;
|
||||
/**
|
||||
* Extract entities from query using Brainy's semantic search
|
||||
* Identifies known entities, concepts, and relationships in the query text
|
||||
*/
|
||||
private extractEntities;
|
||||
/**
|
||||
* Build final TripleQuery based on intent, entities, and query analysis
|
||||
* Constructs optimized query combining vector, graph, and field searches
|
||||
*/
|
||||
private buildQuery;
|
||||
/**
|
||||
* Extract entities from text using NEURAL matching to strict NounTypes
|
||||
* ALWAYS uses neural matching, NEVER falls back to patterns
|
||||
*/
|
||||
extract(text: string, options?: {
|
||||
types?: string[];
|
||||
includeMetadata?: boolean;
|
||||
confidence?: number;
|
||||
}): Promise<Array<{
|
||||
text: string;
|
||||
type: string;
|
||||
position: {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
confidence: number;
|
||||
metadata?: any;
|
||||
}>>;
|
||||
/**
|
||||
* DEPRECATED - Old pattern-based extraction
|
||||
* This should NEVER be used - kept only for reference
|
||||
*/
|
||||
private extractWithPatterns_DEPRECATED;
|
||||
/**
|
||||
* Analyze sentiment of text
|
||||
*/
|
||||
sentiment(text: string, options?: {
|
||||
granularity?: 'document' | 'sentence' | 'aspect';
|
||||
aspects?: string[];
|
||||
}): Promise<{
|
||||
overall: {
|
||||
score: number;
|
||||
magnitude: number;
|
||||
label: 'positive' | 'negative' | 'neutral' | 'mixed';
|
||||
};
|
||||
sentences?: Array<{
|
||||
text: string;
|
||||
score: number;
|
||||
magnitude: number;
|
||||
label: string;
|
||||
}>;
|
||||
aspects?: Record<string, {
|
||||
score: number;
|
||||
magnitude: number;
|
||||
mentions: number;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* Calculate confidence for entity extraction
|
||||
*/
|
||||
private calculateConfidence;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue