@aaswe/codebase-ai
Version:
AI-Assisted Software Engineering (AASWE) - Rich codebase context for IDE LLMs
165 lines • 3.99 kB
TypeScript
/**
* SPARQL Query Engine
*
* Production-ready natural language to SPARQL translation engine with
* intelligent query generation, optimization, and execution capabilities.
*/
import { EventEmitter } from 'events';
import { InMemoryRDFStore } from '../../layer2/in-memory-rdf/InMemoryRDFStore';
import { SPARQLEngineConfig, SPARQLQueryResponse, SPARQLMetrics } from './types';
/**
* SPARQL Query Engine for natural language to SPARQL translation
*/
export declare class SPARQLQueryEngine extends EventEmitter {
private config;
private llm;
private rdfStore;
private queryCache;
private metrics;
private queryPatterns;
private ontologyInfo;
private isInitialized;
private cacheCleanupInterval?;
constructor(config: SPARQLEngineConfig, rdfStore: InMemoryRDFStore);
/**
* Merge user config with defaults
*/
private mergeWithDefaults;
/**
* Initialize metrics
*/
private initializeMetrics;
/**
* Initialize LLM based on configuration
*/
private initializeLLM;
/**
* Initialize query patterns for pattern-based generation
*/
private initializeQueryPatterns;
/**
* Load ontology information from RDF store
*/
private loadOntologyInfo;
/**
* Start cache cleanup interval
*/
private startCacheCleanup;
/**
* Clean up expired cache entries
*/
private cleanupCache;
/**
* Generate cache key for query
*/
private generateCacheKey;
/**
* Get cached result
*/
private getCachedResult;
/**
* Cache query result
*/
private cacheResult;
/**
* Update cache hit rate
*/
private updateCacheHitRate;
/**
* Update metrics
*/
private updateMetrics;
/**
* Initialize the SPARQL Query Engine
*/
initialize(): Promise<void>;
/**
* Process natural language query and return SPARQL results
*/
query(naturalLanguageQuery: string): Promise<SPARQLQueryResponse>;
/**
* Get current metrics
*/
getMetrics(): SPARQLMetrics;
/**
* Shutdown the engine
*/
shutdown(): Promise<void>;
/**
* Parse natural language query into structured format
*/
private parseNaturalLanguageQuery;
/**
* Detect query intent from natural language
*/
private detectQueryIntent;
/**
* Extract entities from natural language query
*/
private extractEntities;
/**
* Extract triple patterns from query and entities
*/
private extractTriplePatterns;
/**
* Extract filters from natural language query
*/
private extractFilters;
/**
* Extract aggregations from natural language query
*/
private extractAggregations;
/**
* Calculate parsing confidence
*/
private calculateParsingConfidence;
/**
* Generate SPARQL query from parsed structure
*/
private generateSPARQLQuery;
/**
* Try pattern-based SPARQL generation
*/
private tryPatternBasedGeneration;
/**
* Apply pattern template to generate SPARQL
*/
private applyPattern;
/**
* Get variable value for pattern template
*/
private getVariableValue;
/**
* Generate SPARQL using LLM
*/
private generateWithLLM;
/**
* Estimate query complexity
*/
private estimateQueryComplexity;
/**
* Execute SPARQL query against RDF store
*/
private executeSPARQLQuery;
/**
* Add prefixes to SPARQL query
*/
private addPrefixesToQuery;
/**
* Validate SPARQL syntax
*/
private validateSPARQL;
/**
* Format execution results for display
*/
private formatResponse;
/**
* Generate query explanation
*/
private generateExplanation;
/**
* Generate query suggestions
*/
private generateSuggestions;
}
//# sourceMappingURL=SPARQLQueryEngine.d.ts.map