From e765b97fc483d5e737794a0aa90890ab2a1b2028 Mon Sep 17 00:00:00 2001 From: aarne Date: Mon, 6 Oct 2008 12:49:13 +0000 Subject: [PATCH] simplified 1.5 by removing mathematical/ --- next-lib/src/Make.hs | 18 ++------- next-lib/src/api/Constructors.gf | 3 +- next-lib/src/api/Symbolic.gf | 48 +++++++++++------------- next-lib/src/api/SymbolicCat.gf | 5 +++ next-lib/src/api/SymbolicDan.gf | 5 +++ next-lib/src/api/SymbolicEng.gf | 4 +- next-lib/src/api/SymbolicFin.gf | 5 +++ next-lib/src/api/SymbolicFre.gf | 5 +++ next-lib/src/api/SymbolicGer.gf | 5 +++ next-lib/src/api/SymbolicIta.gf | 5 +++ next-lib/src/api/SymbolicNor.gf | 5 +++ next-lib/src/api/SymbolicSpa.gf | 5 +++ next-lib/src/api/SymbolicSwe.gf | 5 +++ next-lib/src/catalan/IdiomCat.gf | 28 ++++++++++++++ next-lib/src/catalan/SymbolCat.gf | 2 + next-lib/src/danish/SymbolDan.gf | 2 + next-lib/src/finnish/ExtraFin.gf | 4 +- next-lib/src/finnish/SymbolFin.gf | 42 +++++++++++++++++++++ next-lib/src/french/SymbolFre.gf | 2 + next-lib/src/german/CatGer.gf | 2 + next-lib/src/german/SymbolGer.gf | 43 +++++++++++++++++++++ next-lib/src/italian/SymbolIta.gf | 2 + next-lib/src/norwegian/SymbolNor.gf | 2 + next-lib/src/romance/SymbolRomance.gf | 41 ++++++++++++++++++++ next-lib/src/scandinavian/SymbolScand.gf | 38 +++++++++++++++++++ next-lib/src/spanish/SymbolSpa.gf | 2 + next-lib/src/swedish/SymbolSwe.gf | 2 + src/GF/Command/TreeOperations.hs | 23 +++++++++++- src/PGF/Macros.hs | 6 ++- 29 files changed, 308 insertions(+), 51 deletions(-) create mode 100644 next-lib/src/api/SymbolicCat.gf create mode 100644 next-lib/src/api/SymbolicDan.gf create mode 100644 next-lib/src/api/SymbolicFin.gf create mode 100644 next-lib/src/api/SymbolicFre.gf create mode 100644 next-lib/src/api/SymbolicGer.gf create mode 100644 next-lib/src/api/SymbolicIta.gf create mode 100644 next-lib/src/api/SymbolicNor.gf create mode 100644 next-lib/src/api/SymbolicSpa.gf create mode 100644 next-lib/src/api/SymbolicSwe.gf create mode 100644 next-lib/src/catalan/SymbolCat.gf create mode 100644 next-lib/src/danish/SymbolDan.gf create mode 100644 next-lib/src/finnish/SymbolFin.gf create mode 100644 next-lib/src/french/SymbolFre.gf create mode 100644 next-lib/src/german/SymbolGer.gf create mode 100644 next-lib/src/italian/SymbolIta.gf create mode 100644 next-lib/src/norwegian/SymbolNor.gf create mode 100644 next-lib/src/romance/SymbolRomance.gf create mode 100644 next-lib/src/scandinavian/SymbolScand.gf create mode 100644 next-lib/src/spanish/SymbolSpa.gf create mode 100644 next-lib/src/swedish/SymbolSwe.gf diff --git a/next-lib/src/Make.hs b/next-lib/src/Make.hs index 973e6def1..8a597b707 100644 --- a/next-lib/src/Make.hs +++ b/next-lib/src/Make.hs @@ -49,14 +49,11 @@ langsCoding = [ langs = map fst langsCoding -- languagues for which to compile Lang -langsLang = langs `except` ["Ara"] +langsLang = langs `except` ["Ara","Bul","Ina","Rus"] -- languages for which to compile Try langsAPI = langsLang `except` ["Ara","Bul","Hin","Ina","Rus","Tha"] --- languages for which to compile Mathematical -langsMath = langsAPI - -- languages for which to run treebank test langsTest = langsLang `except` ["Ara","Bul","Cat","Hin","Rus","Spa","Tha"] @@ -88,17 +85,10 @@ make xx = do ifx "lang" $ do mapM_ (gfc pres [] . lang) (optl langsLang) copy "*/*.gfo" dir - ifx "compat" $ do - mapM_ (gfc pres [] . compat) (optl langsCompat) - copy "*/Compatibility*.gfo" dir ifx "api" $ do mapM_ (gfc pres presApiPath . try) (optl langsAPI) + mapM_ (gfc pres presApiPath . symbolic) (optl langsAPI) 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 run_gfc $ ["-s","--make","--name=langs","--parser=off", "--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" lang (lla,la) = lla ++ "/All" ++ la ++ ".gf" -compat (lla,la) = lla ++ "/Compatibility" ++ la ++ ".gf" try (lla,la) = "api/Try" ++ la ++ ".gf" -math (lla,la) = "mathematical/Mathematical" ++ la ++ ".gf" -symbolic (lla,la) = "mathematical/Symbolic" ++ la ++ ".gf" +symbolic (lla,la) = "api/Symbolic" ++ la ++ ".gf" except ls es = filter (flip notElem es . snd) ls only ls es = filter (flip elem es . snd) ls diff --git a/next-lib/src/api/Constructors.gf b/next-lib/src/api/Constructors.gf index 05f40500c..b34e7a620 100644 --- a/next-lib/src/api/Constructors.gf +++ b/next-lib/src/api/Constructors.gf @@ -1510,7 +1510,8 @@ incomplete resource Constructors = open Grammar in { = \p,i -> TExclMark (PhrUtt NoPConj (UttImpSg p i) NoVoc) TEmpty; mkText : Phr -> Text -> Text -- John walks. ... = 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 { diff --git a/next-lib/src/api/Symbolic.gf b/next-lib/src/api/Symbolic.gf index 2a621cf9c..6ce8478b9 100644 --- a/next-lib/src/api/Symbolic.gf +++ b/next-lib/src/api/Symbolic.gf @@ -1,12 +1,11 @@ --1 Symbolic: Noun Phrases with mathematical symbols -incomplete resource Symbolic = open - Symbol, Syntax, PredefCnc in { +incomplete resource Symbolic = open Symbol, Grammar in { oper symb : overload { symb : Str -> NP ; -- x - symb : Int -> NP ; -- 23 + symb : Integer -> NP ; -- 23 symb : Float -> NP ; -- 0.99 symb : N -> Digits -> NP ; -- level 4 symb : N -> Card -> NP ; -- level four @@ -14,49 +13,44 @@ incomplete resource Symbolic = open symb : Det -> N -> Card -> NP ; -- the number four symb : Det -> CN -> Card -> NP ; -- the even number four symb : Det -> N -> Str -> Str -> NP ; -- the levels i and j - 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 + symb : Det -> CN -> [Symb] -> NP -- the basic levels i, j, and k } ; - mkSymb : Str -> Symb ; - mkInt : Str -> PredefCnc.Int ; - mkFloat : Str -> PredefCnc.Float ; + mkSymb : Str -> Symb ; + mkInteger : Predef.Int -> Integer ; + mkFloating : Predef.Float -> Floating ; --. symb = overload { symb : Str -> NP - = \s -> mkNP (SymbPN (mkSymb s)) ; - symb : Int -> NP - = \i -> mkNP (IntPN i) ; - symb : Float -> NP - = \i -> mkNP (FloatPN i) ; + = \s -> UsePN (SymbPN (mkSymb s)) ; + symb : Integer -> NP + = \i -> UsePN (IntPN i) ; + symb : Floating -> NP + = \i -> UsePN (FloatPN i) ; symb : N -> Digits -> NP - = \c,i -> CNNumNP (mkCN c) (mkCard i) ; + = \c,i -> CNNumNP (UseN c) (NumDigits i) ; symb : N -> Card -> NP - = \c,n -> CNNumNP (mkCN c) n ; + = \c,n -> CNNumNP (UseN c) n ; symb : CN -> Card -> NP = \c,n -> CNNumNP c n ; 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 - = \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 - = \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 - = CNSymbNP ; - symb : Symb -> S = SymbS ; - symb : Symb -> Card = SymbNum ; - symb : Symb -> Ord = SymbOrd - + = CNSymbNP } ; mkSymb : Str -> Symb = \s -> {s = s ; lock_Symb = <>} ; - mkInt i = {s = i ; lock_Int = <>} ; - mkFloat f = {s = f ; lock_Float = <>} ; + mkInteger i = {s = Predef.show Predef.Int i ; lock_Int = <>} ; + mkFloating f = {s = Predef.show Predef.Float f ; lock_Float = <>} ; + Integer : Type = {s : Str ; lock_Int : {}} ; + Floating : Type = {s : Str ; lock_Float : {}} ; } diff --git a/next-lib/src/api/SymbolicCat.gf b/next-lib/src/api/SymbolicCat.gf new file mode 100644 index 000000000..4c19a02bc --- /dev/null +++ b/next-lib/src/api/SymbolicCat.gf @@ -0,0 +1,5 @@ +--# -path=.:present:prelude + +resource SymbolicCat = Symbolic with + (Symbol = SymbolCat), + (Syntax = SyntaxCat) ; diff --git a/next-lib/src/api/SymbolicDan.gf b/next-lib/src/api/SymbolicDan.gf new file mode 100644 index 000000000..cbbe7e0ad --- /dev/null +++ b/next-lib/src/api/SymbolicDan.gf @@ -0,0 +1,5 @@ +--# -path=.:present:mathematical:prelude + +resource SymbolicDan = Symbolic with + (Symbol = SymbolDan), + (Grammar = GrammarDan) ; diff --git a/next-lib/src/api/SymbolicEng.gf b/next-lib/src/api/SymbolicEng.gf index 0ce4725fa..c9b559a22 100644 --- a/next-lib/src/api/SymbolicEng.gf +++ b/next-lib/src/api/SymbolicEng.gf @@ -1,5 +1,5 @@ ---# -path=.:present:prelude +--# -path=.:present:mathematical:prelude resource SymbolicEng = Symbolic with (Symbol = SymbolEng), - (Syntax = SyntaxEng) ; + (Grammar = GrammarEng) ; diff --git a/next-lib/src/api/SymbolicFin.gf b/next-lib/src/api/SymbolicFin.gf new file mode 100644 index 000000000..f8b88526b --- /dev/null +++ b/next-lib/src/api/SymbolicFin.gf @@ -0,0 +1,5 @@ +--# -path=.:present:mathematical:prelude + +resource SymbolicFin = Symbolic with + (Symbol = SymbolFin), + (Grammar = GrammarFin) ; diff --git a/next-lib/src/api/SymbolicFre.gf b/next-lib/src/api/SymbolicFre.gf new file mode 100644 index 000000000..ee0b2acc9 --- /dev/null +++ b/next-lib/src/api/SymbolicFre.gf @@ -0,0 +1,5 @@ +--# -path=.:present:mathematical:prelude + +resource SymbolicFre = Symbolic with + (Symbol = SymbolFre), + (Grammar = GrammarFre) ; diff --git a/next-lib/src/api/SymbolicGer.gf b/next-lib/src/api/SymbolicGer.gf new file mode 100644 index 000000000..8b8d7111d --- /dev/null +++ b/next-lib/src/api/SymbolicGer.gf @@ -0,0 +1,5 @@ +--# -path=.:present:mathematical:prelude + +resource SymbolicGer = Symbolic with + (Symbol = SymbolGer), + (Grammar = GrammarGer) ; diff --git a/next-lib/src/api/SymbolicIta.gf b/next-lib/src/api/SymbolicIta.gf new file mode 100644 index 000000000..d4b578c8d --- /dev/null +++ b/next-lib/src/api/SymbolicIta.gf @@ -0,0 +1,5 @@ +--# -path=.:present:mathematical:prelude + +resource SymbolicIta = Symbolic with + (Symbol = SymbolIta), + (Grammar = GrammarIta) ; diff --git a/next-lib/src/api/SymbolicNor.gf b/next-lib/src/api/SymbolicNor.gf new file mode 100644 index 000000000..b4eff28e0 --- /dev/null +++ b/next-lib/src/api/SymbolicNor.gf @@ -0,0 +1,5 @@ +--# -path=.:present:mathematical:prelude + +resource SymbolicNor = Symbolic with + (Symbol = SymbolNor), + (Grammar = GrammarNor) ; diff --git a/next-lib/src/api/SymbolicSpa.gf b/next-lib/src/api/SymbolicSpa.gf new file mode 100644 index 000000000..ae44431f5 --- /dev/null +++ b/next-lib/src/api/SymbolicSpa.gf @@ -0,0 +1,5 @@ +--# -path=.:present:mathematical:prelude + +resource SymbolicSpa = Symbolic with + (Symbol = SymbolSpa), + (Grammar = GrammarSpa) ; diff --git a/next-lib/src/api/SymbolicSwe.gf b/next-lib/src/api/SymbolicSwe.gf new file mode 100644 index 000000000..193d8e84d --- /dev/null +++ b/next-lib/src/api/SymbolicSwe.gf @@ -0,0 +1,5 @@ +--# -path=.:present:mathematical:prelude + +resource SymbolicSwe = Symbolic with + (Symbol = SymbolSwe), + (Grammar = GrammarSwe) ; diff --git a/next-lib/src/catalan/IdiomCat.gf b/next-lib/src/catalan/IdiomCat.gf index 193cd3b49..5b82047aa 100644 --- a/next-lib/src/catalan/IdiomCat.gf +++ b/next-lib/src/catalan/IdiomCat.gf @@ -21,4 +21,32 @@ concrete IdiomCat of Idiom = CatCat ** ) (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))) ; + + + + + } diff --git a/next-lib/src/catalan/SymbolCat.gf b/next-lib/src/catalan/SymbolCat.gf new file mode 100644 index 000000000..09faff744 --- /dev/null +++ b/next-lib/src/catalan/SymbolCat.gf @@ -0,0 +1,2 @@ +concrete SymbolCat of Symbol = CatCat ** SymbolRomance with + (ResRomance = ResCat) ; diff --git a/next-lib/src/danish/SymbolDan.gf b/next-lib/src/danish/SymbolDan.gf new file mode 100644 index 000000000..ef1e73c82 --- /dev/null +++ b/next-lib/src/danish/SymbolDan.gf @@ -0,0 +1,2 @@ +concrete SymbolDan of Symbol = CatDan ** SymbolScand with + (ResScand = ResDan) ; diff --git a/next-lib/src/finnish/ExtraFin.gf b/next-lib/src/finnish/ExtraFin.gf index 5a2bba75b..5af232ef0 100644 --- a/next-lib/src/finnish/ExtraFin.gf +++ b/next-lib/src/finnish/ExtraFin.gf @@ -68,12 +68,10 @@ concrete ExtraFin of ExtraFinAbs = CatFin ** isPron = False } ; - vai_Conj = {s1 = [] ; s2 = "vai" ; n = Sg} ; - CompPartAP ap = { - s = \\agr => ap.s ! False ! AN (NCase agr.n Part) + s = \\agr => ap.s ! False ! NCase agr.n Part } ; } diff --git a/next-lib/src/finnish/SymbolFin.gf b/next-lib/src/finnish/SymbolFin.gf new file mode 100644 index 000000000..922b19dcb --- /dev/null +++ b/next-lib/src/finnish/SymbolFin.gf @@ -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 "," ; + +} + diff --git a/next-lib/src/french/SymbolFre.gf b/next-lib/src/french/SymbolFre.gf new file mode 100644 index 000000000..ab972c039 --- /dev/null +++ b/next-lib/src/french/SymbolFre.gf @@ -0,0 +1,2 @@ +concrete SymbolFre of Symbol = CatFre ** SymbolRomance with + (ResRomance = ResFre) ; diff --git a/next-lib/src/german/CatGer.gf b/next-lib/src/german/CatGer.gf index 17a8fe12e..82a97c854 100644 --- a/next-lib/src/german/CatGer.gf +++ b/next-lib/src/german/CatGer.gf @@ -95,6 +95,8 @@ concrete CatGer of Cat = Tense = {s : Str ; t : ResGer.Tense ; m : Mood} ; lin + TTAnt t a = {s = t.s ++ a.s ; t = t.t ; a = a.a ; m = t.m} ; + TPres = {s = [] ; t = Pres ; m = MIndic} ; TPast = {s = [] ; t = Past ; m = MIndic} ; --# notpresent TFut = {s = [] ; t = Fut ; m = MIndic} ; --# notpresent diff --git a/next-lib/src/german/SymbolGer.gf b/next-lib/src/german/SymbolGer.gf new file mode 100644 index 000000000..38516d74a --- /dev/null +++ b/next-lib/src/german/SymbolGer.gf @@ -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 "," ; + +} + diff --git a/next-lib/src/italian/SymbolIta.gf b/next-lib/src/italian/SymbolIta.gf new file mode 100644 index 000000000..d4e9cbf52 --- /dev/null +++ b/next-lib/src/italian/SymbolIta.gf @@ -0,0 +1,2 @@ +concrete SymbolIta of Symbol = CatIta ** SymbolRomance with + (ResRomance = ResIta) ; diff --git a/next-lib/src/norwegian/SymbolNor.gf b/next-lib/src/norwegian/SymbolNor.gf new file mode 100644 index 000000000..2e446b09b --- /dev/null +++ b/next-lib/src/norwegian/SymbolNor.gf @@ -0,0 +1,2 @@ +concrete SymbolNor of Symbol = CatNor ** SymbolScand with + (ResScand = ResNor) ; diff --git a/next-lib/src/romance/SymbolRomance.gf b/next-lib/src/romance/SymbolRomance.gf new file mode 100644 index 000000000..64b4e1a34 --- /dev/null +++ b/next-lib/src/romance/SymbolRomance.gf @@ -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 "," ; + +} diff --git a/next-lib/src/scandinavian/SymbolScand.gf b/next-lib/src/scandinavian/SymbolScand.gf new file mode 100644 index 000000000..8bde4e1a4 --- /dev/null +++ b/next-lib/src/scandinavian/SymbolScand.gf @@ -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 "," ; + +} diff --git a/next-lib/src/spanish/SymbolSpa.gf b/next-lib/src/spanish/SymbolSpa.gf new file mode 100644 index 000000000..e56343432 --- /dev/null +++ b/next-lib/src/spanish/SymbolSpa.gf @@ -0,0 +1,2 @@ +concrete SymbolSpa of Symbol = CatSpa ** SymbolRomance with + (ResRomance = ResSpa) ; diff --git a/next-lib/src/swedish/SymbolSwe.gf b/next-lib/src/swedish/SymbolSwe.gf new file mode 100644 index 000000000..b80619c06 --- /dev/null +++ b/next-lib/src/swedish/SymbolSwe.gf @@ -0,0 +1,2 @@ +concrete SymbolSwe of Symbol = CatSwe ** SymbolScand with + (ResScand = ResSwe) ; diff --git a/src/GF/Command/TreeOperations.hs b/src/GF/Command/TreeOperations.hs index 88b962bdc..f05b8dec3 100644 --- a/src/GF/Command/TreeOperations.hs +++ b/src/GF/Command/TreeOperations.hs @@ -11,8 +11,10 @@ import GF.Compile.AbsCompute -- for conversions import PGF.Data --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] @@ -24,7 +26,7 @@ allTreeOps = [ ("compute",("compute by using semantic definitions (def)", id)), ("smallest",("sort trees from smallest to largest, in number of nodes", - id)), + smallest)), ("typecheck",("type check and solve metavariables; reject if incorrect", id)) ] @@ -35,7 +37,24 @@ typeCheck pgf t = (t,(True,[])) compute :: PGF -> Tree -> Tree 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 = diff --git a/src/PGF/Macros.hs b/src/PGF/Macros.hs index f579c07dd..b79715f44 100644 --- a/src/PGF/Macros.hs +++ b/src/PGF/Macros.hs @@ -34,6 +34,10 @@ lookType :: PGF -> CId -> Type lookType pgf f = 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 = valCat . lookType pgf @@ -137,4 +141,4 @@ combinations t = case t of aa:uu -> [a:u | a <- aa, u <- combinations uu] isLiteralCat :: CId -> Bool -isLiteralCat = (`elem` [mkCId "String", mkCId "Float", mkCId "Int"]) \ No newline at end of file +isLiteralCat = (`elem` [mkCId "String", mkCId "Float", mkCId "Int"])