diff options
| author | krasimir <krasimir@chalmers.se> | 2010-11-24 12:51:54 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2010-11-24 12:51:54 +0000 |
| commit | 0b80b3ef0aa2daaef66f642fdff984c4eb7709f0 (patch) | |
| tree | 0a278483170ad262a60355a1010426b431b47f95 /src | |
| parent | ee85111d382fd7bf2055a2bf149d60deacb70802 (diff) | |
command ai in the shell now shows the probability of the tree
Diffstat (limited to 'src')
| -rw-r--r-- | src/compiler/GF/Command/Commands.hs | 13 | ||||
| -rw-r--r-- | src/runtime/haskell/PGF/Probabilistic.hs | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs index faaa9e3ab..b4ab5ff4a 100644 --- a/src/compiler/GF/Command/Commands.hs +++ b/src/compiler/GF/Command/Commands.hs @@ -902,21 +902,24 @@ allCommands env@(pgf, mos) = Map.fromList [ exec = \opts arg -> do case arg of [EFun id] -> case Map.lookup id (funs (abstract pgf)) of - Just fd -> return $ fromString $ - render (ppFun id fd) + Just fd -> do putStrLn $ render (ppFun id fd) + putStrLn ("Probability: "++show (probTree pgf (EFun id))) + return void Nothing -> case Map.lookup id (cats (abstract pgf)) of - Just hyps -> do return $ fromString $ + Just hyps -> do putStrLn $ render (ppCat id hyps $$ if null (functionsToCat pgf id) then empty else space $$ vcat [ppFun fid (ty,0,Just [],0) | (fid,ty) <- functionsToCat pgf id]) + return void Nothing -> do putStrLn ("unknown category of function identifier "++show id) return void [e] -> case inferExpr pgf e of Left tcErr -> error $ render (ppTcError tcErr) - Right (e,ty) -> do putStrLn ("Expression: "++showExpr [] e) - putStrLn ("Type: "++showType [] ty) + Right (e,ty) -> do putStrLn ("Expression: "++showExpr [] e) + putStrLn ("Type: "++showType [] ty) + putStrLn ("Probability: "++show (probTree pgf e)) return void _ -> do putStrLn "a single identifier or expression is expected from the command" return void, diff --git a/src/runtime/haskell/PGF/Probabilistic.hs b/src/runtime/haskell/PGF/Probabilistic.hs index 873f17be4..1a75b60a6 100644 --- a/src/runtime/haskell/PGF/Probabilistic.hs +++ b/src/runtime/haskell/PGF/Probabilistic.hs @@ -7,8 +7,8 @@ module PGF.Probabilistic , showProbabilities -- :: Probabilities -> String , readProbabilitiesFromFile -- :: FilePath -> PGF -> IO Probabilities - , probTree -- :: Probabilities -> Tree -> Double - , rankTreesByProbs -- :: Probabilities -> [Tree] -> [Tree] + , probTree + , rankTreesByProbs ) where import PGF.CId |
