From 17b7fb146382a9feb3857b6ded29fbefab4ae68c Mon Sep 17 00:00:00 2001 From: aarne Date: Sat, 24 Apr 2010 11:34:04 +0000 Subject: [PATCH] lrec tutorial examples --- examples/lrec-tutorial/Ara.gf | 8 ++ examples/lrec-tutorial/AraAra.gf | 9 ++ examples/lrec-tutorial/Arabic.gf | 110 ++++++++++++++++ examples/lrec-tutorial/Grammar.gf | 17 +++ examples/lrec-tutorial/GrammarIta.gf | 80 +++++++++++ examples/lrec-tutorial/GrammarIta0.gf | 80 +++++++++++ examples/lrec-tutorial/Lang.gf | 9 ++ examples/lrec-tutorial/LangIta.gf | 17 +++ examples/lrec-tutorial/LexFaceIta.gf | 9 ++ examples/lrec-tutorial/Morpho.gf | 82 ++++++++++++ examples/lrec-tutorial/One.gf | 42 ++++++ examples/lrec-tutorial/ResIta.gf | 154 ++++++++++++++++++++++ examples/lrec-tutorial/Zero.gf | 9 ++ examples/lrec-tutorial/ZeroDut.gf | 18 +++ examples/lrec-tutorial/ZeroEng.gf | 11 ++ examples/lrec-tutorial/ZeroFre.gf | 16 +++ examples/lrec-tutorial/ZeroGer.gf | 19 +++ examples/lrec-tutorial/ZeroHeb.gf | 24 ++++ examples/lrec-tutorial/ZeroHebTr.gf | 20 +++ examples/lrec-tutorial/ZeroIta.gf | 16 +++ examples/lrec-tutorial/ZeroLat.gf | 17 +++ examples/lrec-tutorial/face/Face.gf | 14 ++ examples/lrec-tutorial/face/FaceEn0.gf | 22 ++++ examples/lrec-tutorial/face/FaceEng.gf | 7 + examples/lrec-tutorial/face/FaceFin.gf | 7 + examples/lrec-tutorial/face/FaceI.gf | 17 +++ examples/lrec-tutorial/face/FaceIta.gf | 8 ++ examples/lrec-tutorial/face/LexFace.gf | 8 ++ examples/lrec-tutorial/face/LexFaceEng.gf | 8 ++ examples/lrec-tutorial/face/LexFaceFin.gf | 7 + examples/lrec-tutorial/face/LexFaceIta.gf | 6 + 31 files changed, 871 insertions(+) create mode 100644 examples/lrec-tutorial/Ara.gf create mode 100644 examples/lrec-tutorial/AraAra.gf create mode 100644 examples/lrec-tutorial/Arabic.gf create mode 100644 examples/lrec-tutorial/Grammar.gf create mode 100644 examples/lrec-tutorial/GrammarIta.gf create mode 100644 examples/lrec-tutorial/GrammarIta0.gf create mode 100644 examples/lrec-tutorial/Lang.gf create mode 100644 examples/lrec-tutorial/LangIta.gf create mode 100644 examples/lrec-tutorial/LexFaceIta.gf create mode 100644 examples/lrec-tutorial/Morpho.gf create mode 100644 examples/lrec-tutorial/One.gf create mode 100644 examples/lrec-tutorial/ResIta.gf create mode 100644 examples/lrec-tutorial/Zero.gf create mode 100644 examples/lrec-tutorial/ZeroDut.gf create mode 100644 examples/lrec-tutorial/ZeroEng.gf create mode 100644 examples/lrec-tutorial/ZeroFre.gf create mode 100644 examples/lrec-tutorial/ZeroGer.gf create mode 100644 examples/lrec-tutorial/ZeroHeb.gf create mode 100644 examples/lrec-tutorial/ZeroHebTr.gf create mode 100644 examples/lrec-tutorial/ZeroIta.gf create mode 100644 examples/lrec-tutorial/ZeroLat.gf create mode 100644 examples/lrec-tutorial/face/Face.gf create mode 100644 examples/lrec-tutorial/face/FaceEn0.gf create mode 100644 examples/lrec-tutorial/face/FaceEng.gf create mode 100644 examples/lrec-tutorial/face/FaceFin.gf create mode 100644 examples/lrec-tutorial/face/FaceI.gf create mode 100644 examples/lrec-tutorial/face/FaceIta.gf create mode 100644 examples/lrec-tutorial/face/LexFace.gf create mode 100644 examples/lrec-tutorial/face/LexFaceEng.gf create mode 100644 examples/lrec-tutorial/face/LexFaceFin.gf create mode 100644 examples/lrec-tutorial/face/LexFaceIta.gf diff --git a/examples/lrec-tutorial/Ara.gf b/examples/lrec-tutorial/Ara.gf new file mode 100644 index 000000000..14fbb2573 --- /dev/null +++ b/examples/lrec-tutorial/Ara.gf @@ -0,0 +1,8 @@ +abstract Ara = { + +cat S ; V ; + +fun ktb_V : V ; + + Tab : V -> S ; +} diff --git a/examples/lrec-tutorial/AraAra.gf b/examples/lrec-tutorial/AraAra.gf new file mode 100644 index 000000000..b97229ed3 --- /dev/null +++ b/examples/lrec-tutorial/AraAra.gf @@ -0,0 +1,9 @@ +concrete AraAra of Ara = open Arabic in { + +lincat V = Verb ; S = Str ; + +lin ktb_V = u_Verb "ktb" ; + + Tab v = verbTable v ; + +} diff --git a/examples/lrec-tutorial/Arabic.gf b/examples/lrec-tutorial/Arabic.gf new file mode 100644 index 000000000..0ac3642d5 --- /dev/null +++ b/examples/lrec-tutorial/Arabic.gf @@ -0,0 +1,110 @@ +resource Arabic = { +oper + Root : Type = {F,C,L : Str} ; + Pattern : Type = {F,FC,CL,L : Str} ; + + appPattern : Root -> Pattern -> Str = \r,p -> + p.F + r.F + p.FC + r.C + p.CL + r.L + p.L ; + + getRoot : Str -> Root = \s -> case s of { + F@? + C@? + L => {F = F ; C = C ; L = L} ; + _ => Predef.error ("cannot get root from" ++ s) + } ; + + getPattern : Str -> Pattern = \s -> case s of { + F + "F" + FC + "C" + CL + "L" + L => {F = F ; FC = FC ; CL = CL ; L = L} ; + _ => Predef.error ("cannot get pattern from" ++ s) + } ; + + getWord : Str -> Str -> Str = \r,p -> + appPattern (getRoot r) (getPattern p) ; + +param + Number = Sg | Dl | Pl ; + Gender = Masc | Fem ; + Tense = Perf | Impf ; + + VPer = Vp3 Number Gender | Vp2Sg Gender | Vp2Dl | Vp2Pl Gender | Vp1Sg | Vp1Pl ; + +oper + Verb : Type = {s : Tense => VPer => Str} ; + + pattV_u : Tense -> VPer -> Pattern = \t,v -> getPattern (case t of { + Perf => case v of { + Vp3 Sg Masc => "FaCaLa" ; + Vp3 Sg Fem => "FaCaLat" ; + Vp3 Dl Masc => "FaCaLaA" ; + Vp3 Dl Fem => "FaCaLataA" ; + Vp3 Pl Masc => "FaCaLuwA" ; + Vp3 Pl Fem => "FaCaLona" ; + + Vp2Sg Masc => "FaCaLota" ; + Vp2Sg Fem => "FaCaLoti" ; + Vp2Dl => "FaCaLotumaA" ; + Vp2Pl Masc => "FaCaLotum" ; + Vp2Pl Fem => "FaCaLotunv2a" ; + + Vp1Sg => "FaCaLotu" ; + Vp1Pl => "FaCaLonaA" + } ; + Impf => case v of { + Vp3 Sg Masc => "yaFoCuLu" ; + Vp3 Sg Fem => "taFoCuLu" ; + Vp3 Dl Masc => "yaFoCuLaAni" ; + Vp3 Dl Fem => "taFoCuLaAni" ; + Vp3 Pl Masc => "yaFoCuLuwna" ; + Vp3 Pl Fem => "yaFoCuLna" ; + + Vp2Sg Masc => "taFoCuLu" ; + Vp2Sg Fem => "taFoCuLiyna" ; + Vp2Dl => "taFoCuLaAni" ; + Vp2Pl Masc => "taFoCuLuwna" ; + Vp2Pl Fem => "taFoCuLona" ; + + Vp1Sg => "A?aFoCuLu" ; + Vp1Pl => "naFoCuLu" + } + }) ; + + u_Verb : Str -> Verb = \s -> { + s = \\t,p => appPattern (getRoot s) (pattV_u t p) + } ; + +-- for html + + tag : Str -> Str = \t -> "<" + t + ">" ; + etag : Str -> Str = \t -> "" ; + atag : Str -> Str -> Str = \t,a -> "<" + t ++ a + ">" ; + + intag : Str -> Str -> Str = \t,s -> tag t ++ s ++ etag t ; + intagAttr : Str -> Str -> Str -> Str = \t,a,s -> atag t a ++ s ++ etag t ; + + verbTable : Verb -> Str = \v -> + let + vsp = v.s ! Perf ; + vsi = v.s ! Impf ; + tr : Str -> Str = intag "tr" ; + td : Str -> Str = intag "td" ; + ts : Str -> Str = \s -> td ("\"" ++ s ++ "\"") ; + trs : Str -> Str -> VPer -> Str = \s,n,v -> + tr (td s ++ td n ++ ts (vsp ! v) ++ ts (vsi ! v)) + in + intagAttr "table" "border=1" ( + tr ((td "Persona") ++ (td "Numerus") ++ (td "Perfectum") ++ (td "Imperfectum")) ++ + trs "3. masc." "sing." (Vp3 Sg Masc) ++ + trs "3. fem." "sing." (Vp3 Sg Fem) ++ + trs "2. masc." "sing." (Vp2Sg Masc) ++ + trs "2. fem." "sing." (Vp2Sg Fem) ++ + trs "1." "sing." (Vp1Sg) ++ + trs "3. masc." "dual." (Vp3 Dl Masc) ++ + trs "3. fem." "dual." (Vp3 Dl Fem) ++ + trs "2." "dual." (Vp2Dl) ++ + trs "3. masc." "plur." (Vp3 Pl Masc) ++ + trs "3. fem." "plur." (Vp3 Pl Fem) ++ + trs "2. masc." "plur." (Vp2Pl Masc) ++ + trs "2. fem." "plur." (Vp2Pl Fem) ++ + trs "1." "plur." (Vp1Pl) + ) ; + + +} diff --git a/examples/lrec-tutorial/Grammar.gf b/examples/lrec-tutorial/Grammar.gf new file mode 100644 index 000000000..c7872869c --- /dev/null +++ b/examples/lrec-tutorial/Grammar.gf @@ -0,0 +1,17 @@ +abstract Grammar = { + cat + Cl ; NP ; VP ; AP ; CN ; Det ; N ; A ; V ; V2 ; + fun + PredVP : NP -> VP -> Cl ; + ComplV2 : V2 -> NP -> VP ; + DetCN : Det -> CN -> NP ; + ModCN : CN -> AP -> CN ; + + UseV : V -> VP ; + UseN : N -> CN ; + UseA : A -> AP ; + + a_Det, the_Det : Det ; + this_Det, these_Det : Det ; + i_NP, she_NP, we_NP : NP ; +} diff --git a/examples/lrec-tutorial/GrammarIta.gf b/examples/lrec-tutorial/GrammarIta.gf new file mode 100644 index 000000000..caa5b9b02 --- /dev/null +++ b/examples/lrec-tutorial/GrammarIta.gf @@ -0,0 +1,80 @@ +concrete GrammarIta of Grammar = open ResIta, Prelude in { + lincat + Cl = {s : ResIta.Tense => Str} ; + NP = ResIta.NP ; -- {s : Case => {clit,obj : Str} ; a : Agr} ; + VP = ResIta.VP ; -- {v : Verb ; clit : Str ; obj : Str} ; + AP = {s : Gender => Number => Str ; isPre : Bool} ; + CN = Noun ; -- {s : Number => Str ; g : Gender} ; + Det = {s : Gender => Case => Str ; n : Number} ; + N = Noun ; -- {s : Number => Str ; g : Gender} ; + A = Adj ; -- {s : Gender => Number => Str ; isPre : Bool} ; + V = Verb ; -- {s : VForm => Str ; aux : Aux} ; + V2 = Verb ** {c : Case} ; + + lin + PredVP np vp = + let + subj = (np.s ! Nom).obj ; + obj = vp.obj ; + clit = vp.clit ; + verb = table { + Pres => agrV vp.v np.a ; + Perf => agrV (auxVerb vp.v.aux) np.a ++ agrPart vp.v np.a + } + in { + s = \\t => subj ++ clit ++ verb ! t ++ obj + } ; + + ComplV2 v2 np = + let + nps = np.s ! v2.c + in { + v = {s = v2.s ; aux = v2.aux} ; + clit = nps.clit ; + obj = nps.obj + } ; + + UseV v = { + v = v ; + clit = [] ; + obj = [] + } ; + + DetCN det cn = { + s = \\c => {obj = det.s ! cn.g ! c ++ cn.s ! det.n ; clit = []} ; + a = Ag cn.g det.n Per3 + } ; + + ModCN cn ap = { + s = \\n => preOrPost ap.isPre (ap.s ! cn.g ! n) (cn.s ! n) ; + g = cn.g + } ; + + UseN n = n ; + + UseA adj = adj ; + + a_Det = adjDet (mkA "un" "una" [] [] True) Sg ; + + the_Det = { + s = table { + Masc => table { + Nom | Acc => pre {"il" ; "lo" / s_impuro ; "l'" / vowel} ; + Dat => pre {"al" ; "allo" / s_impuro ; "all'" / vowel} + } ; + Fem => table { + Nom | Acc => pre {"la" ; "l'" / vowel} ; + Dat => pre {"alla" ; "all'" / vowel} + } + } ; + n = Sg + } ; + + this_Det = adjDet (mkA "questo") Sg ; + these_Det = adjDet (mkA "questo") Pl ; + + i_NP = pronNP "io" "mi" "mi" Masc Sg Per1 ; + she_NP = pronNP "lei" "la" "le" Fem Sg Per3 ; + we_NP = pronNP "noi" "ci" "ci" Masc Pl Per1 ; + +} diff --git a/examples/lrec-tutorial/GrammarIta0.gf b/examples/lrec-tutorial/GrammarIta0.gf new file mode 100644 index 000000000..0e87b36e4 --- /dev/null +++ b/examples/lrec-tutorial/GrammarIta0.gf @@ -0,0 +1,80 @@ +concrete GrammarIta of Grammar = open ResIta, Prelude in { + lincat + Cl = {s : Tense => Str} ; + NP = {s : Case => Str ; a : Agr} ; + VP = {s : VForm => Str ; aux : Aux} ; + AP = {s : Gender => Number => Str} ; + CN = {s : Number => Str ; g : Gender} ; + Det = {s : Gender => Case => Str ; n : Number} ; + N = {s : Number => Str ; g : Gender} ; + A = {s : Gender => Number => Str} ; + V = {s : VForm => Str ; aux : Aux} ; + V2 = Verb ** {c : Preposition} ; + + lin + PredVP np vp = + let + subj = np.s ! Nom ; + obj = vp.obj ; + clit = vp.clit ; + verb = table { + Pres => agrV vp ; + Perf => agrV (auxVerb vp.aux) np.a ++ agrPart vp np.a + } + in { + s = \\t => subj ++ clit ++ verb ! t ++ obj + } ; + + ComplV2 v2 np = + let + nps = np.s ! v2.c.c + in { + v = {s = v2.s ; aux = v2.aux} ; + clit = nps.clit ; + obj = v2.c.p ++ nps.obj + } ; + + UseV v = { + v = v ; + clit = [] ; + obj = [] + } ; + + DetCN det cn = { + s = \\c => {obj = det.s ! cn.g ! c ++ cn.s ! det.n ; clit = []} ; + a = Ag cn.g det.n Per3 + } ; + + ModCN cn ap = { + s = \\n => preOrPost ap.isPre (ap.s ! cn.g ! n) (cn.s ! n) ; + g = cn.g + } ; + + UseN n = n ; + + UseA adj = adj ; + + a_Det = adjDet (mkA "un" "una" [] [] True) Sg ; + + the_Det = { + s = table { + Masc => table { + Nom | Acc => pre {"il" ; "lo" / s_impuro ; "l'" / vowel} ; + Dat => pre {"al" ; "allo" / s_impuro ; "all'" / vowel} + } ; + Fem => table { + Nom | Acc => pre {"la" ; "l'" / vowel} ; + Dat => pre {"alla" ; "all'" / vowel} + } + } ; + n = Sg + } ; + + this_Det = adjDet (mkA "questo") Sg ; + these_Det = adjDet (mkA "questo") Pl ; + + i_NP = pronNP "io" "mi" "mi" Masc Sg Per1 ; + she_NP = pronNP "lei" "la" "le" Fem Sg Per3 ; + we_NP = pronNP "noi" "ci" "ci" Masc Pl Per1 ; + +} diff --git a/examples/lrec-tutorial/Lang.gf b/examples/lrec-tutorial/Lang.gf new file mode 100644 index 000000000..b024a2331 --- /dev/null +++ b/examples/lrec-tutorial/Lang.gf @@ -0,0 +1,9 @@ +abstract Lang = Grammar ** { + +fun + man_N, woman_N, house_N, tree_N : N ; + big_A, small_A, green_A : A ; + walk_V, arrive_V : V ; + love_V2, please_V2 : V2 ; + +} ; diff --git a/examples/lrec-tutorial/LangIta.gf b/examples/lrec-tutorial/LangIta.gf new file mode 100644 index 000000000..41aabf6c1 --- /dev/null +++ b/examples/lrec-tutorial/LangIta.gf @@ -0,0 +1,17 @@ +concrete LangIta of Lang = GrammarIta ** open ResIta in { + +lin + man_N = mkN "uomo" "uomini" Masc ; + woman_N = mkN "donna" ; + house_N = mkN "casa" ; + tree_N = mkN "albero" ; + big_A = preA (mkA "grande") ; + small_A = preA (mkA "piccolo") ; + green_A = mkA "verde" ; + walk_V = mkV "camminare" ; + arrive_V = essereV (mkV "arrivare") ; + love_V2 = mkV2 "amare" ; + please_V2 = mkV2 (mkV "piacere" "piaccio" "piaci" "piace" + "piacciamo" "piacete" "piacciono" "piaciuto" Essere) Dat ; + +} ; diff --git a/examples/lrec-tutorial/LexFaceIta.gf b/examples/lrec-tutorial/LexFaceIta.gf new file mode 100644 index 000000000..cf1523440 --- /dev/null +++ b/examples/lrec-tutorial/LexFaceIta.gf @@ -0,0 +1,9 @@ +instance LexFaceIta of LexFace = open SyntaxIta, ParadigmsIta, LexiconIta in { + +oper + like_V2 = mkV2 "amare" ; + invitation_N = mkN "invitazione" feminine ; + friend_N = mkN "amico" ; + have_V2 = LexiconIta.have_V2 ; + +} diff --git a/examples/lrec-tutorial/Morpho.gf b/examples/lrec-tutorial/Morpho.gf new file mode 100644 index 000000000..dfa465483 --- /dev/null +++ b/examples/lrec-tutorial/Morpho.gf @@ -0,0 +1,82 @@ +resource Morpho = open Prelude in { + +param + VForm = VInf | VPres | VPast | VPastPart | VPresPart ; + +oper + Verb : Type = {s : VForm => Str} ; + +-- worst-case function for data abstraction + + mkVerb : (_,_,_,_,_ : Str) -> Verb = \vi,vpr,vpa,vpap,vprp -> { + s = table { + VInf => vi ; + VPres => vpr ; + VPast => vpa ; + VPastPart => vpap ; + VPresPart => vprp + } + } ; + + regVerb : Str -> Verb = \walk -> + mkVerb walk (walk + "s") (walk + "ed") (walk + "ed") (walk + "ing") ; + + s_regVerb : Str -> Verb = \kiss -> + mkVerb kiss (kiss + "es") (kiss + "ed") (kiss + "ed") (kiss + "ing") ; + + e_regVerb : Str -> Verb = \use -> + let us = init use + in + mkVerb use (use + "s") (us + "ed") (us + "ed") (us + "ing") ; + + y_regVerb : Str -> Verb = \cry -> + let cr = init cry + in + mkVerb cry (cr + "ies") (cr + "ied") (cr + "ied") (cry + "ing") ; + + ie_regVerb : Str -> Verb = \die -> + let dy = Predef.tk 2 die + "y" + in + mkVerb die (die + "s") (die + "d") (die + "d") (dy + "ing") ; + + dupRegVerb : Str -> Verb = \stop -> + let stopp = stop + last stop + in + mkVerb stop (stop + "s") (stopp + "ed") (stopp + "ed") (stopp + "ing") ; + + smartVerb : Str -> Verb = \v -> case v of { + _ + ("s"|"z"|"x"|"ch") => s_regVerb v ; + _ + "ie" => ie_regVerb v ; + _ + "ee" => mkVerb v (v + "s") (v + "d") (v + "d") (v + "ing") ; + _ + "e" => e_regVerb v ; + _ + ("a"|"e"|"o"|"u") + "y" => regVerb v ; + _ + "y" => y_regVerb v ; + _ + ("ea"|"ee"|"ie"|"oa"|"oo"|"ou") + ? => regVerb v ; + _ + ("a"|"e"|"i"|"o"|"u") + + ("b"|"d"|"g"|"m"|"n"|"p"|"s"|"t") => dupRegVerb v ; + _ => regVerb v + } ; + + irregVerb : (_,_,_ : Str) -> Verb = \sing,sang,sung -> + let v = smartVerb sing + in + mkVerb sing (v.s ! VPres) sang sung (v.s ! VPresPart) ; + +-- first example of matching + + add_s : Str -> Str = \v -> case v of { + _ + ("s"|"z"|"x"|"ch") => v + "es" ; + _ + ("a"|"e"|"o"|"u") + "y" => v + "s" ; + cr + "y" => cr + "ies" ; + _ => v + "s" + } ; + +-- user paradigm + + mkV = overload { + mkV : (cry : Str) -> Verb = smartVerb ; + mkV : (sing,sang,sung : Str) -> Verb = irregVerb ; + mkV : (go,goes,went,gone,going : Str) -> Verb = mkVerb ; + } ; + +} diff --git a/examples/lrec-tutorial/One.gf b/examples/lrec-tutorial/One.gf new file mode 100644 index 000000000..4d0e94397 --- /dev/null +++ b/examples/lrec-tutorial/One.gf @@ -0,0 +1,42 @@ +abstract One = { + cat + S ; + Cl ; + NP ; + VP ; + AP ; + CN ; + Det ; + Pron ; + PN ; + N ; + A ; + V ; + V2 ; + Adv ; + Prep ; + Pol ; + Tense ; + fun + DeclCl : Tense -> Pol -> Cl -> S ; + QuestCl : Tense -> Pol -> Cl -> S ; + + PredVP : NP -> VP -> Cl ; + + ComplV2 : V2 -> NP -> VP ; + UseAP : AP -> VP ; + UseV : V -> VP ; + AdVP : VP -> Adv -> VP ; + + DetCN : Det -> CN -> NP ; + UsePN : PN -> NP ; + UsePron : Pron -> NP ; + + ModCN : CN -> AP -> CN ; + UseN : N -> CN ; + + UseA : A -> AP ; + + AdvA : A -> Adv ; + PrepNP : Prep -> NP -> Adv ; +} diff --git a/examples/lrec-tutorial/ResIta.gf b/examples/lrec-tutorial/ResIta.gf new file mode 100644 index 000000000..51066450d --- /dev/null +++ b/examples/lrec-tutorial/ResIta.gf @@ -0,0 +1,154 @@ +resource ResIta = open Prelude in { + +-- parameters + +param + Number = Sg | Pl ; + Gender = Masc | Fem ; + Case = Nom | Acc | Dat ; + Agr = Ag Gender Number Person ; + Aux = Avere | Essere ; + Tense = Pres | Perf ; + Person = Per1 | Per2 | Per3 ; + + VForm = VInf | VPres Number Person | VPart Gender Number ; + +-- parts of speech + +oper + VP = {v : Verb ; clit : Str ; obj : Str} ; + NP = {s : Case => {clit,obj : Str} ; a : Agr} ; + +-- auxiliaries + + prepCase : Case -> Str = \c -> case c of { + Dat => "a" ; + _ => [] + } ; + + adjDet : Adj -> Number -> {s : Gender => Case => Str ; n : Number} = \adj,n -> { + s = \\g,c => prepCase c ++ adj.s ! g ! n ; + n = n + } ; + + pronNP : (s,a,d : Str) -> Gender -> Number -> Person -> NP = \s,a,d,g,n,p -> { + s = table { + Nom => {clit = [] ; obj = s} ; + Acc => {clit = a ; obj = []} ; + Dat => {clit = d ; obj = []} + } ; + a = Ag g n p + } ; + +-- predication + + agrV : Verb -> Agr -> Str = \v,a -> case a of { + Ag _ n p => v.s ! VPres n p + } ; + + auxVerb : Aux -> Verb = \a -> case a of { + Avere => mkVerb "avere" "ho" "hai" "ha" "abbiamo" "avete" "hanno" "avuto" Avere ; + Essere => mkVerb "essere" "sono" "sei" "è" "siamo" "siete" "sono" "stato" Essere + } ; + + agrPart : Verb -> Agr -> Str = \v,a -> case v.aux of { + Avere => v.s ! VPart Masc Sg ; + Essere => case a of { + Ag g n _ => v.s ! VPart g n + } + } ; + + neg : Bool -> Str = \b -> case b of {True => [] ; False => "non"} ; + +-------------------------------------------------------- +-- morphology + + Noun : Type = {s : Number => Str ; g : Gender} ; + Adj : Type = {s : Gender => Number => Str ; isPre : Bool} ; + Verb : Type = {s : VForm => Str ; aux : Aux} ; + + mkNoun : Str -> Str -> Gender -> Noun = \vino,vini,g -> { + s = table {Sg => vino ; Pl => vini} ; + g = g + } ; + + regNoun : Str -> Noun = \vino -> case vino of { + fuo + c@("c"|"g") + "o" => mkNoun vino (fuo + c + "hi") Masc ; + ol + "io" => mkNoun vino (ol + "i") Masc ; + vin + "o" => mkNoun vino (vin + "i") Masc ; + cas + "a" => mkNoun vino (cas + "e") Fem ; + pan + "e" => mkNoun vino (pan + "i") Masc ; + _ => mkNoun vino vino Masc + } ; + + mkN = overload { + mkN : (vino : Str) -> Noun = regNoun ; + mkN : (uomo, uomini : Str) -> Gender -> Noun = mkNoun ; + } ; + + mkAdj : (_,_,_,_ : Str) -> Bool -> Adj = \buono,buona,buoni,buone,p -> { + s = table { + Masc => table {Sg => buono ; Pl => buoni} ; + Fem => table {Sg => buona ; Pl => buone} + } ; + isPre = p + } ; + + regAdj : Str -> Adj = \nero -> case nero of { + ner + "o" => mkAdj nero (ner + "a") (ner + "i") (ner + "e") False ; + verd + "e" => mkAdj nero nero (verd + "i") (verd + "i") False ; + _ => mkAdj nero nero nero nero False + } ; + + mkA = overload { + mkA : (nero : Str) -> Adj = regAdj ; + mkN : (buono,buona,buoni,buone : Str) -> Bool -> Adj = mkAdj ; + } ; + + preA : Adj -> Adj = \a -> {s = a.s ; isPre = True} ; + + mkVerb : (_,_,_,_,_,_,_,_ : Str) -> Aux -> Verb = + \amare,amo,ami,ama,amiamo,amate,amano,amato,aux -> { + s = table { + VInf => amare ; + VPres Sg Per1 => amo ; + VPres Sg Per2 => ami ; + VPres Sg Per3 => ama ; + VPres Pl Per1 => amiamo ; + VPres Pl Per2 => amate ; + VPres Pl Per3 => amano ; + VPart g n => (regAdj amato).s ! g ! n + } ; + aux = aux + } ; + + regVerb : Str -> Verb = \amare -> case amare of { + am + "are" => mkVerb amare (am+"o") (am+"i") (am+"a") + (am+"iamo") (am+"ate") (am+"ano") (am+"ato") Avere ; + tem + "ere" => mkVerb amare (tem+"o") (tem+"i") (tem+"e") + (tem+"iamo") (tem+"ete") (tem+"ono") (tem+"uto") Avere ; + fin + "ire" => mkVerb amare (fin+"isco") (fin+"isci") (fin+"isce") + (fin+"iamo") (fin+"ite") (fin+"iscono") (fin+"ito") Avere + } ; + + mkV = overload { + mkV : (finire : Str) -> Verb = regVerb ; + mkV : (andare,vado,vadi,va,andiamo,andate,vanno,andato : Str) -> + Aux -> Verb = mkVerb ; + } ; + + essereV : Verb -> Verb = \v -> {s = v.s ; aux = Essere} ; + + Verb2 = Verb ** {c : Case} ; + + mkV2 = overload { + mkV2 : (amare : Str) -> Verb2 = \v -> regVerb v ** {c = Acc} ; + mkV2 : (amare : Verb) -> Case -> Verb2 = \v,p -> v ** {c = p} ; + } ; + +-- phonological auxiliaries + + vowel : Strs = strs {"a" ; "e" ; "i" ; "o" ; "u" ; "h"} ; + s_impuro : Strs = strs {"z" ; "sb" ; "sc" ; "sd" ; "sf" ; "sp"} ; --- ... + +} diff --git a/examples/lrec-tutorial/Zero.gf b/examples/lrec-tutorial/Zero.gf new file mode 100644 index 000000000..5ff16de34 --- /dev/null +++ b/examples/lrec-tutorial/Zero.gf @@ -0,0 +1,9 @@ +abstract Zero = { + cat + S ; NP ; VP ; V2 ; + fun + Pred : NP -> VP -> S ; + Compl : V2 -> NP -> VP ; + John, Mary : NP ; + Love : V2 ; +} diff --git a/examples/lrec-tutorial/ZeroDut.gf b/examples/lrec-tutorial/ZeroDut.gf new file mode 100644 index 000000000..efe8bbda4 --- /dev/null +++ b/examples/lrec-tutorial/ZeroDut.gf @@ -0,0 +1,18 @@ +concrete ZeroDut of Zero = { + lincat + S, NP, VP = Str ; + V2 = {v,p : Str} ; + lin + Pred np vp = np ++ vp ; + Compl v2 np = v2.v ++ np ++ v2.p ; + John = "Jan" ; + Mary = "Marie" ; + Love = {v = "heeft" ; p = "lief"} ; +} + +--. + +-- illustrates: discontinuous constituents +-- +-- > p -lang=ZeroEng "John loves Mary" | aw -view=open -format=png + diff --git a/examples/lrec-tutorial/ZeroEng.gf b/examples/lrec-tutorial/ZeroEng.gf new file mode 100644 index 000000000..146c083cf --- /dev/null +++ b/examples/lrec-tutorial/ZeroEng.gf @@ -0,0 +1,11 @@ +concrete ZeroEng of Zero = { + lincat + S, NP, VP, V2 = Str ; + lin + Pred np vp = np ++ vp ; + Compl v2 np = v2 ++ np ; + John = "John" ; + Mary = "Mary" ; + Love = "loves" ; +} + diff --git a/examples/lrec-tutorial/ZeroFre.gf b/examples/lrec-tutorial/ZeroFre.gf new file mode 100644 index 000000000..96b0dcf73 --- /dev/null +++ b/examples/lrec-tutorial/ZeroFre.gf @@ -0,0 +1,16 @@ +concrete ZeroFre of Zero = { + lincat + S, NP, VP, V2 = Str ; + lin + Pred np vp = np ++ vp ; + Compl v2 np = v2 ++ np ; + John = "Jean" ; + Mary = "Marie" ; + Love = "aime" ; +} + +--. + +-- > gr | l +-- > p -lang=ZeroEng "John loves Mary" | l -lang=ZeroFre + diff --git a/examples/lrec-tutorial/ZeroGer.gf b/examples/lrec-tutorial/ZeroGer.gf new file mode 100644 index 000000000..ab12ddf99 --- /dev/null +++ b/examples/lrec-tutorial/ZeroGer.gf @@ -0,0 +1,19 @@ +concrete ZeroGer of Zero = { + lincat + S, NP, VP = Str ; + V2 = {v,p : Str} ; + lin + Pred np vp = np ++ vp ; + Compl v2 np = v2.v ++ np ++ v2.p ; + John = "Johann" ; + Mary = "Maria" ; + Love = {v = "hat" ; p = "lieb"} ; +} + +--. + +-- illustrates: discontinuous constituents +-- contrived, since we also have "liebt" +-- +-- > p -lang=ZeroEng "John loves Mary" | aw -view=open -format=png + diff --git a/examples/lrec-tutorial/ZeroHeb.gf b/examples/lrec-tutorial/ZeroHeb.gf new file mode 100644 index 000000000..4c8d4a85b --- /dev/null +++ b/examples/lrec-tutorial/ZeroHeb.gf @@ -0,0 +1,24 @@ + + concrete ZeroHeb of Zero = { + flags coding=utf8 ; + lincat + S = Str ; + NP = {s : Str ; g : Gender} ; + VP, V2 = Gender => Str ; + lin + Pred np vp = np.s ++ vp ! np.g ; + Compl v2 np = table {g => v2 ! g ++ "×ת" ++ np.s} ; + John = {s = "ג׳ון" ; g = Masc} ; + Mary = {s = "מרי" ; g = Fem} ; + Love = table {Masc => "×והב" ; Fem => "×והבת"} ; + param + Gender = Masc | Fem ; + } + +--. +-- illustrates: transliteration, inherent features, agreement +-- > gr | l -to_hebrew +-- > ut -hebrew +-- > rf -file=ZeroHeb.gf | ps -env=quotes -to_hebrew +-- > dc amac aw -format=png -view=open ?0 +-- > gr | %amac diff --git a/examples/lrec-tutorial/ZeroHebTr.gf b/examples/lrec-tutorial/ZeroHebTr.gf new file mode 100644 index 000000000..d60290f92 --- /dev/null +++ b/examples/lrec-tutorial/ZeroHebTr.gf @@ -0,0 +1,20 @@ +concrete ZeroHebTr of Zero = { + lincat + S = Str ; + NP = {s : Str ; g : Gender} ; + VP, V2 = Gender => Str ; + lin + Pred np vp = np.s ++ vp ! np.g ; + Compl v2 np = table {g => v2 ! g ++ "At" ++ np.s} ; + John = {s = "gg1wN" ; g = Masc} ; + Mary = {s = "mry" ; g = Fem} ; + love = table {Masc => "Awhb" ; Fem => "Awhbt"} ; + param + Gender = Masc | Fem ; +} + +--. +-- illustrates: transliteration, inherent features, agreement +-- > gr | l -to_hebrew +-- > ut -hebrew +-- > rf -file=ZeroHeb.gf | ps -env=quotes -to_hebrew diff --git a/examples/lrec-tutorial/ZeroIta.gf b/examples/lrec-tutorial/ZeroIta.gf new file mode 100644 index 000000000..254fa17ca --- /dev/null +++ b/examples/lrec-tutorial/ZeroIta.gf @@ -0,0 +1,16 @@ +concrete ZeroIta of Zero = { + lincat + S, NP, VP, V2 = Str ; + lin + Pred np vp = np ++ vp ; + Compl v2 np = v2 ++ np ; + John = "Giovanni" ; + Mary = "Maria" ; + Love = "ama" ; +} + +--. + +-- > gr | l +-- > p -lang=ZeroEng "John loves Mary" | l -lang=ZeroIta + diff --git a/examples/lrec-tutorial/ZeroLat.gf b/examples/lrec-tutorial/ZeroLat.gf new file mode 100644 index 000000000..10fe480a6 --- /dev/null +++ b/examples/lrec-tutorial/ZeroLat.gf @@ -0,0 +1,17 @@ +concrete ZeroLat of Zero = { + lincat + S, VP, V2 = Str ; + NP = Case => Str ; + lin + Pred np vp = np ! Nom ++ vp ; + Compl v2 np = np ! Acc ++ v2 ; + John = table {Nom => "Ioannes" ; Acc => "Ioannem"} ; + Mary = table {Nom => "Maria" ; Acc => "Mariam"} ; + Love = "amat" ; + param + Case = Nom | Acc ; +} + +--. +-- illustrates: parameters, word order +-- > p -lang=ZeroEng "John loves Mary" | aw -view=open -format=png diff --git a/examples/lrec-tutorial/face/Face.gf b/examples/lrec-tutorial/face/Face.gf new file mode 100644 index 000000000..9259363da --- /dev/null +++ b/examples/lrec-tutorial/face/Face.gf @@ -0,0 +1,14 @@ +abstract Face = { + +flags startcat = Message ; + +cat + Message ; Person ; Object ; Number ; +fun + Have : Person -> Number -> Object -> Message ; + Like : Person -> Object -> Message ; + You : Person ; + Friend, Invitation : Object ; + One, Two, Hundred : Number ; + +} diff --git a/examples/lrec-tutorial/face/FaceEn0.gf b/examples/lrec-tutorial/face/FaceEn0.gf new file mode 100644 index 000000000..2c4e7123b --- /dev/null +++ b/examples/lrec-tutorial/face/FaceEn0.gf @@ -0,0 +1,22 @@ +--# -path=.:present + +concrete FaceEn0 of Face = open SyntaxEng, ParadigmsEng in { +lincat + Message = Cl ; + Person = NP ; + Object = CN ; + Number = Numeral ; +lin + Have p n o = mkCl p have_V2 (mkNP n o) ; + Like p o = mkCl p like_V2 (mkNP this_Quant o) ; + You = mkNP youSg_Pron ; + Friend = mkCN friend_N ; + Invitation = mkCN invitation_N ; + One = n1_Numeral ; + Two = n2_Numeral ; + Hundred = n100_Numeral ; +oper + like_V2 = mkV2 "like" ; + invitation_N = mkN "invitation" ; + friend_N = mkN "friend" ; +} diff --git a/examples/lrec-tutorial/face/FaceEng.gf b/examples/lrec-tutorial/face/FaceEng.gf new file mode 100644 index 000000000..bac0b5f5a --- /dev/null +++ b/examples/lrec-tutorial/face/FaceEng.gf @@ -0,0 +1,7 @@ +--# -path=.:present + +concrete FaceEng of Face = FaceI with + (Syntax = SyntaxEng), + (LexFace = LexFaceEng) ; + + diff --git a/examples/lrec-tutorial/face/FaceFin.gf b/examples/lrec-tutorial/face/FaceFin.gf new file mode 100644 index 000000000..47b57ce29 --- /dev/null +++ b/examples/lrec-tutorial/face/FaceFin.gf @@ -0,0 +1,7 @@ +--# -path=.:present + +concrete FaceFin of Face = FaceI with + (Syntax = SyntaxFin), + (LexFace = LexFaceFin) ; + + diff --git a/examples/lrec-tutorial/face/FaceI.gf b/examples/lrec-tutorial/face/FaceI.gf new file mode 100644 index 000000000..b612dcdb8 --- /dev/null +++ b/examples/lrec-tutorial/face/FaceI.gf @@ -0,0 +1,17 @@ +incomplete concrete FaceI of Face = open Syntax, LexFace in { + +lincat + Message = Cl ; + Person = NP ; + Object = CN ; + Number = Numeral ; +lin + Have p n o = mkCl p have_V2 (mkNP n o) ; + Like p o = mkCl p like_V2 (mkNP this_Quant o) ; + You = mkNP youSg_Pron ; + Friend = mkCN friend_N ; + Invitation = mkCN invitation_N ; + One = n1_Numeral ; + Two = n2_Numeral ; + Hundred = n100_Numeral ; +} diff --git a/examples/lrec-tutorial/face/FaceIta.gf b/examples/lrec-tutorial/face/FaceIta.gf new file mode 100644 index 000000000..7e512ce6d --- /dev/null +++ b/examples/lrec-tutorial/face/FaceIta.gf @@ -0,0 +1,8 @@ +--# -path=.:present + +concrete FaceIta of Face = FaceI - [Like] with + (Syntax = SyntaxIta), + (LexFace = LexFaceIta) ** open SyntaxIta in { +lin Like p o = + mkCl (mkNP this_Quant o) like_V2 p ; +} diff --git a/examples/lrec-tutorial/face/LexFace.gf b/examples/lrec-tutorial/face/LexFace.gf new file mode 100644 index 000000000..db60ab8fd --- /dev/null +++ b/examples/lrec-tutorial/face/LexFace.gf @@ -0,0 +1,8 @@ +interface LexFace = open Syntax in { + +oper + like_V2 : V2 ; + invitation_N : N ; + friend_N : N ; + +} diff --git a/examples/lrec-tutorial/face/LexFaceEng.gf b/examples/lrec-tutorial/face/LexFaceEng.gf new file mode 100644 index 000000000..042d19923 --- /dev/null +++ b/examples/lrec-tutorial/face/LexFaceEng.gf @@ -0,0 +1,8 @@ +instance LexFaceEng of LexFace = open SyntaxEng, ParadigmsEng in { + +oper + like_V2 = mkV2 "like" ; + invitation_N = mkN "invitation" ; + friend_N = mkN "friend" ; + +} diff --git a/examples/lrec-tutorial/face/LexFaceFin.gf b/examples/lrec-tutorial/face/LexFaceFin.gf new file mode 100644 index 000000000..f43dbb022 --- /dev/null +++ b/examples/lrec-tutorial/face/LexFaceFin.gf @@ -0,0 +1,7 @@ +instance LexFaceFin of LexFace = open SyntaxFin, ParadigmsFin in { + +oper + like_V2 = mkV2 (mkV "pitää") elative ; + invitation_N = mkN "kutsu" ; + friend_N = mkN "ystävä" ; +} diff --git a/examples/lrec-tutorial/face/LexFaceIta.gf b/examples/lrec-tutorial/face/LexFaceIta.gf new file mode 100644 index 000000000..ce03ef126 --- /dev/null +++ b/examples/lrec-tutorial/face/LexFaceIta.gf @@ -0,0 +1,6 @@ +instance LexFaceIta of LexFace = open SyntaxIta, ParadigmsIta in { +oper + like_V2 = mkV2 (mkV (piacere_64 "piacere")) dative ; + invitation_N = mkN "invito" ; + friend_N = mkN "amico" ; +}