extractor = CursorExtractor(schema) for log_file in Path("data/raw/logs").glob("*.log"): content = log_file.read_text() extractor.extract_from_text(content, str(log_file))
def __init__(self, schema: Dict[str, str]): self.schema = schema # field -> regex pattern self.results = [] Cursor Extractor
def extract_from_text(self, text: str, file_path: str = None): entry = "_source": file_path for field, pattern in self.schema.items(): match = re.search(pattern, text, re.IGNORECASE | re.MULTILINE) entry[field] = match.group(1) if match else None self.results.append(entry) return entry str(log_file)) def __init__(self
find data/raw -name "*.log" | entr -r python extractor/run_extractor.py Then ask Cursor AI: “Show me the diff of extracted errors between the last two runs.” Cursor Extractor can output to: pattern in self.schema.items(): match = re.search(pattern
import re import json from pathlib import Path from typing import Dict, Any class CursorExtractor: """Hybrid regex + placeholder for AI refinement"""