From 0a3cf118597356b5a7bc435453a367f4633331d5 Mon Sep 17 00:00:00 2001 From: aarne Date: Sat, 2 Jun 2007 21:50:55 +0000 Subject: [PATCH] example generation started --- lib/resource-1.0/api/Constructors.gf | 54 +++++++++++--------- lib/resource-1.0/api/examples/Exx.gf | 21 ++++++++ lib/resource-1.0/api/examples/ExxEng.gf | 7 +++ lib/resource-1.0/api/examples/ExxI.gf | 50 ++++++++++++++++++ lib/resource-1.0/api/examples/ExxSwe.gf | 7 +++ lib/resource-1.0/api/examples/mkgfs.hs | 16 ++++++ lib/resource-1.0/english/NounEng.gf | 2 +- lib/resource-1.0/scandinavian/PhraseScand.gf | 1 + 8 files changed, 133 insertions(+), 25 deletions(-) create mode 100644 lib/resource-1.0/api/examples/Exx.gf create mode 100644 lib/resource-1.0/api/examples/ExxEng.gf create mode 100644 lib/resource-1.0/api/examples/ExxI.gf create mode 100644 lib/resource-1.0/api/examples/ExxSwe.gf create mode 100644 lib/resource-1.0/api/examples/mkgfs.hs diff --git a/lib/resource-1.0/api/Constructors.gf b/lib/resource-1.0/api/Constructors.gf index 258c012d0..bf24513d6 100644 --- a/lib/resource-1.0/api/Constructors.gf +++ b/lib/resource-1.0/api/Constructors.gf @@ -64,8 +64,8 @@ incomplete resource Constructors = open Grammar in { oper mkText : overload { - mkText : Phr -> Text ; -- John walks. - mkText : Phr -> (Punct) -> (Text) -> Text ; -- John walks? Yes! + mkText : Phr -> Text ; -- But John walks. + mkText : Phr -> (Punct) -> (Text) -> Text ; -- John walks? Yes. -- A text can also be directly built from utterances, which in turn can -- be directly built from sentences, present-tense clauses, questions, or @@ -132,12 +132,12 @@ incomplete resource Constructors = open Grammar in { mkUtt : S -> Utt ; -- John walked mkUtt : Cl -> Utt ; -- John walks mkUtt : QS -> Utt ; -- did John walk - mkUtt : Imp -> Utt ; -- help yourself + mkUtt : Imp -> Utt ; -- love yourself -- Imperatives can also vary in $ImpForm$ (number/politeness) and -- polarity. - mkUtt : (ImpForm) -> (Pol) -> Imp -> Utt ; -- don't help yourselves + mkUtt : (ImpForm) -> (Pol) -> Imp -> Utt ; -- don't love yourselves -- Utterances can also be formed from interrogative phrases and -- interrogative adverbials, noun phrases, adverbs, and verb phrases. @@ -151,7 +151,7 @@ incomplete resource Constructors = open Grammar in { -- The plural first-person imperative is a special construction. - letsUtt : VP -> Utt ; -- let's walk + lets_Utt : VP -> Utt ; -- let's walk --2 Auxiliary parameters for phrases and sentences @@ -161,8 +161,8 @@ incomplete resource Constructors = open Grammar in { -- Polarity is a parameter that sets a clause to positive or negative -- form. Since positive is the default, it need never be given explicitly. - posPol : Pol ; -- (John walks) [default] - negPol : Pol ; -- (John doesn't walk) + positivePol : Pol ; -- (John walks) [default] + negativePol : Pol ; -- (John doesn't walk) --3 Ant, anteriority @@ -170,8 +170,8 @@ incomplete resource Constructors = open Grammar in { -- anterior to some other reference time. -- Since simultaneous is the default, it need never be given explicitly. - simulAnt : Ant ; -- (John walks) [default] - anterAnt : Ant ; -- (John has walked) --# notpresent + simultaneousAnt : Ant ; -- (John walks) [default] + anteriorAnt : Ant ; -- (John has walked) --# notpresent --3 Tense, tense @@ -190,9 +190,9 @@ incomplete resource Constructors = open Grammar in { -- by reference to the person or persons addressed. -- Since singular is the default, it need never be given explicitly. - sgImpForm : ImpForm ; -- (help yourself) [default] - plImpForm : ImpForm ; -- (help yourselves) - polImpForm : ImpForm ; -- (help yourself) [polite singular] + singularImpForm : ImpForm ; -- (help yourself) [default] + pluralImpForm : ImpForm ; -- (help yourselves) + politeImpForm : ImpForm ; -- (help yourself) [polite singular] --2 Sentences and clauses @@ -208,10 +208,10 @@ incomplete resource Constructors = open Grammar in { -- Sentences can be combined with conjunctions. This can apply to a pair -- of sentences, but also to a list of more than two. - mkS : Conj -> S -> S -> S ; -- John walks and Mary talks - mkS : Conj -> ListS -> S ; -- John walks, Mary talks, and Bob runs - mkS : DConj -> S -> S -> S ; -- either John walks or Mary runs - mkS : DConj -> ListS -> S ; -- either John walks, Mary talks, or Bob runs + mkS : Conj -> S -> S -> S ; -- John walks and I run + mkS : Conj -> ListS -> S ; -- John walks, I run and you sleep + mkS : DConj -> S -> S -> S ; -- either John walk or I run + mkS : DConj -> ListS -> S ; -- either John walks, I run or you sleep -- A sentence can be prefixed by an adverb. @@ -1053,10 +1053,16 @@ incomplete resource Constructors = open Grammar in { mkPhr = overload { mkPhr : PConj -> Utt -> Voc -> Phr -- But go home my friend = PhrUtt ; + mkPhr : Utt -> Voc -> Phr + = \u,v -> PhrUtt NoPConj u v ; + mkPhr : PConj -> Utt -> Phr + = \u,v -> PhrUtt u v NoVoc ; mkPhr : Utt -> Phr -- Go home = \u -> PhrUtt NoPConj u NoVoc ; mkPhr : S -> Phr -- I go home = \s -> PhrUtt NoPConj (UttS s) NoVoc ; + mkPhr : Cl -> Phr -- I go home + = \s -> PhrUtt NoPConj (UttS (UseCl TPres ASimul PPos s)) NoVoc ; mkPhr : QS -> Phr -- I go home = \s -> PhrUtt NoPConj (UttQS s) NoVoc ; mkPhr : Imp -> Phr -- I go home @@ -1070,11 +1076,11 @@ incomplete resource Constructors = open Grammar in { mkVoc : NP -> Voc = VocNP ; noVoc : Voc = NoVoc ; - posPol : Pol = PPos ; - negPol : Pol = PNeg ; + positivePol : Pol = PPos ; + negativePol : Pol = PNeg ; - simulAnt : Ant = ASimul ; - anterAnt : Ant = AAnter ; --# notpresent + simultaneousAnt : Ant = ASimul ; + anteriorAnt : Ant = AAnter ; --# notpresent presentTense : Tense = TPres ; pastTense : Tense = TPast ; --# notpresent @@ -1084,9 +1090,9 @@ incomplete resource Constructors = open Grammar in { param ImpForm = IFSg | IFPl | IFPol ; oper - sgImpForm : ImpForm = IFSg ; - plImpForm : ImpForm = IFPl ; - polImpForm : ImpForm = IFPol ; + singularImpForm : ImpForm = IFSg ; + pluralImpForm : ImpForm = IFPl ; + politeImpForm : ImpForm = IFPol ; mkUttImp : ImpForm -> Pol -> Imp -> Utt = \f,p,i -> case f of { IFSg => UttImpSg p i ; @@ -1121,7 +1127,7 @@ incomplete resource Constructors = open Grammar in { = UttVP } ; - letsUtt : VP -> Utt = ImpPl1 ; + lets_Utt : VP -> Utt = ImpPl1 ; mkQCl = overload { diff --git a/lib/resource-1.0/api/examples/Exx.gf b/lib/resource-1.0/api/examples/Exx.gf new file mode 100644 index 000000000..4c1535be4 --- /dev/null +++ b/lib/resource-1.0/api/examples/Exx.gf @@ -0,0 +1,21 @@ +abstract Exx = Cat ** { + +fun + + ex1_Text, ex2_Text, ex3_Text, ex4_Text, ex5_Text, ex6_Text, ex7_Text, ex8_Text : Text ; + + ex1_Phr, ex2_Phr, ex3_Phr, ex4_Phr, ex5_Phr, ex6_Phr : Phr ; + + ex1_PConj : PConj ; + + ex1_Voc : Voc ; + + ex1_Utt, ex2_Utt, ex3_Utt, ex4_Utt, ex5_Utt, ex6_Utt, ex7_Utt, ex8_Utt, ex8_Utt, ex9_Utt, ex10_Utt, ex11_Utt : Utt ; + + ex1_S, ex2_S, ex3_S, ex4_S, ex5_S, ex6_S, ex7_S : S ; + + ex1_Cl, ex2_Cl, ex3_Cl, ex4_Cl, ex5_Cl, ex6_Cl, ex7_Cl, ex8_Cl, ex8_Cl, ex10_Cl, + ex11_Cl, ex12_Cl, ex13_Cl, ex14_Cl, ex15_Cl, ex16_Cl, ex17_Cl, ex18_Cl : Cl ; + + +} diff --git a/lib/resource-1.0/api/examples/ExxEng.gf b/lib/resource-1.0/api/examples/ExxEng.gf new file mode 100644 index 000000000..15cf61ab3 --- /dev/null +++ b/lib/resource-1.0/api/examples/ExxEng.gf @@ -0,0 +1,7 @@ +--# -path=.:..:alltenses:prelude + +concrete ExxEng of Exx = CatEng ** ExxI with + (Lang = LangEng), + (Constructors = ConstructorsEng) ; + + diff --git a/lib/resource-1.0/api/examples/ExxI.gf b/lib/resource-1.0/api/examples/ExxI.gf new file mode 100644 index 000000000..2e4bc0444 --- /dev/null +++ b/lib/resource-1.0/api/examples/ExxI.gf @@ -0,0 +1,50 @@ +incomplete concrete ExxI of Exx = Cat ** open Lang, Constructors in { + +-- examples for Constructors. + + lin + ex1_Text = mkText (mkPhr but_PConj (mkUtt (mkCl john_NP walk_V))) ; + ex2_Text = mkText (mkPhr (mkCl john_NP walk_V)) questMarkPunct (mkText yes_Phr) ; + ex3_Text = mkText (mkUtt john_NP) ; + ex4_Text = mkText (mkS pastTense (mkCl john_NP walk_V)) ; + ex5_Text = mkText (mkCl john_NP walk_V) ; + ex6_Text = mkText (mkQS pastTense (mkQCl (mkCl john_NP walk_V))) ; + ex7_Text = mkText (mkImp walk_V) ; + ex8_Text = emptyText ; + + ex1_Phr = mkPhr (mkUtt why_IAdv) ; + ex2_Phr = mkPhr but_PConj (mkUtt why_IAdv) (mkVoc john_NP) ; + ex3_Phr = mkPhr (mkS pastTense (mkCl john_NP walk_V)) ; + ex4_Phr = mkPhr (mkCl john_NP walk_V) ; + ex5_Phr = mkPhr (mkQS pastTense (mkQCl (mkCl john_NP walk_V))) ; + ex6_Phr = mkPhr (mkImp walk_V) ; + + ex1_PConj = mkPConj and_Conj ; + + ex1_Voc = mkVoc john_NP ; + + ex1_Utt = mkUtt (mkS pastTense (mkCl john_NP walk_V)) ; + ex2_Utt = mkUtt (mkCl john_NP walk_V) ; + ex3_Utt = mkUtt (mkQS pastTense (mkQCl (mkCl john_NP walk_V))) ; + ex4_Utt = mkUtt (mkImp walk_V) ; + ex5_Utt = mkUtt pluralImpForm negativePol (mkImp (reflexiveVP love_V2)) ; + ex6_Utt = mkUtt whoSg_IP ; + ex7_Utt = mkUtt why_IAdv ; + ex8_Utt = mkUtt john_NP ; + ex9_Utt = mkUtt here_Adv ; + ex10_Utt = mkUtt (mkVP walk_V) ; + ex11_Utt = lets_Utt (mkVP walk_V) ; + + ex1_S = mkS (mkCl john_NP walk_V) ; + ex2_S = mkS conditionalTense anteriorAnt negativePol (mkCl john_NP walk_V) ; + ex3_S = mkS and_Conj (mkS (mkCl john_NP walk_V)) (mkS (mkCl (mkNP i_Pron) run_V)) ; + ex4_S = mkS and_Conj (mkListS (mkS (mkCl john_NP walk_V)) (mkListS (mkS (mkCl (mkNP i_Pron) run_V)) (mkS (mkCl (mkNP youSg_Pron) sleep_V)))) ; + ex5_S = mkS either7or_DConj (mkS (mkCl john_NP walk_V)) (mkS (mkCl (mkNP i_Pron) run_V)) ; + ex6_S = mkS either7or_DConj (mkListS (mkS (mkCl john_NP walk_V)) (mkListS (mkS (mkCl (mkNP i_Pron) run_V)) (mkS (mkCl (mkNP youSg_Pron) sleep_V)))) ; + + + + oper + john_PN = paris_PN ; ---- + john_NP = mkNP john_PN ; +} diff --git a/lib/resource-1.0/api/examples/ExxSwe.gf b/lib/resource-1.0/api/examples/ExxSwe.gf new file mode 100644 index 000000000..578e86160 --- /dev/null +++ b/lib/resource-1.0/api/examples/ExxSwe.gf @@ -0,0 +1,7 @@ +--# -path=.:..:alltenses:prelude + +concrete ExxSwe of Exx = CatSwe ** ExxI with + (Lang = LangSwe), + (Constructors = ConstructorsSwe) ; + + diff --git a/lib/resource-1.0/api/examples/mkgfs.hs b/lib/resource-1.0/api/examples/mkgfs.hs new file mode 100644 index 000000000..c0bd06f84 --- /dev/null +++ b/lib/resource-1.0/api/examples/mkgfs.hs @@ -0,0 +1,16 @@ +-- to process constructor examples to lin commans + +main = mkgfs + +src = "ExxI.gf" +script = "exx.gfs" + +mkgfs = do + writeFile script "" + readFile src >>= (mapM addLin . lines) + + +addLin s = case words s of + c@('e':'x':_):_ -> appendFile script ("l " ++ c ++ "\n") + _ -> return () + diff --git a/lib/resource-1.0/english/NounEng.gf b/lib/resource-1.0/english/NounEng.gf index 635dbe8d2..7d718ceda 100644 --- a/lib/resource-1.0/english/NounEng.gf +++ b/lib/resource-1.0/english/NounEng.gf @@ -46,7 +46,7 @@ concrete NounEng of Noun = CatEng ** open ResEng, Prelude in { NumInt n = {s = n.s; n = table (Predef.Ints 1 * Predef.Ints 9) { <0,1> => Sg ; _ => Pl - } ! + } ! <1,2> ---- parser bug (AR 2/6/2007) } ; OrdInt n = {s = n.s ++ "th"} ; --- diff --git a/lib/resource-1.0/scandinavian/PhraseScand.gf b/lib/resource-1.0/scandinavian/PhraseScand.gf index d8e45acf7..cf1934be0 100644 --- a/lib/resource-1.0/scandinavian/PhraseScand.gf +++ b/lib/resource-1.0/scandinavian/PhraseScand.gf @@ -8,6 +8,7 @@ incomplete concrete PhraseScand of Phrase = UttQS qs = {s = qs.s ! QDir} ; UttImpSg pol imp = {s = pol.s ++ imp.s ! pol.p ! Sg} ; UttImpPl pol imp = {s = pol.s ++ imp.s ! pol.p ! Pl} ; + UttImpPol pol imp = {s = pol.s ++ imp.s ! pol.p ! Sg} ; --- works for adj but not for refl UttIP ip = {s = ip.s ! nominative} ; --- Acc also UttIAdv iadv = iadv ;