mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-13 06:49:31 -06:00
"Committed_by_peb"
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
|
||||
concrete FragmentNumber of FragmentAbstract = open FragmentResource in {
|
||||
|
||||
flags startcat= S;
|
||||
|
||||
lincat
|
||||
|
||||
N = { s : Num => Str };
|
||||
|
||||
@@ -5,7 +5,7 @@ lincat S = {s1:Str; s2:AB => Str};
|
||||
|
||||
lin
|
||||
|
||||
f x = { s1 = x.s2 ! A;
|
||||
f x = { s1 = [];
|
||||
s2 = table{ y => variants{ x.s2 ! A; x.s1 ++ x.s2 ! y } } };
|
||||
|
||||
a = { s1 = "a" ++ variants{ "b"; "c" };
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
-- Stability : (stable)
|
||||
-- Portability : (portable)
|
||||
--
|
||||
-- > CVS $Date: 2005/05/17 13:38:46 $
|
||||
-- > CVS $Date: 2005/05/30 08:11:32 $
|
||||
-- > CVS $Author: peb $
|
||||
-- > CVS $Revision: 1.11 $
|
||||
-- > CVS $Revision: 1.12 $
|
||||
--
|
||||
-- All conversions from GFC
|
||||
-----------------------------------------------------------------------------
|
||||
@@ -29,6 +29,7 @@ import qualified GF.Conversion.GFCtoSimple as G2S
|
||||
import qualified GF.Conversion.SimpleToFinite as S2Fin
|
||||
import qualified GF.Conversion.RemoveSingletons as RemSing
|
||||
import qualified GF.Conversion.RemoveErasing as RemEra
|
||||
import qualified GF.Conversion.RemoveEpsilon as RemEps
|
||||
import qualified GF.Conversion.SimpleToMCFG as S2M
|
||||
import qualified GF.Conversion.MCFGtoCFG as M2C
|
||||
|
||||
@@ -49,6 +50,7 @@ gfc2mcfg2cfg opts = \g -> let e = g2e g in trace2 "Options" (show opts) (e2m e,
|
||||
Just "strict" -> simple2mcfg_strict . gfc2simple
|
||||
Just "finite" -> simple2mcfg_nondet . simple2finite . gfc2simple
|
||||
Just "singletons" -> simple2mcfg_nondet . removeSingletons . gfc2simple
|
||||
Just "epsilon" -> removeEpsilon . simple2mcfg_nondet . gfc2simple
|
||||
Just "finite-singletons" -> simple2mcfg_nondet . removeSingletons . simple2finite . gfc2simple
|
||||
Just "finite-strict" -> simple2mcfg_strict . simple2finite . gfc2simple
|
||||
_ -> simple2mcfg_nondet . gfc2simple
|
||||
@@ -83,6 +85,9 @@ mcfg2cfg = M2C.convertGrammar
|
||||
removeErasing :: EGrammar -> [SCat] -> MGrammar
|
||||
removeErasing = RemEra.convertGrammar
|
||||
|
||||
removeEpsilon :: EGrammar -> EGrammar
|
||||
removeEpsilon = RemEps.convertGrammar
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- * converting to some obscure formats
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
-- Stability : (stable)
|
||||
-- Portability : (portable)
|
||||
--
|
||||
-- > CVS $Date: 2005/04/21 16:21:52 $
|
||||
-- > CVS $Author: bringert $
|
||||
-- > CVS $Revision: 1.2 $
|
||||
-- > CVS $Date: 2005/05/30 08:11:32 $
|
||||
-- > CVS $Author: peb $
|
||||
-- > CVS $Revision: 1.3 $
|
||||
--
|
||||
-- Removing epsilon linearizations from MCF grammars
|
||||
-----------------------------------------------------------------------------
|
||||
@@ -30,7 +30,17 @@ import GF.Data.SortedList
|
||||
import GF.Data.GeneralDeduction
|
||||
|
||||
convertGrammar :: EGrammar -> EGrammar
|
||||
convertGrammar grammar = undefined
|
||||
convertGrammar grammar = trace2 "RemoveEpsilon: initialEmpties" (prt initialEmpties) $
|
||||
trace2 "RemoveEpsilon: emptyCats" (prt emptyCats) $
|
||||
grammar
|
||||
where initialEmpties = nubsort [ (cat, lbl) |
|
||||
Rule (Abs cat _ _) (Cnc _ _ lins) <- grammar,
|
||||
Lin lbl [] <- lins ]
|
||||
emptyCats = limitEmpties initialEmpties
|
||||
limitEmpties es = if es==es' then es else limitEmpties es'
|
||||
where es' = nubsort [ (cat, lbl) | Rule (Abs cat _ _) (Cnc _ _ lins) <- grammar,
|
||||
Lin lbl rhs <- lins,
|
||||
all (symbol (\(c,l,n) -> (c,l) `elem` es) (const False)) rhs ]
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user