From 1041d88afd4b17c16cd3cb517d85b54a2d5c75f9 Mon Sep 17 00:00:00 2001 From: Weksa Date: Fri, 13 Nov 2026 08:49:23 +0000 Subject: [PATCH] run: relower and calibrate create their directories after the round is found; paired_floor is NaN under two items instead of underflowing; main: split_text keeps its doc Co-Authored-By: Claude Sonnet 5.5 --- crates/weksa/src/main.rs | 2 +- crates/weksa/src/run.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/weksa/src/main.rs b/crates/weksa/src/main.rs index 6ce2281..3cd2235 100644 --- a/crates/weksa/src/main.rs +++ b/crates/weksa/src/main.rs @@ -685,13 +685,13 @@ impl AddArgs { } } -/// The split of an item as `Train`, `Validation`, `Test` or `excluded`. /// A draw or arm label: [a-z0-9-]{1,32}. fn is_label(l: &str) -> bool { (1..=32).contains(&l.len()) && l.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-') } +/// The split of an item as `Train`, `Validation`, `Test` or `excluded`. fn split_text(item: &CorpusItem) -> String { SplitScheme::V1 .split(item) diff --git a/crates/weksa/src/run.rs b/crates/weksa/src/run.rs index bdfb2e7..b15fd07 100644 --- a/crates/weksa/src/run.rs +++ b/crates/weksa/src/run.rs @@ -1680,7 +1680,6 @@ impl RunStores { return Err(RunError::FloorArms); } let dir = self.relower_dir(n, arm_label); - std::fs::create_dir_all(&dir).map_err(|e| RunError::Io(e.kind()))?; // Ports in the order the prompts are asked: recorded, floors, arm. let floor_count = floors.len(); let mut ports: Vec<&mut dyn ModelPort> = vec![recorded]; @@ -1733,7 +1732,8 @@ impl RunStores { /// scores 0. Port 0 is the recorded lowering, which must be answered /// (`Unrecorded` at once); any other port that is not is listed in /// `waiting`, and nothing is scored. `scratch` is the packet store the - /// prompts are built in, removed and reopened here. + /// prompts are built in, removed and reopened here; its directory is + /// created here, after the round is found. fn read_draws( &self, n: u32, @@ -1745,6 +1745,9 @@ impl RunStores { let held = self.held_splits(n, &[Split::Validation])?; let inventory = self.inventory.inventory().map_err(store)?; let ontology = self.ontology.ontology().map_err(store)?; + if let Some(dir) = scratch.parent() { + std::fs::create_dir_all(dir).map_err(|e| RunError::Io(e.kind()))?; + } for suffix in ["", ".lock"] { let mut name = scratch.as_os_str().to_owned(); name.push(suffix); @@ -2024,7 +2027,6 @@ impl RunStores { ports.push(d); } let dir = self.root.join(format!("calibrate-{n}")); - std::fs::create_dir_all(&dir).map_err(|e| RunError::Io(e.kind()))?; let drawn = self.read_draws(n, &dir.join("base.cc"), &mut ports, scorer)?; let missing: Vec<(String, u32)> = labels .iter() @@ -2828,7 +2830,7 @@ pub const FLOOR_ARMS_MIN: usize = 3; /// than two items or no arm (0/0), and when an arm is ragged. pub fn paired_floor(recorded: &[ItemScore], arms: &[Vec]) -> Reading { let n = recorded.len(); - if arms.iter().any(|a| a.len() != n) { + if n < 2 || arms.iter().any(|a| a.len() != n) { return Reading { chrf: f64::NAN, meaning: f64::NAN, composite: f64::NAN }; } let pooled = |of: &dyn Fn(&ItemScore) -> f64| {