fix(parse): compute unary outside closure deterministically

This commit is contained in:
milner committed 2026-09-23 07:15:00 +00:00
1 parent c1403764d9
commit 2bdb8aede6
2 files changed
+58 -1

No files matched your search

+15
View File
@@ -95,6 +95,21 @@ let () =
check "unit productions are preserved" (has_prod gn "S" [ nt "A" ]);
check "unit productions chain preserved" (has_prod gn "A" [ nt "B" ])
let () =
List.iter
(fun (a, b, c) ->
let gu =
g "S"
[ prod "S" [ nt a ]; prod a [ nt b ]; prod b [ nt c ];
prod c [ tm "a" ] ]
in
let counts, probability = Parse.expected_counts (Parse.prepare gu) [ "a" ] in
check "unit chain probability" (approx probability 1.0);
Array.iter
(fun count -> check "unit chain expected count" (approx count 1.0))
counts)
[ ("A", "B", "C"); ("X", "Y", "Z"); ("Q", "R", "T") ]
let () =
let cfg = { Scoring.default_config with alpha = 1.0; em_iters = 5 } in
let g1 = g "S" [ prod "S" [ tm "a" ] ] in