"""
RBSP Query Engine.

Signal-based query resolution with O(1) resonance matching.

Components:
    - SignalEncoder:       Converts query text into RBSP signals.
    - QueryParser:         Parses natural language queries into structured objects.
    - ResonanceMatcher:    Core matching engine (exact + semantic + structural).
    - SemanticResolver:    LSH-based semantic similarity resolution.
    - ResultRanker:        Ranks results by resonance strength.
    - MultiScopeResolver:  Unified search across files, codebases, systems.
"""

from rbsp.query.parser import (
    ParsedQuery,
    QueryParser,
    QueryToken,
    QueryType,
    TokenType,
)
from rbsp.query.ranker import (
    RankedResult,
    RankingWeights,
    ResultRanker,
)
from rbsp.query.resonance import (
    BloomFilter,
    ResonanceHit,
    ResonanceMatcher,
    SignatureRegistry,
)
from rbsp.query.resolver import (
    MultiScopeResolver,
    ResolvedResult,
    Scope,
    ScopeStore,
)
from rbsp.query.semantic import (
    SemanticCluster,
    SemanticResolver,
    SemanticResult,
)
from rbsp.query.phrase import (
    PhraseQuery,
    PhraseScorer,
)
from rbsp.query.proximity import (
    ProximityScorer,
    SpanQuery,
    span_match,
)
from rbsp.query.rewrite import (
    CollapseWhitespaceRule,
    FieldExtractionRule,
    LowercaseRule,
    OperatorNormalizationRule,
    QueryRewriter,
    QuotedPhraseRule,
    RewriteRule,
    RewrittenQuery,
    StemRule,
    StopWordRemovalRule,
    StripPunctuationRule,
)
from rbsp.query.diversity import (
    CategoryDiversifier,
    DiversityReranker,
    mmr_rerank,
)
from rbsp.query.ensemble import (
    FusionMethod,
    ScoreFusion,
    normalize_scores,
)
from rbsp.query.bm25f import (
    BM25FScorer,
    FieldConfig,
)
from rbsp.query.explain import (
    ExplainableBM25,
    Explanation,
    format_explanation,
)
from rbsp.query.learning_to_rank import (
    BM25Feature,
    DocLengthFeature,
    Feature,
    FeatureExtractor,
    FeatureVector,
    FreshnessFeature,
    LinearRanker,
    QueryCoverageFeature,
    RankingPipeline,
    TFFeature,
)
from rbsp.query.spellcheck import SpellChecker
from rbsp.query.hybrid import (
    AdaptiveResonance,
    HybridRetriever,
    MultiSignalResonance,
    ResonanceConfig,
    ResonanceScorer,
    compare_fusion_methods,
    ndcg_at_k,
)
from rbsp.query.signal import (
    Signal,
    SignalEncoder,
)
from rbsp.query.reranker import (
    CrossEncoder,
    CohereReranker,
    DummyCrossEncoder,
    RerankerConfig,
    RerankerPipeline,
    TransformerReranker,
)
from rbsp.query.wildcard import (
    PrefixMatcher,
    PrefixQuery,
    WildcardMatcher,
    WildcardQuery,
    wildcard_to_regex,
)

__all__ = [
    # Signal encoding
    "Signal",
    "SignalEncoder",
    # Query parsing
    "ParsedQuery",
    "QueryParser",
    "QueryToken",
    "QueryType",
    "TokenType",
    # Resonance matching
    "BloomFilter",
    "ResonanceHit",
    "ResonanceMatcher",
    "SignatureRegistry",
    # Semantic resolution
    "SemanticCluster",
    "SemanticResolver",
    "SemanticResult",
    # Result ranking
    "RankedResult",
    "RankingWeights",
    "ResultRanker",
    # Phrase matching
    "PhraseQuery",
    "PhraseScorer",
    # Proximity scoring
    "ProximityScorer",
    "SpanQuery",
    "span_match",
    # Query rewriting
    "CollapseWhitespaceRule",
    "FieldExtractionRule",
    "LowercaseRule",
    "OperatorNormalizationRule",
    "QueryRewriter",
    "QuotedPhraseRule",
    "RewriteRule",
    "RewrittenQuery",
    "StemRule",
    "StopWordRemovalRule",
    "StripPunctuationRule",
    # Result diversification
    "CategoryDiversifier",
    "DiversityReranker",
    "mmr_rerank",
    # Ensemble score fusion
    "FusionMethod",
    "ScoreFusion",
    "normalize_scores",
    # BM25F field-aware scoring
    "BM25FScorer",
    "FieldConfig",
    # Score explanation
    "ExplainableBM25",
    "Explanation",
    "format_explanation",
    # Wildcard and prefix matching
    "PrefixMatcher",
    "PrefixQuery",
    "WildcardMatcher",
    "WildcardQuery",
    "wildcard_to_regex",
    # Spell checking
    "SpellChecker",
    # Learning to rank
    "BM25Feature",
    "DocLengthFeature",
    "Feature",
    "FeatureExtractor",
    "FeatureVector",
    "FreshnessFeature",
    "LinearRanker",
    "QueryCoverageFeature",
    "RankingPipeline",
    "TFFeature",
    # Multi-scope resolution
    "MultiScopeResolver",
    "ResolvedResult",
    "Scope",
    "ScopeStore",
    # Cross-encoder reranking
    "CrossEncoder",
    "CohereReranker",
    "DummyCrossEncoder",
    "TransformerReranker",
    "RerankerConfig",
    "RerankerPipeline",
    # Resonance-based hybrid retrieval
    "AdaptiveResonance",
    "HybridRetriever",
    "MultiSignalResonance",
    "ResonanceConfig",
    "ResonanceScorer",
    "compare_fusion_methods",
    "ndcg_at_k",
]
