grammar-inference-engine/bex/__init__.py
tobjend b516b2985d feat: implement Reduce algorithm (Algorithm 4, TODS 2010)
- bex/reduce.py: Faithful implementation of Reduce with support-weighted
  SOA edit distance, adjunction, iterative merging, and Minimize
- experiments/context_eval.py: Multi-codebase support (RAGSAK + Flask),
  Reduce experiments with thresholds 0.05-0.4
- tests/test_reduce.py: 24 tests covering all Reduce components
- Flask cloned to external_refs/flask for cross-validation

Results:
- RAGSAK: 12.0% coverage (First 3 symbols)
- Flask: 10.7% coverage (First 3 symbols)
- Reduce has minimal impact (1-2 merges per codebase at ε=0.3)
- Coverage ceiling appears to be ~10-12% for prefix-based grouping
2026-07-12 00:11:38 +02:00

29 lines
980 B
Python

"""
bex — Paper-faithful implementation of BEX inference algorithms.
Papers:
- Bex et al. 2010 (TODS): Inference of Concise Regular Expressions and DTDs
- Bex et al. 2010 (arXiv 1004.2372): Learning Deterministic Regular Expressions
Algorithms implemented:
TODS 2010: 2T-INF, REWRITE, RWR, RWR², RWR₀, CRX
arXiv 2010: iKoa, Disambiguate, rwr², iDRegEx
"""
from .soa import SOA
from .twotinf import build_soa
from .rwr0 import rwr0
from .crx import CRX
from .ikoa import ikoa
from .rwrsq import rwr_sq
from .idregex import idregex
from .kore import kOREInference, validate_k_ore
from .koa import KOA, build_complete_koa
from .expr import concat, disj, star, optional, alphabet, strip_k
from .marking import mark_koa
from .tokenizer import YAMLTokenizer
from .ensemble import infer_ensemble
from .template import generate_template
from .reduce import reduce_contexts, soa_distance, build_soa_with_support, minimize_contexts, reduce_and_infer
__version__ = "0.2.0"