From a5a1d2bbe04f0bff38fa7dbd6a45bb258c7a9f17 Mon Sep 17 00:00:00 2001 From: aarne Date: Tue, 26 Jan 2010 21:49:00 +0000 Subject: [PATCH] bug fixes in biased generation ; example probs file in lib/src --- lib/src/probs | 30 +++++++++++++++++++++++++++++ src/runtime/haskell/PGF/Generate.hs | 14 +++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 lib/src/probs diff --git a/lib/src/probs b/lib/src/probs new file mode 100644 index 000000000..bc647bfa0 --- /dev/null +++ b/lib/src/probs @@ -0,0 +1,30 @@ +youPl_Pron 0.04 +youPol_Pron 0.04 + +UttS 0.6 +UttQS 0.2 +UttImp 0.1 + +NoPConj 0.8 +NoVoc 0.98 + +PredVP 0.9 + +DetCN 0.7 +UsePron 0.2 + +SlashV2 0.8 + +UseV 0.4 +ComplSlash 0.4 +ComplVQ 0.02 +ComplVS 0.02 +ComplVA 0.02 + +DetQuant 0.8 + +ASimul 0.8 +TFut 0.1 +TCond 0.1 +PPos 0.7 + diff --git a/src/runtime/haskell/PGF/Generate.hs b/src/runtime/haskell/PGF/Generate.hs index 3f044c224..f129150fa 100644 --- a/src/runtime/haskell/PGF/Generate.hs +++ b/src/runtime/haskell/PGF/Generate.hs @@ -58,10 +58,13 @@ genRandomProb mprobs gen pgf ty@(DTyp _ cat _) = d:ds2 = ds (f,args) = getf d fs (ts,k) = getts ds2 args - in (foldl EApp (EFun f) ts, k+1) + in (foldl EApp f ts, k+1) getf d fs = case mprobs of Just _ -> hitRegion d [(p,(f,args)) | (p,(f,args)) <- fs] - _ -> let lg = (length fs) in snd (fs !! (floor (d * fromIntegral lg))) + _ -> let + lg = length fs + (f,v) = snd (fs !! (floor (d * fromIntegral lg))) + in (EFun f,v) getts ds cats = case cats of c:cs -> let (t, k) = gett ds c @@ -77,8 +80,9 @@ genRandomProb mprobs gen pgf ty@(DTyp _ cat _) = (f,ty) <- fs, let deflt = 1.0 / fromIntegral (length fs)] -hitRegion :: Double -> [(Double,a)] -> a +hitRegion :: Double -> [(Double,(CId,[a]))] -> (Expr,[a]) hitRegion d vs = case vs of - (p1,v1):vs2 -> - if d < p1 then v1 else hitRegion d [(p+p1,v) | (p,v) <- vs2] + (p1,(f,v1)):vs2 -> if d < p1 then (EFun f, v1) else hitRegion (d-p1) vs2 + _ -> (EMeta 9,[]) +