diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-04-15 19:58:57 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-04-15 19:58:57 +0000 |
| commit | 2f359648711b39b42240ffb8d23214921bea721b (patch) | |
| tree | 3772f3f771fc2fa71c32363de96074104aa5725b /src/runtime | |
| parent | b9f530a8057427c878f085b132685381b987f459 (diff) | |
the compiler now sorts the list of functions per category in probability order. this ensures probability order search in the C runtime
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/haskell/PGF/Probabilistic.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/haskell/PGF/Probabilistic.hs b/src/runtime/haskell/PGF/Probabilistic.hs index bf2464b1d..d0206af26 100644 --- a/src/runtime/haskell/PGF/Probabilistic.hs +++ b/src/runtime/haskell/PGF/Probabilistic.hs @@ -50,9 +50,11 @@ 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,_) -> sortBy cmpProb (fill fs)) (cats (abstract pgf)) in Probs funs1 cats1 where + cmpProb (p1,_) (p2,_) = compare p2 p1 + fill fs = pad [(Map.lookup f probs,f) | (_,f) <- fs] where pad :: [(Maybe Double,a)] -> [(Double,a)] |
