/** * semantic-exploration.ts - AIQL v2.2.0 Semantic Exploration * * Semantic gap detection and query generation for curiosity-driven exploration. * All operations preserve knowledge graph semantic coherence and structural integrity. * * Design Philosophy: * - Gaps detected through graph topology (connectivity, confidence) * - Queries generated to maintain semantic coherence * - Prioritization based on semantic weight (importance to graph) * - Exploration respects existing ontology structure */ import { InferenceEngine } from '@aiql-org/inference'; /** * Statistics for a concept */ export interface ConceptStats { statementCount: number; averageConfidence: number; inDegree: number; outDegree: number; } /** * Semantic gap in knowledge graph */ export interface SemanticGap { concept: string; gapType: 'connectivity' | 'confidence' | 'definition' | 'coherence'; severity: number; context: string[]; metrics: ConceptStats; } /** * Generated semantic query to explore gap */ export interface SemanticQuery { aiqlCode: string; targetConcept: string; queryType: 'existence' | 'property' | 'relation' | 'causal' | 'taxonomic'; expectedCoherence: number; priority: number; } /** * Semantic weight: Importance of concept in graph */ export interface SemanticWeight { concept: string; weight: number; factors: { centrality: number; confidence: number; frequency: number; }; } /** * SemanticExplorer - Curiosity-driven graph exploration * * Detects semantic gaps through topology analysis and generates * coherent queries that preserve graph structure and meaning. */ export declare class SemanticExplorer { /** * Detect Semantic Gaps in the Knowledge Base. * * Scans the graph topology and semantic content to identify areas where the AI's knowledge * is incomplete, inconsistent, or uncertain. This drives the "Curiosity" loop. * * Gap Types Detected: * 1. **Connectivity Gaps**: Concepts that are isolated or have very few connections (Degree < 2). * - *Action*: Trigger queries to find relationships for these orphans. * * 2. **Confidence Gaps**: Statements with low confidence scores (< 0.5). * - *Action*: Trigger verification queries to boost or drop confidence. * * 3. **Definition Gaps**: Concepts that appear as objects but never as subjects (undefined). * - *Action*: Trigger ontological queries (e.g., `[is_a]`, `[defined_as]`). * * 4. **Coherence Gaps**: (Placeholder) Statements that violate soft semantic constraints. * * @param kb - The InferenceEngine instance containing the current knowledge graph. * @returns {SemanticGap[]} Sorted list of detected gaps to be prioritized for exploration. */ detectSemanticGaps(kb: InferenceEngine): SemanticGap[]; /** * Generate semantic queries to explore gaps * Queries are coherent with existing graph structure * * @param gap - Semantic gap to explore * @param kb - InferenceEngine with knowledge base * @returns Array of generated queries */ generateSemanticQueries(gap: SemanticGap, kb: InferenceEngine): SemanticQuery[]; /** * Calculate semantic weight of concept in graph * Higher weight = more central/important to graph * * @param concept - Concept name * @param kb - InferenceEngine with knowledge base * @returns Semantic weight with breakdown */ calculateSemanticWeight(concept: string, kb: InferenceEngine): SemanticWeight; /** * Prioritize gaps by semantic weight * Higher priority gaps should be explored first * * @param gaps - Array of semantic gaps * @returns Sorted array (highest priority first) */ prioritizeGaps(gaps: SemanticGap[]): SemanticGap[]; /** * Build statistics for all concepts in KB */ private buildConceptStatistics; /** * Update statistics for a concept */ private updateConceptStats; /** * Get concepts related to target concept */ private getRelatedConcepts; /** * Get all defined concepts (appear as subject) */ private getDefinedConcepts; /** * Get all mentioned concepts (subject or object) */ private getMentionedConcepts; /** * Generate connectivity-focused queries */ private generateConnectivityQueries; /** * Generate confidence-focused queries */ private generateConfidenceQueries; /** * Generate definition-focused queries */ private generateDefinitionQueries; /** * Generate coherence-focused queries */ private generateCoherenceQueries; /** * Calculate how coherent a query is with existing graph */ private calculateQueryCoherence; /** * Check if KB has related query patterns */ private hasRelatedQueries; } //# sourceMappingURL=semantic-exploration.d.ts.map