summaryrefslogtreecommitdiff
path: root/src/GF/Canon/GFCC
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2006-09-25 13:03:33 +0000
committeraarne <aarne@cs.chalmers.se>2006-09-25 13:03:33 +0000
commit902ff81773fc6eb63512fbb95fc8e3d5ead0e738 (patch)
tree9b3e77be37806fa7144f9a4a5f7ad3641eafeb59 /src/GF/Canon/GFCC
parent9ae36df22079e072b302ad966fc98963d97d2654 (diff)
some fixes in gfcc compilation
Diffstat (limited to 'src/GF/Canon/GFCC')
-rw-r--r--src/GF/Canon/GFCC/DataGFCC.hs14
-rw-r--r--src/GF/Canon/GFCC/RunGFCC.hs8
-rw-r--r--src/GF/Canon/GFCC/Test.gf20
3 files changed, 27 insertions, 15 deletions
diff --git a/src/GF/Canon/GFCC/DataGFCC.hs b/src/GF/Canon/GFCC/DataGFCC.hs
index 0c38a3826..9571d7c23 100644
--- a/src/GF/Canon/GFCC/DataGFCC.hs
+++ b/src/GF/Canon/GFCC/DataGFCC.hs
@@ -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
diff --git a/src/GF/Canon/GFCC/RunGFCC.hs b/src/GF/Canon/GFCC/RunGFCC.hs
index a013d7ccb..5caa5e8d2 100644
--- a/src/GF/Canon/GFCC/RunGFCC.hs
+++ b/src/GF/Canon/GFCC/RunGFCC.hs
@@ -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)
{-
diff --git a/src/GF/Canon/GFCC/Test.gf b/src/GF/Canon/GFCC/Test.gf
index 6cbbd367c..efb77eff6 100644
--- a/src/GF/Canon/GFCC/Test.gf
+++ b/src/GF/Canon/GFCC/Test.gf
@@ -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" ;