From 9488cae6f482ce3b936430c040c8d53e44549e3f Mon Sep 17 00:00:00 2001 From: David Bamutura Date: Fri, 24 May 2019 06:47:57 +0200 Subject: [PATCH] =Made some grammatical corrections based on tes grammar and worked on most functions in QustionCgg.gf --- src/rukiga/CatCgg.gf | 17 +++--- src/rukiga/LexiconCgg.gf | 2 +- src/rukiga/NounCgg.gf | 5 +- src/rukiga/QuestionCgg.gf | 106 ++++++++++++++++++++++++++++++++++-- src/rukiga/ResCgg.gf | 78 +++++++++++++------------- src/rukiga/StructuralCgg.gf | 20 +++---- src/rukiga/VerbCgg.gf | 44 ++++++++------- 7 files changed, 188 insertions(+), 84 deletions(-) diff --git a/src/rukiga/CatCgg.gf b/src/rukiga/CatCgg.gf index 83fadf40..3732bb3b 100755 --- a/src/rukiga/CatCgg.gf +++ b/src/rukiga/CatCgg.gf @@ -14,7 +14,13 @@ lincat S = SS ; -- declarative sentence e.g. "she lived here" Cl = Res.Clause ; -- declarative clause, with all tenses e.g. "she looks at this" + --Questions QCl = Res.Clause ** {posibleSubAgr: Res.Agreement =>Str} ; + IComp = {s : Str; other:Str; n : Res.INumber; requiresSubjPrefix: Bool;endOfSentence : Bool} ; + IP = {s :Str ; other:Str; n : Res.INumber; isVerbSuffix: Bool; requiresIPPrefix: Bool; aux:Str; endOfSentence:Bool}; -- other holds the Idet without a prefix + IAdv = {s : Str ; requiresSubjPrefix: Bool; endOfSentence:Bool}; + IDet = {s : Str ; n : Res.Number; requiresSubjPrefix: Bool}; + IQuant = {s : Res.Number =>Str ; requiresSubjPrefix: Bool}; RS = {s :Res.RForm => Str} ; -- relative e.g. "in which she lived" V,VS, VQ, VA = Res.Verb ; --change to {verb : Str ; comp = []} -- one-place verb e.g. "sleep" V2,V2Q, V2S = Res.Verb2; @@ -73,10 +79,7 @@ lincat Digits = {s : Res.CardOrd => Res.Agreement=>Str ; n : Res.Number ; tail : Px.DTail} ; Ord = {s :Res.Agreement=>Str; position1:Res.Position1} ; Card = {s :Res.Agreement=>Str; n : Res.Number} ; - IP = {s :Str ; other:Str; n : Res.Number; isVerbSuffix: Bool; requiresIPPrefix: Bool; aux:Str; endOfSentence:Bool}; -- other holds the Idet without a prefix - IAdv = {s : Str ; requiresSubjPrefix: Bool}; - IDet = {s : Str ; n : Res.Number; requiresSubjPrefix: Bool}; - IQuant = {s : Res.Number =>Str ; requiresSubjPrefix: Bool}; + DAP = Res.Determiner ; N2 = Res.Noun ** {c2 : Res.Agreement =>Str}; -- relational noun e.g. "son" Prep = Res.Preposition; -- preposition, or just case e.g. "in" @@ -85,11 +88,11 @@ lincat AdA = {s:Str; position1:Res.Position1}; linref - Cl =\cl -> cl.s ++ Res.mkSubjClitic cl.subjAgr ++ cl.root ++ BIND ++ cl.pres; + Cl =\cl -> cl.s ++ Res.mkSubjClitic cl.subjAgr ++ cl.root ++ BIND ++ cl.pres ++ cl.compl; QCl =\qcl -> qcl.s ++ qcl.posibleSubAgr ! (Res.mkAgreement Res.MU_BA Res.P3 Res.Sg) ++ qcl.root ++ BIND ++ qcl.pres; - --VP =\vp -> vp.adv ++ vp.s ++ BIND ++ vp.pres ++ vp.comp ++vp.comp2 ++ vp.ap; + VP =\vp -> vp.adv ++ vp.s ++ BIND ++ vp.pres ++ vp.comp ++vp.comp2 ++ vp.ap; VPSlash =\vpslash -> vpslash.s ++ BIND ++ vpslash.pres; - + --1 Cat: the Category System diff --git a/src/rukiga/LexiconCgg.gf b/src/rukiga/LexiconCgg.gf index 23e1c19a..868cdd60 100755 --- a/src/rukiga/LexiconCgg.gf +++ b/src/rukiga/LexiconCgg.gf @@ -115,7 +115,7 @@ lin come_V = mkV "ij"; go_V = mkV "gyend"; --: V ; -- Many words: kuza, kuraba,kutoora, kugyenda=go away, kushuma=go down jump_V = mkV "guruk" ; - play_V = mkV "zaan"; --: V ; + play_V = mkV "záàn"; --: V ; live_V = mkV "tuur" ; --manyF: kutuura i.e. live somewhere, stay = kuráàra run_V = mkV "íruk"; -- : V ; sleep_V = mkV "nyama" ; --: V ;--Kugwejegyera, kubyama diff --git a/src/rukiga/NounCgg.gf b/src/rukiga/NounCgg.gf index 5e408025..1f8b5eb5 100755 --- a/src/rukiga/NounCgg.gf +++ b/src/rukiga/NounCgg.gf @@ -8,6 +8,7 @@ lin --UsePN : PN -> NP ; -- John UsePN pn = {s = \\ _ => pn.s; agr = pn.a}; -- John + {need use of a pre} UsePron pron = let default3PAgr = (AgP3 Sg KI_BI) in case of { @@ -16,7 +17,7 @@ lin }; --UsePron pron = pron; -- the result of use pron is a NounPhrase --MassNP : CN -> NP ; -- (beer) - MassNP cn = {s = \\_ =>cn.s ! Pl ! Complete; agr = AgP3 Pl cn.gender}; --: CN -> NP ; -- milk + MassNP cn = {s = \\_ =>cn.s ! Sg ! Complete; agr = AgP3 Sg cn.gender}; --: CN -> NP ; -- milk --DetCN det cn = mkDeterminer det cn; --Should be nemed mkDetCN DetCN det cn = mkDetCN det cn; -- the man {- @@ -179,7 +180,7 @@ lin --CountNP : Det -> NP -> NP ; -- three of them, some of the boys CountNP det np = case det.doesAgree of { - True => {s=\\c=> np.s!c ++ det.s2 ! np.agr; agr = np.agr}; + True => {s=\\c=> np.s!c ++ "emye ahari" ++ det.s2 ! np.agr; agr = np.agr}; False => {s=\\c=> np.s!c ++ det.s; agr = np.agr} }; diff --git a/src/rukiga/QuestionCgg.gf b/src/rukiga/QuestionCgg.gf index 781cbf8b..fbb6d0bd 100755 --- a/src/rukiga/QuestionCgg.gf +++ b/src/rukiga/QuestionCgg.gf @@ -26,25 +26,119 @@ concrete QuestionCgg of Question = CatCgg ** open ResCgg, Prelude in { pastPart : Str; -- subject --root : Str ; -- dep. on Pol,Temp, e.g. "does","sleep" -} - compl = vp.comp -- after verb: complement, adverbs + compl = vp.comp -- after verb: complement, adverbs + } ; --QuestSlash : IP -> ClSlash -> QCl ; -- whom does John love + QuestSlash ip clSlash = + let comp = case clSlash.complType of{ + Ap => clSlash.ap; + Adverbial => clSlash.adv; + AdverbialVerb => clSlash.adV; + _ => [] + }; + in { + s = ip.s; + subjAgr = NONE; -- no option but to just pick one + posibleSubAgr = mkSubjCliticTable; + root = clSlash.s; + pres = clSlash.pres; + perf = clSlash.perf; + morphs = clSlash.morphs; + {- + inf : Str; + pres : Str; + past : Str; + presPart : Str; + pastPart : Str; -- subject + --root : Str ; -- dep. on Pol,Temp, e.g. "does","sleep" + -} + compl = comp -- after verb: complement, adverbs + } ; --QuestIAdv : IAdv -> Cl -> QCl ; -- why does John walk + QuestIAdv iadv cl = + { + s = iadv.s ++ cl.s; + subjAgr = cl.subjAgr; -- no option but to just pick one + posibleSubAgr = mkSubjCliticTable; + root = cl.s; + pres = cl.pres; + perf = cl.perf; + morphs = cl.morphs; + {- + inf : Str; + pres : Str; + past : Str; + presPart : Str; + pastPart : Str; -- subject + --root : Str ; -- dep. on Pol,Temp, e.g. "does","sleep" + -} + compl = cl.compl -- after verb: complement, adverbs + } ; --QuestIComp : IComp -> NP -> QCl ; -- where is John - + --QuestIComp icomp --IdetCN : IDet -> CN -> IP ; -- which five songs - IdetCN idet cn = case idet.requiresSubjPrefix of { - True => {s = cn.s!idet.n!Complete ++ mkSubjPrefix (mkAgreement cn.gender P3 idet.n) ++ idet.s; other =[]; n = idet.n; isVerbSuffix=False; requiresIPPrefix=True; aux= "ni"; endOfSentence = True}; - False => { s = cn.s!idet.n!Complete ++ idet.s; isVerbSuffix=False; other =[]; n=idet.n; requiresIPPrefix=True; aux= "ni"; endOfSentence = True} + IdetCN idet cn = let num = case idet.n of{ + Sg => ISg; + Pl => IPl + }; + + in + + + case idet.requiresSubjPrefix of { + True => {s = cn.s!idet.n!Complete ++ mkSubjPrefix (mkAgreement cn.gender P3 idet.n) ++ idet.s; other =[]; n = num; isVerbSuffix=False; requiresIPPrefix=True; aux= "ni"; endOfSentence = True}; + False => { s = cn.s!idet.n!Complete ++ idet.s; isVerbSuffix=False; other =[]; n=num; requiresIPPrefix=True; aux= "ni"; endOfSentence = True} }; --IdetIP : IDet -> IP ; -- which five --Noun Class has been ignored - IdetIP idet = { s = idet.s ; other = idet.s; isVerbSuffix=False; n=idet.n; requiresIPPrefix=True; aux= "ni"; endOfSentence = True}; + IdetIP idet = let num = case idet.n of{ + Sg => ISg; + Pl => IPl + }; + in + { + s = idet.s ; + other = idet.s; + isVerbSuffix=False; + n=num; requiresIPPrefix=True; + aux= "ni"; + endOfSentence = True + }; --IdetQuant : IQuant -> Num -> IDet ; -- which (five) --IdetQuant iquant num = { s = iquant.s ! num.n ; requiresSubjPrefix=True}; + + -- Interrogative complements to copulas can be both adverbs and + -- pronouns. + + --CompIAdv : IAdv -> IComp ; -- where (is it) + CompIAdv iadv = + { + s =iadv.s ; + other = []; + n = INeut; + isVerbSuffix=False; + requiresSubjPrefix =False; + requiresIPPrefix=False; + aux=[]; + endOfSentence=iadv.endOfSentence + }; + --CompIP : IP -> IComp ; -- who (is it) + CompIP ip = + { + s = ip.s; + other =ip.other; + n = ip.n; + isVerbSuffix = ip.isisVerbSuffix; + requiresSubjPrefix = False; + requiresIPPrefix = ip.requiresIPPrefix; + aux=ip.aux; + endOfSentence= ip.endOfSentence; + + }; {- --1 Question: Questions and Interrogative Pronouns diff --git a/src/rukiga/ResCgg.gf b/src/rukiga/ResCgg.gf index b5a1fec0..f7d64894 100755 --- a/src/rukiga/ResCgg.gf +++ b/src/rukiga/ResCgg.gf @@ -39,6 +39,7 @@ param SStandPron ; --Self-standing pronouns ImpPol = ImpPos | ImpNeg; + INumber = ISg | IPl | INeut; {- --there are several and i.e. -- na (two nouns, 2 Noun Phrases, 2 Pronouns, 2 relative subject clauses, ) @@ -104,8 +105,8 @@ oper --These are regular verbs with {a-ire} entry in the dictionary smartVerb : Str ->Verb = \rad ->{ s = rad; - pres = []; - perf = []; + pres = "a"; + perf = "ire"; morphs = mkVerbMorphs; isRegular = True; }; @@ -550,34 +551,35 @@ mkSubjPrefix : Agreement -> Str =\a ->case a of { }; mkSStand :Agreement -> Str = \a -> case a of { - AgMUBAP1 n => mkClitics "nyowe" "itwe" n; - --AgMUBAP1 Pl => "aba" ; - AgMUBAP2 n => mkClitics "iwe" "imwe" n; --probably an error check your grammar book - --AgMUBAP2 Pl => "aba" ; - AgP3 n MU_BA => mkClitics "uwe" "bo" n; - --AgP3 Pl MU_BA => "aba" ; - AgP3 Pl ZERO_BU => mkClitic "bwo" ; - AgP3 Sg BU_MA => mkClitic "bwo" ; - AgP3 Pl (KA_BU | RU_BU) => mkClitic "bwo" ; - AgP3 Pl (KI_BI | ZERO_BI) => mkClitic "byo" ; - AgP3 Pl (ZERO_MA | KU_MA | RI_MA | I_MA | BU_MA) => mkClitic "go"; - AgP3 (Sg | Pl) HA => mkClitic "ho" ; -- of place HA - AgP3 (Sg | Pl) MU => mkClitic "mwo" ; -- of place MU - AgP3 (Sg | Pl) KU => mkClitic "yo" ; -- of place KU - AgP3 Sg (I_ZERO | I_MA | RI_MA) =>mkClitic "ryo" ; - AgP3 Sg (KA_ZERO | KA_BU) =>mkClitic "ko" ; - AgP3 Sg KI_BI => mkClitic "kyo" ; - AgP3 Sg (KU_ZERO | KU_MA) => mkClitic "kwo" ; - AgP3 Sg (MU_MI | MU_ZERO) => mkClitic "gwo" ; - AgP3 Sg (RU_ZERO | RU_BU | RU_MA| RU_N) => mkClitic "rwo" ; - AgP3 Pl (ZERO_TU | KA_TU) =>mkClitic "two" ; - AgP3 Sg (ZERO_ZERO | N_N) =>mkClitic "yo" ; - AgP3 Pl ZERO_MI =>mkClitic "yo" ; - AgP3 Pl MU_MI => mkClitic "yo"; - AgP3 Pl (ZERO_ZERO | ZERO_N | N_N | RU_N) =>mkClitic "zo" ; - AgP3 Sg GU_GA => mkClitic "gwo" ; - AgP3 Pl GU_GA => mkClitic "go" ; - _ => mkClitic "XXX" -- error checking for any case not catered for + AgMUBAP1 Sg => "nyowe"; + AgMUBAP1 Pl => "itwe"; + AgMUBAP1 Pl => "aba" ; + AgMUBAP2 Sg => "iwe" ; --probably an error check your grammar book + AgMUBAP2 Pl => "imwe" ; + AgP3 Sg MU_BA => "uwe" ; + AgP3 Pl MU_BA => "bo" ; + AgP3 Pl ZERO_BU => "bwo" ; + AgP3 Sg BU_MA => "bwo" ; + AgP3 Pl (KA_BU | RU_BU) => "bwo" ; + AgP3 Pl (KI_BI | ZERO_BI) => "byo" ; + AgP3 Pl (ZERO_MA | KU_MA | RI_MA | I_MA | BU_MA) => "go"; + AgP3 (Sg | Pl) HA => "ho" ; -- of place HA + AgP3 (Sg | Pl) MU => "mwo" ; -- of place MU + AgP3 (Sg | Pl) KU => "yo" ; -- of place KU + AgP3 Sg (I_ZERO | I_MA | RI_MA) => "ryo" ; + AgP3 Sg (KA_ZERO | KA_BU) => "ko" ; + AgP3 Sg KI_BI => "kyo" ; + AgP3 Sg (KU_ZERO | KU_MA) => "kwo" ; + AgP3 Sg (MU_MI | MU_ZERO) => "gwo" ; + AgP3 Sg (RU_ZERO | RU_BU | RU_MA| RU_N) => "rwo" ; + AgP3 Pl (ZERO_TU | KA_TU) =>"two" ; + AgP3 Sg (ZERO_ZERO | N_N) => "yo" ; + AgP3 Pl ZERO_MI => "yo" ; + AgP3 Pl MU_MI => "yo"; + AgP3 Pl (ZERO_ZERO | ZERO_N | N_N | RU_N) => "zo" ; + AgP3 Sg GU_GA => "gwo" ; + AgP3 Pl GU_GA => "go" ; + _ => "XXX-Failed SStand" -- error checking for any case not catered for }; -- This involved only change of the personal pronouns as for selfstanding pronouns. @@ -1072,14 +1074,14 @@ mkSubjPrefix : Agreement -> Str =\a ->case a of { -} mkDetCN : Determiner -> Noun -> NounPhrase = \ det, cn -> - case of { - => {s = \\_=> - let - subjClitic = mkSubjClitic (AgP3 det.num cn.gender) - in cn.s!det.num! det.ntype ++ subjClitic ++ det.s; agr = AgP3 det.num cn.gender}; - => { s =\\_ => det.s ++ cn.s !det.num ! det.ntype; agr = AgP3 det.num cn.gender} --; - -- => {s = \\_=> cn.s!det.ntype!det.num; agr = AgP3 det.num cn.gender } - }; + let subjClitic = mkSubjClitic (AgP3 det.num cn.gender) + in + case of { + => {s = \\_=> subjClitic ++ cn.s!det.num! det.ntype ++ subjClitic ++ det.s; agr = AgP3 det.num cn.gender}; + => {s = \\_=>cn.s!det.num! det.ntype ++ subjClitic ++ det.s; agr = AgP3 det.num cn.gender}; + => { s =\\_ => det.s ++ cn.s !n ! det.ntype; agr = AgP3 det.num cn.gender} --; + -- => {s = \\_=> cn.s!det.ntype!det.num; agr = AgP3 det.num cn.gender } + }; diff --git a/src/rukiga/StructuralCgg.gf b/src/rukiga/StructuralCgg.gf index 4e1be08c..c17f123f 100755 --- a/src/rukiga/StructuralCgg.gf +++ b/src/rukiga/StructuralCgg.gf @@ -158,17 +158,17 @@ lin {-Beggining of Interrogative Pronoun-} - whatPl_IP = { s= "ki"; other =[]; n = Pl; isVerbSuffix = True; requiresIPPrefix = False; aux=[]; endOfSentence = True} ; -- what (plural) - whatSg_IP = { s= "ki"; other =[]; n = Sg; isVerbSuffix = True; requiresIPPrefix = False; aux=[]; endOfSentence = True}; --: IP ; -- what (singular) - whoPl_IP = { s= "ha"; other =[]; n = Pl; isVerbSuffix = True; requiresIPPrefix = False; aux="ni"; endOfSentence = True} ;--: IP ; -- who (plural) - whoSg_IP = { s= "ha"; other =[]; n = Sg; isVerbSuffix = True; requiresIPPrefix = False; aux=[]; endOfSentence = True}; --: IP ; -- who (singular) + whatPl_IP = { s= "ki"; other =[]; n = IPl; isVerbSuffix = True; requiresIPPrefix = False; aux=[]; endOfSentence = True} ; -- what (plural) + whatSg_IP = { s= "ki"; other =[]; n = ISg; isVerbSuffix = True; requiresIPPrefix = False; aux=[]; endOfSentence = True}; --: IP ; -- what (singular) + whoPl_IP = { s= "ha"; other =[]; n = IPl; isVerbSuffix = True; requiresIPPrefix = False; aux="ni"; endOfSentence = True} ;--: IP ; -- who (plural) + whoSg_IP = { s= "ha"; other =[]; n = ISg; isVerbSuffix = True; requiresIPPrefix = False; aux=[]; endOfSentence = True}; --: IP ; -- who (singular) --You may need to use booleans to indicate that you need these tables rather than carrying them. - how_IAdv = {s ="ta"; requiresSubjPrefix = True}; --: IAdv ; + how_IAdv = {s ="ta"; requiresSubjPrefix = True; endOfSentence =True}; --: IAdv ; --how8much_IAdv = {s ="kwiga"; s2requireSubjPrefix = True};--: IAdv ; - when_IAdv = {s ="ryari"; requiresSubjPrefix = False}; --: IAdv ; - where_IAdv = {s ="nkahe"; requiresSubjPrefix = False}; --: IAdv ; - why_IAdv = {s ="ahabweki"; requiresSubjPrefix = False};--: IAdv ; + when_IAdv = {s ="ryari"; requiresSubjPrefix = False; endOfSentence =True}; --: IAdv ; + where_IAdv = {s ="nkahe"; requiresSubjPrefix = False; endOfSentence =True}; --: IAdv ; + why_IAdv = {s ="ahabweki"; requiresSubjPrefix = False; endOfSentence =False};--: IAdv ; how8many_IDet ={s ="ngahe"; other =[]; n =Pl; requiresSubjPrefix = False; endOfSentence = True};--: IDet ; @@ -184,7 +184,7 @@ lin someSg_Det = { s =[]; - s2 =\\agr => mkSubjCliticTableSg ! agr ++ "mwe"; + s2 =\\agr => mkSubjCliticTableSg ! agr ++ BIND++ "mwe"; ntype = Complete; num = Sg; pos = PreDeterminer; @@ -193,7 +193,7 @@ lin somePl_Det = { s =[]; - s2 =\\agr => mkSubjCliticTablePl ! agr ++ "mwe"; + s2 =\\agr => mkSubjCliticTablePl ! agr ++ BIND++ "mwe"; ntype = Complete; num = Pl; pos = PreDeterminer; diff --git a/src/rukiga/VerbCgg.gf b/src/rukiga/VerbCgg.gf index 5cdfe17e..23a610ab 100755 --- a/src/rukiga/VerbCgg.gf +++ b/src/rukiga/VerbCgg.gf @@ -23,22 +23,25 @@ lin -- UseComp : Comp -> VP ; -- be warm means complement of a copula especially adjectival Phrase --AdjectivalPhrase : Type = {s : Str ; post : Str; isPre : Bool; isProper : Bool; isPrep: Bool}; - UseComp comp = { - s = comp.s; --Assuming there is no AP which is prepositional - pres =[]; - perf = []; - morphs=\\form,morphs=>[]; - comp = []; - comp2 = []; - ap = []; - isCompApStem = False; - agr = AgrNo; - isRegular = False; - adv = []; - containsAdv =False; - adV =[]; - containsAdV = False - }; --its not generating any sentence + UseComp comp = let auxBe = mkBecome + + in + { + s = auxBe.s ++ BIND ++auxBe.pres++ comp.s; --Assuming there is no AP which is prepositional + pres =[]; + perf = []; + morphs=\\form,morphs=>[]; + comp = []; + comp2 = []; + ap = []; + isCompApStem = False; + agr = AgrNo; + isRegular = False; + adv = []; + containsAdv =False; + adV =[]; + containsAdV = False + }; --its not generating any sentence -- CompAP : AP -> Comp; -- (be) small CompAP ap = {s=ap.s! AgP3 Sg KI_BI}; -- used a hack. @@ -225,8 +228,9 @@ lin ComplVV vv vp = let vpPres = "ku" ++ BIND ++ vp.s ++ BIND ++ vp.pres; in case vv.whenUsed of { VVPerf => { - s= vv.s ++ BIND ++ vv.perf; - pres =vv.pres; perf=vv.perf; + s= vv.s ++ BIND ++ vv.perf ++ vpPres; + pres = [];--vv.pres; + perf= []; -- vv.perf; morphs = vv.morphs; comp=vp.comp ; comp2 = vp.comp2; @@ -240,8 +244,8 @@ lin }; _ => { s= vv.s ++ BIND ++ vv.pres ++ vpPres; - pres =vv.pres; - perf=vv.perf; + pres = [];--vv.pres; + perf= [];--vv.perf; morphs = vv.morphs; comp=vp.comp ; comp2 = vp.comp2;