""" Base classes for query paradigms. """ from abc import ABC, abstractmethod from typing import Dict, Any, List, Optional, Union from dataclasses import dataclass from datetime import datetime @dataclass class QueryResult: """Standardized result format for all query paradigms.""" paradigm: str query: str execution_time_ms: float result_count: int results: List[Dict[str, Any]] metadata: Dict[str, Any] success: bool error_message: Optional[str] = None class BaseQueryParadigm(ABC): """Base class for all query paradigms.""" @property @abstractmethod def name(self) -> str: """Human-readable name of the paradigm.""" pass @property @abstractmethod def description(self) -> str: """Description of what this paradigm does.""" pass @property @abstractmethod def category(self) -> str: """Category: structural, textual, semantic, procedural.""" pass @property @abstractmethod def complexity(self) -> str: """Complexity level: beginner, intermediate, advanced.""" pass @abstractmethod def execute(self, query: str, config: Dict[str, Any] = None) -> QueryResult: """Execute a query using this paradigm.""" pass @abstractmethod def get_examples(self) -> List[Dict[str, str]]: """Get example queries for this paradigm.""" pass @abstractmethod def validate_query(self, query: str) -> tuple[bool, Optional[str]]: """Validate if a query is valid for this paradigm.""" pass def get_syntax_help(self) -> str: """Get syntax help for this paradigm.""" return f"{self.name} syntax help not yet implemented." def can_translate_from(self, other_paradigm: str) -> bool: """Check if this paradigm can translate queries from another.""" return False def translate_query(self, query: str, from_paradigm: str) -> Optional[str]: """Translate a query from another paradigm to this one.""" return None