mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 03:09:33 -06:00
a binding to the sentence lookup from Haskell
This commit is contained in:
@@ -57,11 +57,13 @@ module PGF2 (-- * PGF
|
|||||||
alignWords,
|
alignWords,
|
||||||
-- ** Parsing
|
-- ** Parsing
|
||||||
parse, parseWithHeuristics,
|
parse, parseWithHeuristics,
|
||||||
-- ** Generation
|
-- ** Sentence Lookup
|
||||||
|
lookupSentence,
|
||||||
|
-- ** Generation
|
||||||
generateAll,
|
generateAll,
|
||||||
-- ** Morphological Analysis
|
-- ** Morphological Analysis
|
||||||
MorphoAnalysis, lookupMorpho, fullFormLexicon,
|
MorphoAnalysis, lookupMorpho, fullFormLexicon,
|
||||||
-- ** Visualizations
|
-- ** Visualizations
|
||||||
graphvizAbstractTree,graphvizParseTree,
|
graphvizAbstractTree,graphvizParseTree,
|
||||||
|
|
||||||
-- * Exceptions
|
-- * Exceptions
|
||||||
@@ -470,6 +472,22 @@ mkCallbacksMap concr callbacks pool = do
|
|||||||
|
|
||||||
predict_callback _ _ _ = return nullPtr
|
predict_callback _ _ _ = return nullPtr
|
||||||
|
|
||||||
|
lookupSentence :: Concr -- ^ the language with which we parse
|
||||||
|
-> Type -- ^ the start category
|
||||||
|
-> String -- ^ the input sentence
|
||||||
|
-> [(Expr,Float)]
|
||||||
|
lookupSentence lang (Type ctype _) sent =
|
||||||
|
unsafePerformIO $
|
||||||
|
do exprPl <- gu_new_pool
|
||||||
|
parsePl <- gu_new_pool
|
||||||
|
sent <- newUtf8CString sent parsePl
|
||||||
|
enum <- pgf_lookup_sentence (concr lang) ctype sent parsePl exprPl
|
||||||
|
parseFPl <- newForeignPtr gu_pool_finalizer parsePl
|
||||||
|
exprFPl <- newForeignPtr gu_pool_finalizer exprPl
|
||||||
|
exprs <- fromPgfExprEnum enum parseFPl (touchConcr lang >> touchForeignPtr exprFPl)
|
||||||
|
return exprs
|
||||||
|
|
||||||
|
|
||||||
-- | The oracle is a triple of functions.
|
-- | The oracle is a triple of functions.
|
||||||
-- The first two take a category name and a linearization field name
|
-- The first two take a category name and a linearization field name
|
||||||
-- and they should return True/False when the corresponding
|
-- and they should return True/False when the corresponding
|
||||||
|
|||||||
@@ -208,6 +208,9 @@ foreign import ccall "pgf/pgf.h pgf_align_words"
|
|||||||
foreign import ccall "pgf/pgf.h pgf_parse_with_heuristics"
|
foreign import ccall "pgf/pgf.h pgf_parse_with_heuristics"
|
||||||
pgf_parse_with_heuristics :: Ptr PgfConcr -> PgfType -> CString -> Double -> Ptr PgfCallbacksMap -> Ptr GuExn -> Ptr GuPool -> Ptr GuPool -> IO (Ptr GuEnum)
|
pgf_parse_with_heuristics :: Ptr PgfConcr -> PgfType -> CString -> Double -> Ptr PgfCallbacksMap -> Ptr GuExn -> Ptr GuPool -> Ptr GuPool -> IO (Ptr GuEnum)
|
||||||
|
|
||||||
|
foreign import ccall "pgf/pgf.h pgf_lookup_sentence"
|
||||||
|
pgf_lookup_sentence :: Ptr PgfConcr -> PgfType -> CString -> Ptr GuPool -> Ptr GuPool -> IO (Ptr GuEnum)
|
||||||
|
|
||||||
type LiteralMatchCallback = CInt -> Ptr CInt -> Ptr GuPool -> IO (Ptr PgfExprProb)
|
type LiteralMatchCallback = CInt -> Ptr CInt -> Ptr GuPool -> IO (Ptr PgfExprProb)
|
||||||
|
|
||||||
foreign import ccall "wrapper"
|
foreign import ccall "wrapper"
|
||||||
|
|||||||
Reference in New Issue
Block a user