1
0
forked from GitHub/gf-core

simplified 1.5 by removing mathematical/

This commit is contained in:
aarne
2008-10-06 12:49:13 +00:00
parent f376576af0
commit e56e6483f6
29 changed files with 308 additions and 51 deletions

View File

@@ -49,14 +49,11 @@ langsCoding = [
langs = map fst langsCoding langs = map fst langsCoding
-- languagues for which to compile Lang -- languagues for which to compile Lang
langsLang = langs `except` ["Ara"] langsLang = langs `except` ["Ara","Bul","Ina","Rus"]
-- languages for which to compile Try -- languages for which to compile Try
langsAPI = langsLang `except` ["Ara","Bul","Hin","Ina","Rus","Tha"] langsAPI = langsLang `except` ["Ara","Bul","Hin","Ina","Rus","Tha"]
-- languages for which to compile Mathematical
langsMath = langsAPI
-- languages for which to run treebank test -- languages for which to run treebank test
langsTest = langsLang `except` ["Ara","Bul","Cat","Hin","Rus","Spa","Tha"] langsTest = langsLang `except` ["Ara","Bul","Cat","Hin","Rus","Spa","Tha"]
@@ -88,17 +85,10 @@ make xx = do
ifx "lang" $ do ifx "lang" $ do
mapM_ (gfc pres [] . lang) (optl langsLang) mapM_ (gfc pres [] . lang) (optl langsLang)
copy "*/*.gfo" dir copy "*/*.gfo" dir
ifx "compat" $ do
mapM_ (gfc pres [] . compat) (optl langsCompat)
copy "*/Compatibility*.gfo" dir
ifx "api" $ do ifx "api" $ do
mapM_ (gfc pres presApiPath . try) (optl langsAPI) mapM_ (gfc pres presApiPath . try) (optl langsAPI)
mapM_ (gfc pres presApiPath . symbolic) (optl langsAPI)
copy "*/*.gfo" dir copy "*/*.gfo" dir
ifx "math" $ do
mapM_ (gfc False [] . math) (optl langsMath)
copy "mathematical/*.gfo" "../mathematical"
mapM_ (gfc False [] . symbolic) (optl langsMath)
copy "mathematical/Symbolic*.gfo" "../mathematical"
ifxx "pgf" $ do ifxx "pgf" $ do
run_gfc $ ["-s","--make","--name=langs","--parser=off", run_gfc $ ["-s","--make","--name=langs","--parser=off",
"--output-dir=" ++ dir] "--output-dir=" ++ dir]
@@ -138,10 +128,8 @@ demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
" | ps -to_html | wf -file=resdemo.html" " | ps -to_html | wf -file=resdemo.html"
lang (lla,la) = lla ++ "/All" ++ la ++ ".gf" lang (lla,la) = lla ++ "/All" ++ la ++ ".gf"
compat (lla,la) = lla ++ "/Compatibility" ++ la ++ ".gf"
try (lla,la) = "api/Try" ++ la ++ ".gf" try (lla,la) = "api/Try" ++ la ++ ".gf"
math (lla,la) = "mathematical/Mathematical" ++ la ++ ".gf" symbolic (lla,la) = "api/Symbolic" ++ la ++ ".gf"
symbolic (lla,la) = "mathematical/Symbolic" ++ la ++ ".gf"
except ls es = filter (flip notElem es . snd) ls except ls es = filter (flip notElem es . snd) ls
only ls es = filter (flip elem es . snd) ls only ls es = filter (flip elem es . snd) ls

View File

@@ -1510,7 +1510,8 @@ incomplete resource Constructors = open Grammar in {
= \p,i -> TExclMark (PhrUtt NoPConj (UttImpSg p i) NoVoc) TEmpty; = \p,i -> TExclMark (PhrUtt NoPConj (UttImpSg p i) NoVoc) TEmpty;
mkText : Phr -> Text -> Text -- John walks. ... mkText : Phr -> Text -> Text -- John walks. ...
= TFullStop ; = TFullStop ;
mkText : Text -> Text -> Text = \t,u -> {s = t.s ++ u.s ; lock_Text = <>} ; mkText : Text -> Text -> Text
= \t,u -> {s = t.s ++ u.s ; lock_Text = <>} ;
} ; } ;
mkVP = overload { mkVP = overload {

View File

@@ -1,12 +1,11 @@
--1 Symbolic: Noun Phrases with mathematical symbols --1 Symbolic: Noun Phrases with mathematical symbols
incomplete resource Symbolic = open incomplete resource Symbolic = open Symbol, Grammar in {
Symbol, Syntax, PredefCnc in {
oper oper
symb : overload { symb : overload {
symb : Str -> NP ; -- x symb : Str -> NP ; -- x
symb : Int -> NP ; -- 23 symb : Integer -> NP ; -- 23
symb : Float -> NP ; -- 0.99 symb : Float -> NP ; -- 0.99
symb : N -> Digits -> NP ; -- level 4 symb : N -> Digits -> NP ; -- level 4
symb : N -> Card -> NP ; -- level four symb : N -> Card -> NP ; -- level four
@@ -14,49 +13,44 @@ incomplete resource Symbolic = open
symb : Det -> N -> Card -> NP ; -- the number four symb : Det -> N -> Card -> NP ; -- the number four
symb : Det -> CN -> Card -> NP ; -- the even number four symb : Det -> CN -> Card -> NP ; -- the even number four
symb : Det -> N -> Str -> Str -> NP ; -- the levels i and j symb : Det -> N -> Str -> Str -> NP ; -- the levels i and j
symb : Det -> CN -> [Symb] -> NP ; -- the basic levels i, j, and k symb : Det -> CN -> [Symb] -> NP -- the basic levels i, j, and k
symb : Symb -> S ; -- A
symb : Symb -> Card ; -- n
symb : Symb -> Ord -- n'th
} ; } ;
mkSymb : Str -> Symb ; mkSymb : Str -> Symb ;
mkInt : Str -> PredefCnc.Int ; mkInteger : Predef.Int -> Integer ;
mkFloat : Str -> PredefCnc.Float ; mkFloating : Predef.Float -> Floating ;
--. --.
symb = overload { symb = overload {
symb : Str -> NP symb : Str -> NP
= \s -> mkNP (SymbPN (mkSymb s)) ; = \s -> UsePN (SymbPN (mkSymb s)) ;
symb : Int -> NP symb : Integer -> NP
= \i -> mkNP (IntPN i) ; = \i -> UsePN (IntPN i) ;
symb : Float -> NP symb : Floating -> NP
= \i -> mkNP (FloatPN i) ; = \i -> UsePN (FloatPN i) ;
symb : N -> Digits -> NP symb : N -> Digits -> NP
= \c,i -> CNNumNP (mkCN c) (mkCard i) ; = \c,i -> CNNumNP (UseN c) (NumDigits i) ;
symb : N -> Card -> NP symb : N -> Card -> NP
= \c,n -> CNNumNP (mkCN c) n ; = \c,n -> CNNumNP (UseN c) n ;
symb : CN -> Card -> NP symb : CN -> Card -> NP
= \c,n -> CNNumNP c n ; = \c,n -> CNNumNP c n ;
symb : Det -> N -> Card -> NP symb : Det -> N -> Card -> NP
= \d,n,x -> mkNP d (mkCN (mkCN n) (mkNP (NumPN x))) ; = \d,n,x -> DetCN d (ApposCN (UseN n) (UsePN (NumPN x))) ;
symb : Det -> CN -> Card -> NP symb : Det -> CN -> Card -> NP
= \d,n,x -> mkNP d (mkCN n (mkNP (NumPN x))) ; = \d,n,x -> DetCN d (ApposCN n (UsePN (NumPN x))) ;
symb : Det -> N -> Str -> Str -> NP symb : Det -> N -> Str -> Str -> NP
= \c,n,x,y -> CNSymbNP c (mkCN n) (BaseSymb (mkSymb x) (mkSymb y)) ; = \c,n,x,y -> CNSymbNP c (UseN n) (BaseSymb (mkSymb x) (mkSymb y)) ;
symb : Det -> CN -> [Symb] -> NP symb : Det -> CN -> [Symb] -> NP
= CNSymbNP ; = CNSymbNP
symb : Symb -> S = SymbS ;
symb : Symb -> Card = SymbNum ;
symb : Symb -> Ord = SymbOrd
} ; } ;
mkSymb : Str -> Symb = \s -> {s = s ; lock_Symb = <>} ; mkSymb : Str -> Symb = \s -> {s = s ; lock_Symb = <>} ;
mkInt i = {s = i ; lock_Int = <>} ; mkInteger i = {s = Predef.show Predef.Int i ; lock_Int = <>} ;
mkFloat f = {s = f ; lock_Float = <>} ; mkFloating f = {s = Predef.show Predef.Float f ; lock_Float = <>} ;
Integer : Type = {s : Str ; lock_Int : {}} ;
Floating : Type = {s : Str ; lock_Float : {}} ;
} }

View File

@@ -0,0 +1,5 @@
--# -path=.:present:prelude
resource SymbolicCat = Symbolic with
(Symbol = SymbolCat),
(Syntax = SyntaxCat) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicDan = Symbolic with
(Symbol = SymbolDan),
(Grammar = GrammarDan) ;

View File

@@ -1,5 +1,5 @@
--# -path=.:present:prelude --# -path=.:present:mathematical:prelude
resource SymbolicEng = Symbolic with resource SymbolicEng = Symbolic with
(Symbol = SymbolEng), (Symbol = SymbolEng),
(Syntax = SyntaxEng) ; (Grammar = GrammarEng) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicFin = Symbolic with
(Symbol = SymbolFin),
(Grammar = GrammarFin) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicFre = Symbolic with
(Symbol = SymbolFre),
(Grammar = GrammarFre) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicGer = Symbolic with
(Symbol = SymbolGer),
(Grammar = GrammarGer) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicIta = Symbolic with
(Symbol = SymbolIta),
(Grammar = GrammarIta) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicNor = Symbolic with
(Symbol = SymbolNor),
(Grammar = GrammarNor) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicSpa = Symbolic with
(Symbol = SymbolSpa),
(Grammar = GrammarSpa) ;

View File

@@ -0,0 +1,5 @@
--# -path=.:present:mathematical:prelude
resource SymbolicSwe = Symbolic with
(Symbol = SymbolSwe),
(Grammar = GrammarSwe) ;

View File

@@ -21,4 +21,32 @@ concrete IdiomCat of Idiom = CatCat **
) )
(predV (verbV (estar_54 "estar"))) ; (predV (verbV (estar_54 "estar"))) ;
----AR, for completeness
CleftNP np rs = mkClause [] True (agrP3 Masc Sg)
(insertComplement (\\_ => rs.s ! Indic ! np.a)
(insertComplement (\\_ => np.s ! Ton rs.c) (predV copula))) ;
ExistIP ip = {
s = \\t,a,p,_ =>
ip.s ! Nom ++
(mkClause [] True
(agrP3 Masc Sg)
(insertClit2 "hi" (insertComplement (\\_ => ip.s ! Acc) (predV haver_V))))
.s ! DDir ! t ! a ! p ! Indic
} ;
ImpPl1 vpr = let vp = useVP vpr in {s =
(mkImperative False P1 vp).s ! Pos ! {n = Pl ; g = Masc} --- fem
} ;
CleftAdv ad s = mkClause [] True (agrP3 Masc Sg)
(insertComplement (\\_ => conjThat ++ s.s ! Indic)
(insertComplement (\\_ => ad.s) (predV copula))) ;
} }

View File

@@ -0,0 +1,2 @@
concrete SymbolCat of Symbol = CatCat ** SymbolRomance with
(ResRomance = ResCat) ;

View File

@@ -0,0 +1,2 @@
concrete SymbolDan of Symbol = CatDan ** SymbolScand with
(ResScand = ResDan) ;

View File

@@ -68,12 +68,10 @@ concrete ExtraFin of ExtraFinAbs = CatFin **
isPron = False isPron = False
} ; } ;
vai_Conj = {s1 = [] ; s2 = "vai" ; n = Sg} ; vai_Conj = {s1 = [] ; s2 = "vai" ; n = Sg} ;
CompPartAP ap = { CompPartAP ap = {
s = \\agr => ap.s ! False ! AN (NCase agr.n Part) s = \\agr => ap.s ! False ! NCase agr.n Part
} ; } ;
} }

View File

@@ -0,0 +1,42 @@
concrete SymbolFin of Symbol = CatFin ** open Prelude, NounFin, ResFin in {
lin
SymbPN i = {s = \\c => i.s} ; --- c
IntPN i = {s = \\c => i.s} ; --- c
FloatPN i = {s = \\c => i.s} ; --- c
NumPN i = {s = \\c => i.s!Sg!Nom } ; --- c
CNIntNP cn i = {
s = \\c => cn.s ! NCase Sg (npform2case Sg c) ++ i.s ;
a = agrP3 Sg ;
isPron = False
} ;
CNSymbNP det cn xs = let detcn = NounFin.DetCN det cn in {
s = \\c => detcn.s ! c ++ xs.s ;
a = detcn.a ;
isPron = False
} ;
CNNumNP cn i = {
s = \\c => cn.s ! NCase Sg (npform2case Sg c) ++ i.s ! Sg ! Nom ;
a = agrP3 Sg ;
isPron = False
} ;
SymbS sy = sy ;
SymbNum n = {s = \\_,_ => n.s ; isNum = True ; n = Pl} ;
SymbOrd n = {s = \\_,_ => n.s ++ "."} ;
lincat
Symb, [Symb] = SS ;
lin
MkSymb s = s ;
BaseSymb = infixSS "ja" ;
ConsSymb = infixSS "," ;
}

View File

@@ -0,0 +1,2 @@
concrete SymbolFre of Symbol = CatFre ** SymbolRomance with
(ResRomance = ResFre) ;

View File

@@ -95,6 +95,8 @@ concrete CatGer of Cat =
Tense = {s : Str ; t : ResGer.Tense ; m : Mood} ; Tense = {s : Str ; t : ResGer.Tense ; m : Mood} ;
lin lin
TTAnt t a = {s = t.s ++ a.s ; t = t.t ; a = a.a ; m = t.m} ;
TPres = {s = [] ; t = Pres ; m = MIndic} ; TPres = {s = [] ; t = Pres ; m = MIndic} ;
TPast = {s = [] ; t = Past ; m = MIndic} ; --# notpresent TPast = {s = [] ; t = Past ; m = MIndic} ; --# notpresent
TFut = {s = [] ; t = Fut ; m = MIndic} ; --# notpresent TFut = {s = [] ; t = Fut ; m = MIndic} ; --# notpresent

View File

@@ -0,0 +1,43 @@
concrete SymbolGer of Symbol = CatGer ** open Prelude, ResGer in {
lin
SymbPN i = {s = \\c => i.s ; g = Neutr} ; --- c
IntPN i = {s = \\c => i.s ; g = Neutr} ; --- c
FloatPN i = {s = \\c => i.s ; g = Neutr} ; --- c
NumPN i = {s = i.s ! Neutr ; g = Neutr} ; --- c
CNIntNP cn i = {
s = \\c => cn.s ! Weak ! Sg ! Nom ++ i.s ;
a = agrP3 Sg ;
isPron = False
} ;
CNSymbNP det cn xs = let g = cn.g in {
s = \\c => det.s ! g ! c ++ cn.s ! adjfCase det.a c ! det.n ! c ++ xs.s ;
a = agrP3 det.n ;
isPron = False
} ;
CNNumNP cn i = {
s = \\c => artDef ! (GSg cn.g) ! c ++ cn.s ! Weak ! Sg ! Nom ++ i.s ! Neutr ! c ;
a = agrP3 Sg ;
isPron = False
} ;
SymbS sy = {s = \\_ => sy.s} ;
SymbNum n = {s = \\_,_ => n.s ; n = Pl ; isNum = True} ;
SymbOrd n = {s = \\_ => n.s ++ "."} ;
lincat
Symb, [Symb] = SS ;
lin
MkSymb s = s ;
BaseSymb = infixSS "und" ;
ConsSymb = infixSS "," ;
}

View File

@@ -0,0 +1,2 @@
concrete SymbolIta of Symbol = CatIta ** SymbolRomance with
(ResRomance = ResIta) ;

View File

@@ -0,0 +1,2 @@
concrete SymbolNor of Symbol = CatNor ** SymbolScand with
(ResScand = ResNor) ;

View File

@@ -0,0 +1,41 @@
incomplete concrete SymbolRomance of Symbol =
CatRomance ** open Prelude, CommonRomance, ResRomance in {
lin
SymbPN i = {s = i.s ; g = Masc} ;
IntPN i = {s = i.s ; g = Masc} ;
FloatPN i = {s = i.s ; g = Masc} ;
NumPN i = {s = i.s!Masc ; g = Masc} ;
CNIntNP cn i = {
s = \\c => cn.s ! Sg ++ i.s ;
a = agrP3 cn.g Sg ;
hasClit = False
} ;
CNSymbNP det cn xs = let g = cn.g in {
s = \\c => det.s ! g ! npform2case c ++ cn.s ! det.n ++ xs.s ;
a = agrP3 g det.n ;
hasClit = False
} ;
CNNumNP cn i = {
s = \\c => artDef cn.g Sg (npform2case c) ++ cn.s ! Sg ++ i.s ! Masc ;
a = agrP3 cn.g Sg ;
hasClit = False
} ;
SymbS sy = {s = \\_ => sy.s} ;
SymbNum n = {s = \\_ => n.s ; isNum = True ; n = Pl} ;
SymbOrd n = {s = \\_ => n.s ++ "."} ; ---
lincat
Symb, [Symb] = SS ;
lin
MkSymb s = s ;
BaseSymb = infixSS "et" ; ----
ConsSymb = infixSS "," ;
}

View File

@@ -0,0 +1,38 @@
incomplete concrete SymbolScand of Symbol =
CatScand ** open Prelude, ResScand, CommonScand in {
lin
SymbPN i = {s = \\c => i.s ; g = Neutr} ; --- c
IntPN i = {s = \\c => i.s ; g = Neutr} ; --- c
FloatPN i = {s = \\c => i.s ; g = Neutr} ; --- c
NumPN i = {s = \\c => i.s!neutrum ; g = Neutr} ; --- c
CNIntNP cn i = {
s = \\c => (cn.s ! Sg ! DIndef ! Nom ++ i.s) ;
a = agrP3 cn.g Sg
} ;
CNSymbNP det cn xs = let g = cn.g in {
s = \\c => det.s ! cn.isMod ! g ++ cn.s ! det.n ! det.det ! caseNP c ++ xs.s ;
a = agrP3 g det.n
} ;
CNNumNP cn i = {
s = \\c => (cn.s ! Sg ! DIndef ! Nom ++ i.s ! neutrum) ;
a = agrP3 cn.g Sg
} ;
SymbS sy = {s = \\_ => sy.s} ;
SymbNum n = {s = \\_ => n.s ; isDet = True ; n = Pl} ;
SymbOrd n = {s = n.s ++ ":te" ; isDet = True} ; ---
lincat
Symb, [Symb] = SS ;
lin
MkSymb s = s ;
BaseSymb = infixSS conjAnd ;
ConsSymb = infixSS "," ;
}

View File

@@ -0,0 +1,2 @@
concrete SymbolSpa of Symbol = CatSpa ** SymbolRomance with
(ResRomance = ResSpa) ;

View File

@@ -0,0 +1,2 @@
concrete SymbolSwe of Symbol = CatSwe ** SymbolScand with
(ResScand = ResSwe) ;

View File

@@ -11,8 +11,10 @@ import GF.Compile.AbsCompute
-- for conversions -- for conversions
import PGF.Data import PGF.Data
--import GF.Compile.GrammarToGFCC (mkType,mkExp) --import GF.Compile.GrammarToGFCC (mkType,mkExp)
import GF.Grammar.Grammar import qualified GF.Grammar.Grammar as G
import qualified GF.Grammar.Macros as M
import Data.List
type TreeOp = [Tree] -> [Tree] type TreeOp = [Tree] -> [Tree]
@@ -24,7 +26,7 @@ allTreeOps = [
("compute",("compute by using semantic definitions (def)", ("compute",("compute by using semantic definitions (def)",
id)), id)),
("smallest",("sort trees from smallest to largest, in number of nodes", ("smallest",("sort trees from smallest to largest, in number of nodes",
id)), smallest)),
("typecheck",("type check and solve metavariables; reject if incorrect", ("typecheck",("type check and solve metavariables; reject if incorrect",
id)) id))
] ]
@@ -35,7 +37,24 @@ typeCheck pgf t = (t,(True,[]))
compute :: PGF -> Tree -> Tree compute :: PGF -> Tree -> Tree
compute pgf t = t compute pgf t = t
smallest :: [Tree] -> [Tree]
smallest = sortBy (\t u -> compare (size t) (size u)) where
size t = case t of
Abs _ b -> size b + 1
Fun f ts -> sum (map size ts) + 1
_ -> 1
{-
toTree :: G.Term -> Tree
toTree t = case M.termForm t of
Ok (xx,f,aa) -> Abs xx (Fun f (map toTree aa))
fromTree :: Tree -> G.Term
fromTree t = case t of
Abs xx b -> M.mkAbs xx (fromTree b)
Var x -> M.vr x
Fun f ts -> M.mkApp f (map fromTree ts)
-}
{- {-
data Tree = data Tree =

View File

@@ -34,6 +34,10 @@ lookType :: PGF -> CId -> Type
lookType pgf f = lookType pgf f =
fst $ lookMap (error $ "lookType " ++ show f) f (funs (abstract pgf)) fst $ lookMap (error $ "lookType " ++ show f) f (funs (abstract pgf))
lookDef :: PGF -> CId -> Expr
lookDef pgf f =
snd $ lookMap (error $ "lookDef " ++ show f) f (funs (abstract pgf))
lookValCat :: PGF -> CId -> CId lookValCat :: PGF -> CId -> CId
lookValCat pgf = valCat . lookType pgf lookValCat pgf = valCat . lookType pgf
@@ -137,4 +141,4 @@ combinations t = case t of
aa:uu -> [a:u | a <- aa, u <- combinations uu] aa:uu -> [a:u | a <- aa, u <- combinations uu]
isLiteralCat :: CId -> Bool isLiteralCat :: CId -> Bool
isLiteralCat = (`elem` [mkCId "String", mkCId "Float", mkCId "Int"]) isLiteralCat = (`elem` [mkCId "String", mkCId "Float", mkCId "Int"])