How lanchiang/strudel works
1. What this repo is
Strudel is a Python 3.7 command-line ML pipeline for detecting structure in verbose CSV files. The architecture is centered on loading labeled CSV-like datasets, classifying lines/cells, deriving structure from those predictions, and writing results to CSV.
2. Entry point and orchestration
run_strudel.py is the main executable. It accepts dataset and output arguments (-d, -t, -f, -o) and decides whether to run training + evaluation on a test set or cross-validation on the training set when no test set is supplied. This script is the top-level coordinator for the whole pipeline.
3. Data and benchmark assets
The data/ directory contains compressed .jl.gz files (cius, deex, saus, troy), which appear to be JSON Lines-style datasets used for experiments. These files are the main repository boundary between the code and the benchmark corpora.
4. Dataset loading and representation
strudel/data.py is the likely ingestion layer. It is responsible for reading the compressed training/test data, turning raw records into internal examples, and exposing them to the rest of the pipeline. This is the boundary where raw file formats become model-ready data.
5. Feature and utility layer
strudel/utility.py and strudel/block_size_calculator.py provide shared support logic. From the names and project goal, this layer likely contains feature extraction helpers, normalization, formatting helpers, and heuristics for estimating block sizes or table structure. These helpers sit below the classifiers and above raw data access.
6. Classification subsystem
strudel/classification.py is the core predictive layer. It likely contains the model training, prediction, and evaluation logic used to classify CSV lines or cells. This is the main ML boundary: input examples in, class labels or scores out.
7. Two Strudel variants
strudel/lstrudel.py and strudel/cstrudel.py suggest two related detection pipelines or model variants, probably split along line-level and cell-level structure detection. Architecturally, these look like specialized wrappers around the shared classification and feature layers.
8. Post-processing and structure derivation
strudel/derived_detector.py appears to take raw classifier outputs and convert them into higher-level structural decisions. In an architecture diagram, this is the post-processing stage that turns independent predictions into a coherent CSV structure estimate.
9. Overall data flow
The pipeline is: dataset files in data/ → load/normalize examples → extract features → train or apply classifiers → derive structural blocks/labels → write evaluation/output CSV. The important boundary is between prediction and structure reconstruction, since the repo is not just classifying rows but inferring CSV structure from those classifications.
10. Operational characteristics
The project is local and batch-oriented: no server, no database, and no external runtime service are indicated. Execution is file-based, with results emitted as CSV. Dependencies are managed through requirements.txt, and the repo is designed to be run directly from the command line.
11. How to think about the architecture diagram
A good diagram should show three main layers: input datasets, ML/feature/classification pipeline, and structure derivation/output. The central control plane is run_strudel.py, while classification.py, derived_detector.py, and the lstrudel/cstrudel modules form the core processing subsystem.
Main entry points: run_strudel.py run_strudel.py · data.py Data loader · classification.py Classifier · lstrudel.py LStrudel
Components 15
Inputs
Benchmark datasets and command-line entrypoint
- Data files · Compressed JSON-lines style datasets used for experiments
data
Core Pipeline
Loading, feature work, classification, and structure derivation
- run_strudel.py · Main command-line entrypoint that chooses training, evaluation, or cross-validation runs
run_strudel.py - Data loader · Reads compressed training and test data into internal examples
strudel/data.py - Utility · Common helper layer for feature support and formatting
strudel/utility.py - Block sizing · Estimates block sizes or structural spans used by the pipeline
strudel/block_size_calculator.py - Classifier · Training, prediction, and evaluation logic for structure labels
strudel/classification.py - LStrudel · Specialized variant focused on line-level structure detection
strudel/lstrudel.py - CStrudel · Specialized variant focused on cell-level structure detection
strudel/cstrudel.py - Derived detector · Converts raw predictions into higher-level structural decisions
strudel/derived_detector.py - Train/eval · Run mode that trains on a dataset and evaluates against a test set
- Cross-validation · Fallback run mode when no test set is supplied
- Features · Turns loaded examples into model inputs and shared signals
- Predictions · Classifier outputs for lines or cells
- Structure · Combines predictions into CSV structure estimates
Outputs
Evaluation and CSV results
- CSV output · Written evaluation and inference results
Connections 19
- Data files → Data loader: read · Compressed benchmark files are ingested into internal examples
- run_strudel.py → Train/eval: select · Chooses training plus evaluation when a test set is provided
- run_strudel.py → Cross-validation: select · Runs cross-validation when no test set is supplied
- Train/eval → Data loader: load · Loads training and test examples
- Cross-validation → Data loader: load · Loads the training corpus for validation folds
- Data loader → Features: prepare · Converts raw records into model-ready inputs
- Features → Utility: use · Shares normalization and helper logic
- Features → Block sizing: use · Uses block-size and structure heuristics
- Features → Classifier: feed · Supplies features to the model layer
- Classifier → Predictions: emit · Produces class labels or scores
- run_strudel.py → LStrudel: invoke · May route work through the line-level variant
- run_strudel.py → CStrudel: invoke · May route work through the cell-level variant
- LStrudel → Classifier: wraps · Builds on the shared classifier
- CStrudel → Classifier: wraps · Builds on the shared classifier
- Predictions → Derived detector: refine · Raw predictions are post-processed into structure
- Derived detector → Structure: derive · Produces higher-level CSV structure decisions
- Structure → CSV output: write · Outputs evaluation or inferred CSV artifacts
- Train/eval → CSV output: save · Stores evaluation outputs
- Cross-validation → CSV output: save · Stores cross-validation outputs