mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-05 09:12:51 -06:00
added function treeProbability in the Haskell binding
This commit is contained in:
@@ -39,6 +39,8 @@ module PGF2 (-- * PGF
|
||||
mkFloat,unFloat,
|
||||
mkMeta,unMeta,
|
||||
mkCId,
|
||||
treeProbability,
|
||||
|
||||
-- ** Types
|
||||
Type, Hypo, BindType(..), startCat,
|
||||
readType, showType,
|
||||
@@ -314,6 +316,13 @@ compute (PGF p _) (Expr c_expr touch1) =
|
||||
gu_pool_free exprPl
|
||||
throwIO (PGFError msg)
|
||||
|
||||
treeProbability :: PGF -> Expr -> Float
|
||||
treeProbability (PGF p _) (Expr c_expr touch1) =
|
||||
unsafePerformIO $ do
|
||||
res <- pgf_compute_tree_probability p c_expr
|
||||
touch1
|
||||
return (realToFrac res)
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Graphviz
|
||||
|
||||
|
||||
@@ -325,6 +325,9 @@ foreign import ccall "pgf/pgf.h pgf_expr_unlit"
|
||||
foreign import ccall "pgf/expr.h pgf_expr_arity"
|
||||
pgf_expr_arity :: PgfExpr -> IO CInt
|
||||
|
||||
foreign import ccall "pgf/expr.h pgf_compute_tree_probability"
|
||||
pgf_compute_tree_probability :: Ptr PgfPGF -> PgfExpr -> IO CFloat
|
||||
|
||||
foreign import ccall "pgf/expr.h pgf_check_expr"
|
||||
pgf_check_expr :: Ptr PgfPGF -> Ptr PgfExpr -> PgfType -> Ptr GuExn -> Ptr GuPool -> IO ()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user