1
0
forked from GitHub/gf-core

further extend the API of the C runtime

This commit is contained in:
Krasimir Angelov
2017-10-04 09:45:56 +02:00
parent e426e87cf8
commit e3aa392e63
8 changed files with 92 additions and 30 deletions

View File

@@ -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