summaryrefslogtreecommitdiff
path: root/src/runtime/haskell/PGF/Probabilistic.hs
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2012-08-29 11:43:02 +0000
committerkr.angelov <kr.angelov@gmail.com>2012-08-29 11:43:02 +0000
commitf8fe23fda7b97d5301bfb2ec1d89ce9967c5b200 (patch)
treea2db1d1dbe1cd294a7f323abb0123ea8c551fc82 /src/runtime/haskell/PGF/Probabilistic.hs
parent27196778ace6de265407947a21a5b0eb3fd0caf8 (diff)
A basic infrastructure for generating Teyjus bytecode from the GF abstract syntax
Diffstat (limited to 'src/runtime/haskell/PGF/Probabilistic.hs')
-rw-r--r--src/runtime/haskell/PGF/Probabilistic.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/runtime/haskell/PGF/Probabilistic.hs b/src/runtime/haskell/PGF/Probabilistic.hs
index ee44e73e1..bf2464b1d 100644
--- a/src/runtime/haskell/PGF/Probabilistic.hs
+++ b/src/runtime/haskell/PGF/Probabilistic.hs
@@ -50,7 +50,7 @@ readProbabilitiesFromFile file pgf = do
mkProbabilities :: PGF -> Map.Map CId Double -> Probabilities
mkProbabilities pgf probs =
let funs1 = Map.fromList [(f,p) | (_,cf) <- Map.toList cats1, (p,f) <- cf]
- cats1 = Map.map (\(_,fs) -> fill fs) (cats (abstract pgf))
+ cats1 = Map.map (\(_,fs,_) -> fill fs) (cats (abstract pgf))
in Probs funs1 cats1
where
fill fs = pad [(Map.lookup f probs,f) | (_,f) <- fs]
@@ -68,15 +68,15 @@ defaultProbabilities pgf = mkProbabilities pgf Map.empty
getProbabilities :: PGF -> Probabilities
getProbabilities pgf = Probs {
- funProbs = Map.map (\(_,_,_,p) -> p) (funs (abstract pgf)),
- catProbs = Map.map (\(_,fns) -> fns) (cats (abstract pgf))
+ funProbs = Map.map (\(_,_,_,p,_) -> p) (funs (abstract pgf)),
+ catProbs = Map.map (\(_,fns,_) -> fns) (cats (abstract pgf))
}
setProbabilities :: Probabilities -> PGF -> PGF
setProbabilities probs pgf = pgf {
abstract = (abstract pgf) {
- funs = mapUnionWith (\(ty,a,df,_) p -> (ty,a,df,p)) (funs (abstract pgf)) (funProbs probs),
- cats = mapUnionWith (\(hypos,_) fns -> (hypos,fns)) (cats (abstract pgf)) (catProbs probs)
+ funs = mapUnionWith (\(ty,a,df,_,addr) p -> (ty,a,df,p,addr)) (funs (abstract pgf)) (funProbs probs),
+ cats = mapUnionWith (\(hypos,_,addr) fns -> (hypos,fns,addr)) (cats (abstract pgf)) (catProbs probs)
}}
where
mapUnionWith f map1 map2 =
@@ -87,8 +87,8 @@ probTree :: PGF -> Expr -> Double
probTree pgf t = case t of
EApp f e -> probTree pgf f * probTree pgf e
EFun f -> case Map.lookup f (funs (abstract pgf)) of
- Just (_,_,_,p) -> p
- Nothing -> 1
+ Just (_,_,_,p,_) -> p
+ Nothing -> 1
_ -> 1
-- | rank from highest to lowest probability