1
0
forked from GitHub/gf-core

fix conflicts

This commit is contained in:
kr.angelov
2015-01-21 08:35:20 +00:00
parent 07eb8fec26
commit 60cb95258b

View File

@@ -17,7 +17,9 @@ module PGF2 (-- * CId
-- * PGF -- * PGF
PGF,readPGF,AbsName,abstractName,startCat, PGF,readPGF,AbsName,abstractName,startCat,
-- * Concrete syntax -- * Concrete syntax
Concr,languages,parse,parseWithHeuristics,linearize,alignWords, ConcName,Concr,languages,parse,parseWithHeuristics,linearize,alignWords,
-- * Types
Type(..), Hypo, functionType,
-- * Trees -- * Trees
Expr,Fun,readExpr,showExpr,mkApp,unApp,mkStr, Expr,Fun,readExpr,showExpr,mkApp,unApp,mkStr,
-- * Morphology -- * Morphology
@@ -43,6 +45,7 @@ import Data.Char(isUpper,isSpace)
import Data.List(isSuffixOf,maximumBy) import Data.List(isSuffixOf,maximumBy)
import Data.Function(on) import Data.Function(on)
type CId = String
----------------------------------------------------------------------- -----------------------------------------------------------------------
-- Functions that take a PGF. -- Functions that take a PGF.
@@ -81,7 +84,7 @@ readPGF fpath =
master <- newForeignPtr gu_pool_finalizer pool master <- newForeignPtr gu_pool_finalizer pool
return PGF {pgf = pgf, pgfMaster = master} return PGF {pgf = pgf, pgfMaster = master}
languages :: PGF -> Map.Map String Concr languages :: PGF -> Map.Map ConcName Concr
languages p = languages p =
unsafePerformIO $ unsafePerformIO $
do ref <- newIORef Map.empty do ref <- newIORef Map.empty
@@ -110,10 +113,10 @@ generateAll p cat =
exprFPl <- newForeignPtr gu_pool_finalizer exprPl exprFPl <- newForeignPtr gu_pool_finalizer exprPl
fromPgfExprEnum enum genFPl (p,exprFPl) fromPgfExprEnum enum genFPl (p,exprFPl)
abstractName :: PGF -> String abstractName :: PGF -> AbsName
abstractName p = unsafePerformIO (peekCString =<< pgf_abstract_name (pgf p)) abstractName p = unsafePerformIO (peekCString =<< pgf_abstract_name (pgf p))
startCat :: PGF -> String startCat :: PGF -> Cat
startCat p = unsafePerformIO (peekCString =<< pgf_start_cat (pgf p)) startCat p = unsafePerformIO (peekCString =<< pgf_start_cat (pgf p))
loadConcr :: Concr -> FilePath -> IO () loadConcr :: Concr -> FilePath -> IO ()
@@ -200,7 +203,7 @@ data Expr = forall a . Expr {expr :: PgfExpr, exprMaster :: a}
instance Show Expr where instance Show Expr where
show = showExpr show = showExpr
mkApp :: String -> [Expr] -> Expr mkApp :: Fun -> [Expr] -> Expr
mkApp fun args = mkApp fun args =
unsafePerformIO $ unsafePerformIO $
withCString fun $ \cfun -> withCString fun $ \cfun ->
@@ -215,7 +218,7 @@ mkApp fun args =
where where
len = length args len = length args
unApp :: Expr -> Maybe (String,[Expr]) unApp :: Expr -> Maybe (Fun,[Expr])
unApp (Expr expr master) = unApp (Expr expr master) =
unsafePerformIO $ unsafePerformIO $
withGuPool $ \pl -> do withGuPool $ \pl -> do
@@ -269,7 +272,7 @@ showExpr e =
-- Functions using Concr -- Functions using Concr
-- Morpho analyses, parsing & linearization -- Morpho analyses, parsing & linearization
type MorphoAnalysis = (String,String,Float) type MorphoAnalysis = (Fun,String,Float)
lookupMorpho :: Concr -> String -> [MorphoAnalysis] lookupMorpho :: Concr -> String -> [MorphoAnalysis]
lookupMorpho (Concr concr master) sent = unsafePerformIO $ lookupMorpho (Concr concr master) sent = unsafePerformIO $
@@ -316,11 +319,11 @@ getAnalysis ref self c_lemma c_anal prob exn = do
anal <- peekCString c_anal anal <- peekCString c_anal
writeIORef ref ((lemma, anal, prob):ans) writeIORef ref ((lemma, anal, prob):ans)
parse :: Concr -> String -> String -> Either String [(Expr,Float)] parse :: Concr -> Cat -> String -> Either String [(Expr,Float)]
parse lang cat sent = parseWithHeuristics lang cat sent (-1.0) [] parse lang cat sent = parseWithHeuristics lang cat sent (-1.0) []
parseWithHeuristics :: Concr -- ^ the language with which we parse parseWithHeuristics :: Concr -- ^ the language with which we parse
-> String -- ^ the start category -> Cat -- ^ the start category
-> String -- ^ the input sentence -> String -- ^ the input sentence
-> Double -- ^ the heuristic factor. -> Double -- ^ the heuristic factor.
-- A negative value tells the parser -- A negative value tells the parser