1
0
forked from GitHub/gf-core

some fixes in gfcc compilation

This commit is contained in:
aarne
2006-09-25 13:03:33 +00:00
parent 71ddbc1346
commit d386213c14
4 changed files with 32 additions and 19 deletions

View File

@@ -27,11 +27,11 @@ statGFCC gfcc = unlines [
type Concr = Map CId Term
lookMap :: (Show i, Ord i) => i -> Map i a -> a
lookMap c m = maybe (error ("cannot find " ++ show c)) id $ Data.Map.lookup c m
lookMap :: (Show i, Ord i) => a -> i -> Map i a -> a
lookMap d c m = maybe d id $ Data.Map.lookup c m
lookLin :: GFCC -> CId -> CId -> Term
lookLin mcfg lang fun = lookMap fun $ lookMap lang $ concretes mcfg
lookLin mcfg lang fun = lookMap term0 fun $ lookMap undefined lang $ concretes mcfg
linearize :: GFCC -> CId -> Exp -> String
linearize mcfg lang = realize . linExp mcfg lang
@@ -57,6 +57,12 @@ linExp mcfg lang tree@(Tr at trees) =
comp = compute mcfg lang
look = lookLin mcfg lang
exp0 :: Exp
exp0 = Tr (AS "NO_PARSE") []
term0 :: Term
term0 = kks "UNKNOWN_ID"
kks :: String -> Term
kks = K . KS
@@ -81,7 +87,7 @@ compute mcfg lang args = compg [] where
W s t -> W s (comp t)
R ts -> R $ Prelude.map comp ts
V i -> idx args (fromInteger i) -- already computed
S ts -> S (Prelude.map comp ts)
S ts -> S $ Prelude.filter (/= S []) $ Prelude.map comp ts
F c -> comp $ look c -- global const: not comp'd (if contains argvar)
FV ts -> FV $ Prelude.map comp ts
_ -> trm

View File

@@ -39,9 +39,11 @@ treat grammar s = case words s of
_ -> putStrLn "no parse found"
_ -> lins $ readExp s
where
lins t = mapM_ (lin t) $ cncnames grammar
lins t = mapM_ (lint t) $ cncnames grammar
lint t lang = do
putStrLn $ printTree $ linExp grammar lang t
lin t lang
lin t lang = do
-- putStrLn $ printTree $ linExp grammar lang t
putStrLn $ linearize grammar lang t
prlins t = do
putStrLn $ printTree t
@@ -54,7 +56,7 @@ file2gfcc f =
readFile f >>= err (error "no parse") (return . mkGFCC) . pGrammar . myLexer
readExp :: String -> Exp
readExp = err (error "no parse") id . (pExp . myLexer)
readExp = errVal exp0 . (pExp . myLexer)
{-

View File

@@ -24,6 +24,7 @@ lincat VP = Verb ;
oper Noun = {s : NForm => Str} ;
oper Verb = {s : VForm => Str} ;
-- {-
lincat NP = {s : Case => Str ; n : Number ; p : Person} ;
lin Pred np vp = {s = np.s ! Nom ++ vp.s ! VF np.n np.p} ;
lin Pred2 np vp ob = {s = np.s ! Nom ++ vp.s ! VF np.n np.p ++ ob.s ! Part} ;
@@ -31,16 +32,19 @@ lin Det no = {s = \\c => no.s ! NF Sg c ; n = Sg ; p = P3} ;
lin Dets no = {s = \\c => no.s ! NF Pl c ; n = Pl ; p = P3} ;
lin Mina = {s = table Case ["minä" ; "minua"] ; n = Sg ; p = P1} ;
lin Te = {s = table Case ["te" ; "teitä"] ; n = Pl ; p = P2} ;
--lincat NP = {s : Case => Str ; a : {n : Number ; p : Person}} ;
--lin Pred np vp = {s = np.s ! Nom ++ vp.s ! VF np.a.n np.a.p} ;
--lin Pred2 np vp ob = {s = np.s ! Nom ++ vp.s ! VF np.a.n np.a.p ++ ob.s ! Part} ;
--lin Det no = {s = \\c => no.s ! NF Sg c ; a = {n = Sg ; p = P3}} ;
--lin Dets no = {s = \\c => no.s ! NF Pl c ; a = {n = Pl ; p = P3}} ;
--lin Mina = {s = table Case ["minä" ; "minua"] ; a = {n = Sg ; p = P1}} ;
--lin Te = {s = table Case ["te" ; "teitä"] ; a = {n = Pl ; p = P2}} ;
-- -}
{-
lincat NP = {s : Case => Str ; a : {n : Number ; p : Person}} ;
lin Pred np vp = {s = np.s ! Nom ++ vp.s ! VF np.a.n np.a.p} ;
lin Pred2 np vp ob = {s = np.s ! Nom ++ vp.s ! VF np.a.n np.a.p ++ ob.s ! Part} ;
lin Det no = {s = \\c => no.s ! NF Sg c ; a = {n = Sg ; p = P3}} ;
lin Dets no = {s = \\c => no.s ! NF Pl c ; a = {n = Pl ; p = P3}} ;
lin Mina = {s = table Case ["minä" ; "minua"] ; a = {n = Sg ; p = P1}} ;
lin Te = {s = table Case ["te" ; "teitä"] ; a = {n = Pl ; p = P2}} ;
-}
lin Raha = mkN "raha" ;
lin Raha = mkN "raha" ;
lin Paska = mkN "paska" ;
lin Pallo = mkN "pallo" ;
lin Puhua = mkV "puhu" ;