diff options
Diffstat (limited to 'doc/tutorial/resource')
| -rw-r--r-- | doc/tutorial/resource/LexEng.gf | 34 | ||||
| -rw-r--r-- | doc/tutorial/resource/LexFoods.gf | 4 | ||||
| -rw-r--r-- | doc/tutorial/resource/LexIta.gf | 46 | ||||
| -rw-r--r-- | doc/tutorial/resource/MorphoEng.gf | 33 | ||||
| -rw-r--r-- | doc/tutorial/resource/MorphoIta.gf | 87 | ||||
| -rw-r--r-- | doc/tutorial/resource/Syntax.gf | 46 | ||||
| -rw-r--r-- | doc/tutorial/resource/SyntaxEng.gf | 67 | ||||
| -rw-r--r-- | doc/tutorial/resource/SyntaxIta.gf | 81 |
8 files changed, 398 insertions, 0 deletions
diff --git a/doc/tutorial/resource/LexEng.gf b/doc/tutorial/resource/LexEng.gf new file mode 100644 index 000000000..c939aac9f --- /dev/null +++ b/doc/tutorial/resource/LexEng.gf @@ -0,0 +1,34 @@ +--# -path=.:prelude + +resource LexEng = open SyntaxEng, MorphoEng, Prelude in { + + oper + + -- constructors for open lexicon + + mkN : (man,men : Str) -> CN ; + regN : (car : Str) -> CN ; + + mkA : (hot : Str) -> AP ; + + mkV : (go,goes : Str) -> V ; + regV : (walk : Str) -> V ; + + mkV2 : (look : V) -> (at : Str) -> V2 ; + dirV2 : (eat : V) -> V2 ; + + -------------------------------------------- + -- definitions, hidden from users + + mkN x y = mkNoun x y ** {lock_CN = <>} ; + regN x = regNoun x ** {lock_CN = <>} ; + + mkA x = ss x ** {lock_AP = <>} ; + + mkV x y = mkVerb x y ** {lock_V = <>} ; + regV x = regVerb x ** {lock_V = <>} ; + + mkV2 x p = x ** {c = p ; lock_V2 = <>} ; + dirV2 x = mkV2 x [] ; + +} diff --git a/doc/tutorial/resource/LexFoods.gf b/doc/tutorial/resource/LexFoods.gf new file mode 100644 index 000000000..5bda608a3 --- /dev/null +++ b/doc/tutorial/resource/LexFoods.gf @@ -0,0 +1,4 @@ +interface LexFoods = open Syntax in { + + +}
\ No newline at end of file diff --git a/doc/tutorial/resource/LexIta.gf b/doc/tutorial/resource/LexIta.gf new file mode 100644 index 000000000..0b8940e1e --- /dev/null +++ b/doc/tutorial/resource/LexIta.gf @@ -0,0 +1,46 @@ +--# -path=.:prelude + +resource LexIta = open SyntaxIta, MorphoIta, Prelude in { + + oper + + -- constructors for genders + + Gender : Type ; + masculine, feminine : Gender ; + + -- constructors for open lexicon + + mkN : Gender -> (vino,vini : Str) -> CN ; + regN : (vino : Str) -> CN ; + femN : CN -> CN ; + + mkA : (nero,nera,neri,nere : Str) -> AP ; + regA : (nero : Str) -> AP ; + + mkV : (ama,amano : Str) -> V ; + regV : (amare : Str) -> V ; + + mkV2 : (aspettare : V) -> (a : Str) -> V2 ; + dirV2 : (mangiare : V) -> V2 ; + + -------------------------------------------- + -- definitions, hidden from users + + Gender = MorphoIta.Gender ; + masculine = Masc ; + feminine = Fem ; + + mkN g x y = mkNoun g x y ** {lock_CN = <>} ; + regN x = regNoun x ** {lock_CN = <>} ; + + mkA x y z u = mkAdjective x y z u ** {lock_AP = <>} ; + regA x = regAdjective x ** {lock_AP = <>} ; + + mkV x y = mkVerb x y ** {lock_V = <>} ; + regV x = regVerb x ** {lock_V = <>} ; + + mkV2 x p = x ** {c = p ; lock_V2 = <>} ; + dirV2 x = mkV2 x [] ; + +} diff --git a/doc/tutorial/resource/MorphoEng.gf b/doc/tutorial/resource/MorphoEng.gf new file mode 100644 index 000000000..a6a25b08c --- /dev/null +++ b/doc/tutorial/resource/MorphoEng.gf @@ -0,0 +1,33 @@ +--# -path=.:prelude + +resource MorphoEng = open Prelude in { + + param + Number = Sg | Pl ; + + oper + Noun, Verb : Type = {s : Number => Str} ; + + mkNoun : Str -> Str -> Noun = \x,y -> { + s = table { + Sg => x ; + Pl => y + } + } ; + + regNoun : Str -> Noun = \s -> case last s of { + "s" | "z" => mkNoun s (s + "es") ; + "y" => mkNoun s (init s + "ies") ; + _ => mkNoun s (s + "s") + } ; + + mkVerb : Str -> Str -> Verb = \x,y -> mkNoun y x ; + + regVerb : Str -> Verb = \s -> case last s of { + "s" | "z" => mkVerb s (s + "es") ; + "y" => mkVerb s (init s + "ies") ; + "o" => mkVerb s (s + "es") ; + _ => mkVerb s (s + "s") + } ; + + } diff --git a/doc/tutorial/resource/MorphoIta.gf b/doc/tutorial/resource/MorphoIta.gf new file mode 100644 index 000000000..2d5272812 --- /dev/null +++ b/doc/tutorial/resource/MorphoIta.gf @@ -0,0 +1,87 @@ +--# -path=.:prelude + + -- This is a simple Italian resource morphology for the GF tutorial. + + resource MorphoIta = open Prelude in { + + param + Number = Sg | Pl ; + Gender = Masc | Fem ; + + oper + Noun : Type = {s : Number => Str ; g : Gender} ; + Adjective : Type = {s : Gender => Number => Str} ; + + -- we will only use present indicative third person verb forms + + Verb : Type = {s : Number => Str} ; + + -- this function takes the gender and both singular and plural forms + + mkNoun : Gender -> Str -> Str -> Noun = \g,vino,vini -> { + s = table { + Sg => vino ; + Pl => vini + } ; + g = g + } ; + + -- this function takes the singular form + + regNoun : Str -> Noun = \vino -> + let + vin = init vino ; + o = last vino + in + case o of { + "a" => mkNoun Fem vino (vin + "e") ; -- pizza + "o" | "e" => mkNoun Masc vino (vin + "i") ; -- vino, pane + _ => mkNoun Masc vino vino -- tram + } ; + + -- to make nouns such as "carne", "università" feminine + + femNoun : Noun -> Noun = \mano -> { + s = mano.s ; + g = Fem + } ; + + -- this takes both genders and numbers + + mkAdjective : (x1,_,_,x4 : Str) -> Adjective = \nero,nera,neri,nere -> { + s = table { + Masc => (mkNoun Masc nero neri).s ; + Fem => (mkNoun Fem nera nere).s + } + } ; + + -- this takes the masculine singular form + + regAdjective : Str -> Adjective = \nero -> + let ner = init nero in + case last nero of { + "o" => mkAdjective (ner + "o") (ner + "a") (ner + "i") (ner + "e") ; + "e" => mkAdjective (ner + "e") (ner + "e") (ner + "i") (ner + "i") ; + _ => mkAdjective nero nero nero nero + } ; + + -- this function takes the singular and plural forms + + mkVerb : Str -> Str -> Verb = \ama,amano -> { + s = table { + Sg => ama ; + Pl => amano + } + } ; + + -- this function takes the infinitive form + + regVerb : Str -> Verb = \amare -> + let am = Predef.tk 3 amare in + case Predef.dp 3 amare of { + "ere" => mkVerb (am + "e") (am + "ono") ; -- premere + "ire" => mkVerb (am + "isce") (am + "iscono") ; -- finire + _ => mkVerb (am + "a") (am + "ano") -- amare + } ; + + } diff --git a/doc/tutorial/resource/Syntax.gf b/doc/tutorial/resource/Syntax.gf new file mode 100644 index 000000000..4fef6b543 --- /dev/null +++ b/doc/tutorial/resource/Syntax.gf @@ -0,0 +1,46 @@ +abstract Syntax = { + + flags startcat=Phr ; + + cat + S ; -- declarative sentence e.g. "this pizza is good" + NP ; -- noun phrase e.g. "this pizza" + CN ; -- common noun e.g. "pizza" + Det ; -- determiner e.g. "this" + AP ; -- adjectival phrase e.g. "very good" + AdA ; -- adadjective e.g. "very" + VP ; -- verb phrase e.g. "is good" + V ; -- intransitive verb e.g. "boil" + V2 ; -- two-place verb e.g. "eat" + + fun + PosVP, NegVP : NP -> VP -> S ; + + PredAP : AP -> VP ; + PredV : V -> VP ; + PredV2 : V2 -> NP -> VP ; + + DetCN : Det -> CN -> NP ; + + ModCN : AP -> CN -> CN ; + + AdAP : AdA -> AP -> AP ; + + + -- entries of the closed lexicon + + this_Det : Det ; + that_Det : Det ; + these_Det : Det ; + those_Det : Det ; + every_Det : Det ; + theSg_Det : Det ; + thePl_Det : Det ; + a_Det : Det ; + plur_Det : Det ; + two_Det : Det ; + + very_AdA : AdA ; + too_AdA : AdA ; + +}
\ No newline at end of file diff --git a/doc/tutorial/resource/SyntaxEng.gf b/doc/tutorial/resource/SyntaxEng.gf new file mode 100644 index 000000000..e4787af47 --- /dev/null +++ b/doc/tutorial/resource/SyntaxEng.gf @@ -0,0 +1,67 @@ +--# -path=.:prelude + +concrete SyntaxEng of Syntax = open Prelude, MorphoEng in { + + lincat + S = {s : Str} ; + NP = {s : Str ; n : Number} ; + CN = {s : Number => Str} ; + Det = {s : Str ; n : Number} ; + AP = {s : Str} ; + AdA = {s : Str} ; + VP = {s : Bool => Number => Str} ; + V = {s : Number => Str} ; + V2 = {s : Number => Str ; c : Str} ; + + lin + PosVP np vp = {s = np.s ++ vp.s ! True ! np.n} ; + NegVP np vp = {s = np.s ++ vp.s ! False ! np.n} ; + + PredAP ap = {s = \\b,n => copula b n ++ ap.s} ; + PredV v = {s = \\b,n => predVerb b n v} ; + PredV2 v2 np = {s = \\b,n => predVerb b n v2 ++ v2.c ++ np.s} ; + + DetCN det cn = {s = det.s ++ cn.s ! det.n ; n = det.n} ; + + ModCN ap cn = {s = \\n => ap.s ++ cn.s ! n} ; + + AdAP ada ap = {s = ada.s ++ ap.s} ; + + this_Det = {s = "this" ; n = Sg} ; + that_Det = {s = "that" ; n = Sg} ; + these_Det = {s = "these" ; n = Pl} ; + those_Det = {s = "those" ; n = Pl} ; + every_Det = {s = "every" ; n = Sg} ; + theSg_Det = {s = "the" ; n = Sg} ; + thePl_Det = {s = "the" ; n = Pl} ; + a_Det = {s = artIndef ; n = Sg} ; + plur_Det = {s = [] ; n = Pl} ; + two_Det = {s = "two" ; n = Pl} ; + + very_AdA = {s = "very"} ; + too_AdA = {s = "too"} ; + + + oper + copula : Bool -> Number -> Str = \b,n -> case n of { + Sg => posneg b "is" ; + Pl => posneg b "are" + } ; + + predVerb : Bool -> Number -> Verb -> Str = \b,n,verb -> + let inf = verb.s ! Sg in + case b of { + True => verb.s ! n ; + False => posneg b ((regVerb "do").s ! n) ++ inf + } ; + + posneg : Bool -> Str -> Str = \b,do -> case b of { + True => do ; + False => do + "n't" + } ; + + artIndef : Str = + pre {"a" ; "an" / strs {"a" ; "e" ; "i" ; "o"}} ; + + +} diff --git a/doc/tutorial/resource/SyntaxIta.gf b/doc/tutorial/resource/SyntaxIta.gf new file mode 100644 index 000000000..1633ac5f8 --- /dev/null +++ b/doc/tutorial/resource/SyntaxIta.gf @@ -0,0 +1,81 @@ +--# -path=.:prelude + +concrete SyntaxIta of Syntax = open Prelude, MorphoIta in { + + lincat + S = {s : Str} ; + NP = {s : Str ; g : Gender ; n : Number} ; + CN = {s : Number => Str ; g : Gender} ; + Det = {s : Gender => Str ; n : Number} ; + AP = {s : Gender => Number => Str} ; + AdA = {s : Str} ; + VP = {s : Bool => Gender => Number => Str} ; + V = {s : Number => Str} ; + V2 = {s : Number => Str ; c : Str} ; + + lin + PosVP np vp = {s = np.s ++ vp.s ! True ! np.g ! np.n} ; + NegVP np vp = {s = np.s ++ vp.s ! False ! np.g ! np.n} ; + + PredAP ap = {s = \\b,g,n => posneg b ++ copula n ++ ap.s ! g ! n} ; + PredV v = {s = \\b,_,n => posneg b ++ v.s ! n} ; + PredV2 v2 np = {s = \\b,_,n => posneg b ++ v2.s ! n ++ v2.c ++ np.s} ; + + DetCN det cn = {s = det.s ! cn.g ++ cn.s ! det.n ; g = cn.g ; n = det.n} ; + + ModCN ap cn = {s = \\n => cn.s ! n ++ ap.s ! cn.g ! n ; g = cn.g} ; + + AdAP ada ap = {s = \\n,g => ada.s ++ ap.s ! n ! g} ; + + this_Det = mkDet Sg (regAdjective "questo") ; + that_Det = mkDet Sg (regAdjective "quello") ; + these_Det = mkDet Pl (regAdjective "questo") ; + those_Det = mkDet Pl (regAdjective "quello") ; + every_Det = {s = \\_ => "ogni" ; n = Sg} ; + theSg_Det = {s = artDef Sg ; n = Sg} ; + thePl_Det = {s = artDef Pl ; n = Pl} ; + a_Det = {s = artIndef ; n = Pl} ; + plur_Det = {s = \\_ => [] ; n = Pl} ; + two_Det = {s = \\_ => "due" ; n = Pl} ; + + very_AdA = {s = "molto"} ; + too_AdA = {s = "troppo"} ; + + + oper + copula : Number -> Str = \n -> case n of { + Sg => "è" ; + Pl => "sono" + } ; + + posneg : Bool -> Str = \b -> case b of { + True => [] ; + False => "non" + } ; + + mkDet : Number -> Adjective -> Det = \n,adj -> { + s = \\g => adj.s ! g ! n ; + n = n ; + lock_Det = <> + } ; + + artDef : Number -> Gender => Str = \n -> case n of { + Sg => table { + Masc => pre {"il" ; "lo" / sImpuro} ; + Fem => "la" + } ; + Pl => table { + Masc => pre {"i" ; "gli" / sImpuro ; "gli" / vowel} ; + Fem => "le" + } + } ; + + artIndef : Gender => Str = table { + Masc => pre {"un" ; "uno" / sImpuro} ; + Fem => pre {"una" ; "un'" / vowel} + } ; + + sImpuro : Strs = strs {"sb" ; "sp" ; "sy" ; "z"} ; + vowel : Strs = strs {"a" ; "e" ; "i" ; "o" ; "u"} ; + +} |
