fix(parse): move inside outside inference into log space
This commit is contained in:
1 parent
6023c46560
commit
6b249b14fc
3 files changed
+104
-106
No files matched your search
@@ -43,6 +43,19 @@ let () =
|
||||
check "viterbi P(aa) = 1/8" (approx vp 0.125);
|
||||
check "viterbi tree exists" (vt <> None)
|
||||
|
||||
let () =
|
||||
let recursive =
|
||||
g "S"
|
||||
[ { Grammar.lhs = "S"; rhs = [ tm "a"; nt "S" ]; count = 1.0 };
|
||||
{ Grammar.lhs = "S"; rhs = [ tm "a" ]; count = 999.0 } ]
|
||||
in
|
||||
let tokens = List.init 120 (fun _ -> "a") in
|
||||
match Parse.log_inside (Parse.prepare recursive) tokens with
|
||||
| Some probability ->
|
||||
check "log inside survives probability underflow"
|
||||
(Float.is_finite probability && probability < -700.0)
|
||||
| None -> check "log inside survives probability underflow" false
|
||||
|
||||
let () =
|
||||
let gr = g "S" [ prod "S" [ nt "A"; nt "B" ]; prod "A" [ tm "a" ]; prod "B" [ tm "b" ] ] in
|
||||
let prep = Parse.prepare gr in
|
||||
|
||||
Reference in new issue
Block a user