git » alan.git » commit b968566

Space forced slot assignments to satisfy high quotas

author Alan Dipert
2025-12-04 04:07:30 UTC
committer Alan Dipert
2025-12-04 04:07:30 UTC
parent e0632576616242388560e190e2f088463d4ab11d

Space forced slot assignments to satisfy high quotas

test_generator.py +18 -4

diff --git a/test_generator.py b/test_generator.py
index 8061d4c..328639f 100644
--- a/test_generator.py
+++ b/test_generator.py
@@ -514,10 +514,24 @@ def generate_test(
     sections_out = []
     question_counter = 1
     item_map = []
-    irregular_noun_slots = {8, 12, 16, 20, 24, 28}
-    irregular_verb_slots = {10, 14, 18, 22, 26, 32}
-    ditransitive_slots = {3, 6, 9, 12, 15, 18, 21, 24, 27, 30}
-    fem_plural_slots = {5, 11, 17, 23, 29}
+    total_items = sum(section.num_items for section in blueprint.sections)
+    cfg = params or {}
+
+    def spaced_slots(count: int) -> set[int]:
+        if count <= 0:
+            return set()
+        slots = set()
+        for i in range(count):
+            idx = 1 + int(i * total_items / max(1, count))
+            slots.add(min(total_items, max(1, idx)))
+        return slots
+
+    irregular_target = cfg.get("min_irregular", 6)
+    # require both irregulars to meet the target
+    irregular_noun_slots = spaced_slots(min(irregular_target, total_items))
+    irregular_verb_slots = spaced_slots(min(irregular_target, total_items))
+    ditransitive_slots = spaced_slots(cfg.get("min_ditransitive", 8))
+    fem_plural_slots = spaced_slots(cfg.get("min_fem_plural", 4))
 
     for section in blueprint.sections:
         questions: List[Question] = []