mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 00:22:51 -06:00
further extend the API of the C runtime
This commit is contained in:
@@ -45,7 +45,7 @@ module PGF2 (-- * PGF
|
||||
|
||||
-- ** Types
|
||||
Type, Hypo, BindType(..), startCat,
|
||||
readType, showType,
|
||||
readType, showType, showContext,
|
||||
mkType, unType,
|
||||
|
||||
-- ** Type checking
|
||||
@@ -1083,8 +1083,7 @@ categoryContext :: PGF -> Cat -> [Hypo]
|
||||
categoryContext p cat =
|
||||
unsafePerformIO $
|
||||
withGuPool $ \tmpPl ->
|
||||
do (sb,out) <- newOut tmpPl
|
||||
c_cat <- newUtf8CString cat tmpPl
|
||||
do c_cat <- newUtf8CString cat tmpPl
|
||||
c_hypos <- pgf_category_context (pgf p) c_cat
|
||||
if c_hypos == nullPtr
|
||||
then return []
|
||||
@@ -1104,6 +1103,15 @@ categoryContext p cat =
|
||||
toBindType (#const PGF_BIND_TYPE_EXPLICIT) = Explicit
|
||||
toBindType (#const PGF_BIND_TYPE_IMPLICIT) = Implicit
|
||||
|
||||
categoryProb :: PGF -> Cat -> Float
|
||||
categoryProb p cat =
|
||||
unsafePerformIO $
|
||||
withGuPool $ \tmpPl ->
|
||||
do c_cat <- newUtf8CString cat tmpPl
|
||||
c_prob <- pgf_category_prob (pgf p) c_cat
|
||||
touchPGF p
|
||||
return (realToFrac c_prob)
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Helper functions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user