mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 11:19:32 -06:00
command ai in the shell now shows the probability of the tree
This commit is contained in:
@@ -902,21 +902,24 @@ allCommands env@(pgf, mos) = Map.fromList [
|
|||||||
exec = \opts arg -> do
|
exec = \opts arg -> do
|
||||||
case arg of
|
case arg of
|
||||||
[EFun id] -> case Map.lookup id (funs (abstract pgf)) of
|
[EFun id] -> case Map.lookup id (funs (abstract pgf)) of
|
||||||
Just fd -> return $ fromString $
|
Just fd -> do putStrLn $ render (ppFun id fd)
|
||||||
render (ppFun id fd)
|
putStrLn ("Probability: "++show (probTree pgf (EFun id)))
|
||||||
|
return void
|
||||||
Nothing -> case Map.lookup id (cats (abstract pgf)) of
|
Nothing -> case Map.lookup id (cats (abstract pgf)) of
|
||||||
Just hyps -> do return $ fromString $
|
Just hyps -> do putStrLn $
|
||||||
render (ppCat id hyps $$
|
render (ppCat id hyps $$
|
||||||
if null (functionsToCat pgf id)
|
if null (functionsToCat pgf id)
|
||||||
then empty
|
then empty
|
||||||
else space $$
|
else space $$
|
||||||
vcat [ppFun fid (ty,0,Just [],0) | (fid,ty) <- functionsToCat pgf id])
|
vcat [ppFun fid (ty,0,Just [],0) | (fid,ty) <- functionsToCat pgf id])
|
||||||
|
return void
|
||||||
Nothing -> do putStrLn ("unknown category of function identifier "++show id)
|
Nothing -> do putStrLn ("unknown category of function identifier "++show id)
|
||||||
return void
|
return void
|
||||||
[e] -> case inferExpr pgf e of
|
[e] -> case inferExpr pgf e of
|
||||||
Left tcErr -> error $ render (ppTcError tcErr)
|
Left tcErr -> error $ render (ppTcError tcErr)
|
||||||
Right (e,ty) -> do putStrLn ("Expression: "++showExpr [] e)
|
Right (e,ty) -> do putStrLn ("Expression: "++showExpr [] e)
|
||||||
putStrLn ("Type: "++showType [] ty)
|
putStrLn ("Type: "++showType [] ty)
|
||||||
|
putStrLn ("Probability: "++show (probTree pgf e))
|
||||||
return void
|
return void
|
||||||
_ -> do putStrLn "a single identifier or expression is expected from the command"
|
_ -> do putStrLn "a single identifier or expression is expected from the command"
|
||||||
return void,
|
return void,
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ module PGF.Probabilistic
|
|||||||
, showProbabilities -- :: Probabilities -> String
|
, showProbabilities -- :: Probabilities -> String
|
||||||
, readProbabilitiesFromFile -- :: FilePath -> PGF -> IO Probabilities
|
, readProbabilitiesFromFile -- :: FilePath -> PGF -> IO Probabilities
|
||||||
|
|
||||||
, probTree -- :: Probabilities -> Tree -> Double
|
, probTree
|
||||||
, rankTreesByProbs -- :: Probabilities -> [Tree] -> [Tree]
|
, rankTreesByProbs
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import PGF.CId
|
import PGF.CId
|
||||||
|
|||||||
Reference in New Issue
Block a user