From 8c8612b7d798d1f9e0eec3f2599d6a7c13130a18 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Wed, 24 Jul 2019 19:24:19 +0300 Subject: [PATCH 1/3] (Som) Take passive out of Prep + add reflexive as PrepAgr + update tests --- src/somali/ParadigmsSom.gf | 6 +-- src/somali/ParamSom.gf | 50 +++++++++---------- src/somali/ResSom.gf | 90 ++++++++++++++++++++--------------- src/somali/unittest/vp.gftest | 4 +- 4 files changed, 79 insertions(+), 71 deletions(-) diff --git a/src/somali/ParadigmsSom.gf b/src/somali/ParadigmsSom.gf index 81e9fe00c..1fb3be59e 100644 --- a/src/somali/ParadigmsSom.gf +++ b/src/somali/ParadigmsSom.gf @@ -103,10 +103,10 @@ oper mkPrep = overload { mkPrep : Str -> CatSom.Prep = \s -> - lin Prep ((ResSom.mkPrep s s s s s s) ** { + lin Prep ((ResSom.mkPrep s s s s s s s) ** { c2=noPrep ; sii,dhex,berri=[]}) ; - mkPrep : (x1,_,_,_,_,x6 : Str) -> CatSom.Prep = \a,b,c,d,e,f -> - lin Prep ((ResSom.mkPrep a b c d e f) ** { + mkPrep : (x1,_,_,_,_,_,x7 : Str) -> CatSom.Prep = \a,b,c,d,e,f,g -> + lin Prep ((ResSom.mkPrep a b c d e f g) ** { c2=noPrep ; sii,dhex,berri=[]}) ; mkPrep : Preposition -> CatSom.Prep = \p -> lin Prep ((prep p) ** {sii,dhex,berri=[]}) ; diff --git a/src/somali/ParamSom.gf b/src/somali/ParamSom.gf index 2cd9a8bb3..dda95ebe3 100644 --- a/src/somali/ParamSom.gf +++ b/src/somali/ParamSom.gf @@ -142,6 +142,7 @@ param | Pl1_Prep Inclusion | Pl2_Prep | Impers_Prep + | Reflexive_Prep | P3_Prep ; State = Definite | Indefinite ; @@ -193,41 +194,34 @@ param param Preposition = U | Ku | Ka | La | NoPrep ; - PrepositionPlus = P Preposition - | Passive ; -- Hack: RGL only supports V2s as passive, so I can reuse V2's preposition slot for passives as well, and save >200 parameters. (Don't ask.) PrepCombination = Ugu | Uga | Ula | Kaga | Kula | Kala - | Lagu -- laygu, lagugu, nalagu, laydinku - | Laga -- layga, lagaa, nalaga, laydinka - -- | TODO rest of combinations with impersonal-la - -- | TODO incorporate reflexive too - | Single PrepositionPlus ; + | Passive | Lagu | Laga -- TODO all combinations with impersonal la + | Single Preposition ; oper - combine : PrepositionPlus -> Preposition -> PrepCombination = \p1,p2 -> - let oneWay : PrepositionPlus => Preposition => PrepCombination = - \\x,y => case of { - => Single Passive ; - => Lagu ; - => Laga ; - => Single (P p) ; -- TODO rest of combinations -

=> case of { - => Ugu ; - => Uga ; - => Ula ; - => Kaga ; - => Kula ; - => Kala ; - => Single (P p) ; - => Single x ; - => Single x }} -- for trying both ways - in case oneWay ! P p2 ! (pp2prep p1) of { + combine : (isPassive : Bool) -> Preposition -> Preposition -> PrepCombination = \isPass,p1,p2 -> + let oneWay : Preposition => Preposition => PrepCombination = + \\x,y => case of { + => Passive ; + => Lagu ; + => Laga ; + => Single p ; -- TODO all combinations + => case of { + => Ugu ; + => Uga ; + => Ula ; + => Kaga ; + => Kula ; + => Kala ; + => Single p ; + => Single x ; + => Single x }} -- for trying both ways + in case oneWay ! p2 ! p1 of { Single _ => oneWay ! p1 ! p2 ; z => z } ; - pp2prep : PrepositionPlus -> Preposition = \pp -> - case pp of {P p => p ; _ => NoPrep} ; -------------------------------------------------------------------------------- -- Verbs diff --git a/src/somali/ResSom.gf b/src/somali/ResSom.gf index 6bc484813..9640e08b1 100644 --- a/src/somali/ResSom.gf +++ b/src/somali/ResSom.gf @@ -324,66 +324,80 @@ oper Prep : Type = {s : PrepAgr => Str} ; - mkPrep : (x1,_,_,_,_,x6 : Str) -> Prep = \ku,ii,kuu,noo,idiin,loo -> { + mkPrep : (x1,_,_,_,_,_,x7 : Str) -> Prep = \ku,ii,kuu,noo,idiin,isku,loo -> { s = table { + P3_Prep => ku ; Sg1_Prep => ii ; Sg2_Prep => kuu ; Pl2_Prep => idiin ; Pl1_Prep Excl => noo ; Pl1_Prep Incl => "i" + noo ; - Impers_Prep => loo ; - P3_Prep => ku + Reflexive_Prep => isku ; + Impers_Prep => loo } } ; - prep : Preposition -> (Prep ** {c2 : Preposition}) = \p -> prepTable ! P p ** {c2 = p} ; + prep : Preposition -> (Prep ** {c2 : Preposition}) = \p -> prepTable ! p ** {c2 = p} ; - prepTable : PrepositionPlus => Prep = table { - P Ku => mkPrep "ku" "igu" "kugu" "nagu" "idinku" "lagu" ; - P Ka => mkPrep "ka" "iga" "kaa" "naga" "idinka" "laga" ; - P La => mkPrep "la" "ila" "kula" "nala" "idinla" "lala" ; - P U => mkPrep "u" "ii" "kuu" "noo" "idiin" "loo" ; - P NoPrep => mkPrep [] "i" "ku" "na" "idin" "la" ; - -- impersonal subject clitic combining with object clitics. - Passive => mkPrep "la" "la i" "lagu" "nala" "laydin" "la" + prepTable : Preposition => Prep = table { + Ku => mkPrep "ku" "igu" "kugu" "nagu" "idinku" "isku" "lagu" ; + Ka => mkPrep "ka" "iga" "kaa" "naga" "idinka" "iska" "laga" ; + La => mkPrep "la" "ila" "kula" "nala" "idinla" "isla" "lala" ; + U => mkPrep "u" "ii" "kuu" "noo" "idiin" "is_u_???:TODO" "loo" ; + NoPrep => mkPrep [] "i" "ku" "na" "idin" "is" "la" } ; prepCombTable : PrepAgr => PrepCombination => Str = table { - Sg1_Prep => table { Ugu => "iigu" ; Uga => "iiga" ; + Sg1_Prep => table { + Ugu => "iigu" ; Uga => "iiga" ; Ula => "iila" ; Kaga => "igaga" ; Kula => "igula" ; Kala => "igala" ; + Passive => "la i" ; Lagu => "laygu" ; Laga => "layga" ; Single p => (prepTable ! p).s ! Sg1_Prep } ; Sg2_Prep => table { Ugu => "kuugu" ; Uga => "kaaga" ; Ula => "kuula" ; Kaga => "kaaga" ; Kula => "kugula" ; Kala => "kaala" ; + Passive => "lagu" ; Lagu => "lagugu" ; Laga => "lagaa" ; Single p => (prepTable ! p).s ! Sg2_Prep } ; Pl1_Prep Excl => table { Ugu => "noogu" ; Uga => "nooga" ; Ula => "noola" ; Kaga => "nagaga" ; Kula => "nagula" ; Kala => "nagala" ; + Passive => "nala" ; Lagu => "nalagu" ; Laga => "nalaga" ; Single p => (prepTable ! p).s ! Pl1_Prep Excl } ; Pl1_Prep Incl => table { Ugu => "inoogu" ; Uga => "inooga" ; Ula => "inoola" ; Kaga => "inagaga" ; Kula => "inagula" ; Kala => "inagala" ; + Passive => "inala" ; Lagu => "inalagu" ; Laga => "inalaga" ; Single p => (prepTable ! p).s ! Pl1_Prep Incl } ; Pl2_Prep => table { Ugu => "idiinku" ; Uga => "idiinka" ; Ula => "idiinla" ; Kaga => "idinkaga" ; Kula => "idinkula" ; Kala => "idinkala" ; + Passive => "laydin" ; Lagu => "laydinku" ; Laga => "laydinka" ; Single p => (prepTable ! p).s ! Pl2_Prep } ; Impers_Prep => table { Ugu => "loogu" ; Uga => "looga" ; Ula => "loola" ; Kaga => "lagaga" ; Kula => "lagula" ; Kala => "lagala" ; - Lagu => "lagu" ; Laga => "laga" ; -- TODO check + Passive => "la" ; + Lagu => "lagu" ; Laga => "laga" ; -- TODO check these two Single p => (prepTable ! p).s ! Impers_Prep } ; + Reflexive_Prep => -- TODO check every form + table { Ugu => "isugu" ; Uga => "isuga" ; + Ula => "isula" ; Kaga => "iskaga" ; + Kula => "iskula" ; Kala => "iskala" ; + Passive => "lays" ; + Lagu => "laysku" ; Laga => "layska" ; + Single p => (prepTable ! p).s ! Reflexive_Prep } ; a => table { Ugu => "ugu" ; Uga => "uga" ; Ula => "ula" ; Kaga => "kaga" ; Kula => "kula" ; Kala => "kala" ; + Passive => "la" ; Lagu => "lagu" ; Laga => "laga" ; Single p => (prepTable ! p).s ! a } } ; @@ -652,12 +666,12 @@ oper VerbPhrase : Type = BaseVerb ** Complement ** BaseAdv ** { -- Prepositions can combine together and with object pronoun. - c2 : PrepositionPlus ; -- hack to implement passives more efficiently: - c3 : Preposition ; -- if c2 is Passive, the real preposition is in c3. + isPassive : Bool ; + c2,c3 : Preposition ; -- if c2 is Passive, the real preposition is in c3. obj2 : NPLite ; -- {s : Str ; a : PrepAgr} secObj : Str ; -- if two overt pronoun objects vComp : Str ; -- VV complement - refl : Str ; -- reflexive is put here, if the verb has an obj2. +-- refl : Str ; -- reflexive is put here, if the verb has an obj2. miscAdv : Str ; -- dump for any other kind of adverb, that isn't } ; -- in a closed class of particles or made with PrepNP. @@ -667,37 +681,37 @@ oper comp = \\_ => <[],[]> ; pred = NoPred ; vComp,berri,miscAdv,refl = [] ; - c2 = P NoPrep ; - c3 = NoPrep ; + c2, c3 = NoPrep ; + isPassive = False ; obj2 = {s = [] ; a = P3_Prep} ; secObj = [] } ; useVc : Verb2 -> VPSlash = \v2 -> useV v2 ** { - c2 = P v2.c2 + c2 = v2.c2 } ; passV2 : Verb2 -> VerbPhrase = \v2 -> passVP (useV v2) ; passVP : VerbPhrase -> VerbPhrase = \vp -> vp ** { - c2 = Passive ; - c3 = pp2prep vp.c2 ; + isPassive = True ; } ; complSlash : VPSlash -> VerbPhrase = \vps -> let np = vps.obj2 in vps ** { comp = \\agr => let cmp = vps.comp ! agr in {p1 = np.s ++ cmp.p1 ; -- if object is a noun, it will come before verb in the sentence. -- if object is a pronoun, np.s is empty. - p2 = cmp.p2 ++ vps.refl ++ compl np.a vps} -- object combines with the preposition of the verb. + p2 = cmp.p2 ++ compl np.a vps} -- object combines with the preposition of the verb. } ; compl : PrepAgr -> VerbPhrase -> Str = \agr,vp -> - prepCombTable ! agr ! combine vp.c2 vp.c3 ; + prepCombTable ! agr ! combine vp.isPassive vp.c2 vp.c3 ; - insertRefl : VPSlash -> VPSlash = \vps -> - case of { -

=> vps ** {refl = "is"} ; -- NB. if AdvVP is called after ReflVP, vps.c2 may change. - _ => vps ** {refl = "is" ++ BIND} + insertRefl : VPSlash -> VPSlash = \vps -> vps ** { + obj2 = vps.obj2 ** {a = Reflexive_Prep} ; + + -- If old obj2 was something else than P3, it is now shown in secObj + secObj = vps.secObj ++ secondObject ! vps.obj2.a ; } ; insertComp : VPSlash -> NounPhrase -> VerbPhrase = \vp,np -> @@ -727,8 +741,8 @@ oper NoPrep => vp ** adv'' ; -- the adverb is not formed with PrepNP, e.g. "tomorrow" _ => case of { -- if free complement slots, introduce adv.np with insertComp -

=> insertCompAgrPlus (vp ** {c2 = P adv.c2}) adv.np ** adv' ; - <_ ,NoPrep> => insertCompAgrPlus (vp ** {c3 = adv.c2}) adv.np ** adv' ; + => insertCompAgrPlus (vp ** {c2 = adv.c2}) adv.np ** adv' ; + <_,NoPrep> => insertCompAgrPlus (vp ** {c3 = adv.c2}) adv.np ** adv' ; -- if complement slots are full, just insert strings. _ => vp ** adv'' @@ -739,7 +753,7 @@ oper dhex = vp.dhex ++ adv.dhex ; berri = vp.berri ++ adv.berri } ; adv'' : {sii,dhex,berri,miscAdv : Str} -- adv.np inserted into miscAdv - = adv' ** {dhex = (prepTable ! P adv.c2).s ! adv.np.a ++ adv.dhex ; + = adv' ** {dhex = (prepTable ! adv.c2).s ! adv.np.a ++ adv.dhex ; miscAdv = adv.np.s} } ; -------------------------------------------------------------------------------- @@ -763,8 +777,8 @@ oper obj : {p1,p2 : Str} = let o : {p1,p2 : Str} = vp.comp ! subj.a ; bind : Str = case of { - => [] ; - _ => BIND } ; + => [] ; + _ => BIND } ; in case p of { Pos => o ; Neg => {p2 = [] ; p1 = o.p1 ++ o.p2 ++ bind} -- object pronoun, prepositions and negation all contract @@ -780,10 +794,10 @@ oper } ; in wordOrder subjnoun subjpron stm obj pred vp ; } where { - vp = case vps.c2 of { - Passive => complSlash (insertComp vps np) ; - _ => complSlash vps } ; - subj = case vps.c2 of {Passive => impersNP ; _ => np} ; + vp = case vps.isPassive of { + True => complSlash (insertComp vps np) ; + _ => complSlash vps } ; + subj = case vps.isPassive of {True => impersNP ; _ => np} ; } ; wordOrder : (sn,sp,stm : Str) -> {p1,p2 : Str} -> {fin,inf : Str} -> VerbPhrase -> Str = @@ -851,7 +865,7 @@ oper linAdv : Adverb -> Str = \adv -> adv.berri ++ adv.sii - ++ (prepTable ! P adv.c2).s ! adv.np.a + ++ (prepTable ! adv.c2).s ! adv.np.a ++ adv.dhex ++ adv.np.s ; diff --git a/src/somali/unittest/vp.gftest b/src/somali/unittest/vp.gftest index 7d6c10fb1..eac88d2bf 100644 --- a/src/somali/unittest/vp.gftest +++ b/src/somali/unittest/vp.gftest @@ -17,11 +17,11 @@ LangSom: ku &+ ma arkin Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPast ASimul) PNeg (PredVP (UsePron they_Pron) (ComplSlash (SlashV2a see_V2) (UsePron youSg_Pron))))) NoVoc -- LangEng: you taught yourself -LangSom: waa aad is &+ ku bartay +LangSom: waa aad isku bartay Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPast ASimul) PPos (PredVP (UsePron youSg_Pron) (ReflVP (SlashV2a teach_V2))))) NoVoc -- LangEng: you don't teach yourself -LangSom: is &+ ku &+ ma barto +LangSom: isku &+ ma barto Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PNeg (PredVP (UsePron youSg_Pron) (ReflVP (SlashV2a teach_V2))))) NoVoc -- LangEng: one saw you From e5aa8a64998293064b138d16b744eccde3ef3034 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Thu, 25 Jul 2019 18:41:16 +0300 Subject: [PATCH 2/3] (Som) Remove Impers_Prep and put it in PrepCombination --- src/somali/ParadigmsSom.gf | 6 +-- src/somali/ParamSom.gf | 5 +-- src/somali/ResSom.gf | 85 +++++++++++++++++--------------------- 3 files changed, 43 insertions(+), 53 deletions(-) diff --git a/src/somali/ParadigmsSom.gf b/src/somali/ParadigmsSom.gf index 1fb3be59e..81e9fe00c 100644 --- a/src/somali/ParadigmsSom.gf +++ b/src/somali/ParadigmsSom.gf @@ -103,10 +103,10 @@ oper mkPrep = overload { mkPrep : Str -> CatSom.Prep = \s -> - lin Prep ((ResSom.mkPrep s s s s s s s) ** { + lin Prep ((ResSom.mkPrep s s s s s s) ** { c2=noPrep ; sii,dhex,berri=[]}) ; - mkPrep : (x1,_,_,_,_,_,x7 : Str) -> CatSom.Prep = \a,b,c,d,e,f,g -> - lin Prep ((ResSom.mkPrep a b c d e f g) ** { + mkPrep : (x1,_,_,_,_,x6 : Str) -> CatSom.Prep = \a,b,c,d,e,f -> + lin Prep ((ResSom.mkPrep a b c d e f) ** { c2=noPrep ; sii,dhex,berri=[]}) ; mkPrep : Preposition -> CatSom.Prep = \p -> lin Prep ((prep p) ** {sii,dhex,berri=[]}) ; diff --git a/src/somali/ParamSom.gf b/src/somali/ParamSom.gf index dda95ebe3..fbf98ac5d 100644 --- a/src/somali/ParamSom.gf +++ b/src/somali/ParamSom.gf @@ -141,7 +141,6 @@ param | Sg2_Prep | Pl1_Prep Inclusion | Pl2_Prep - | Impers_Prep | Reflexive_Prep | P3_Prep ; @@ -160,7 +159,6 @@ oper agr2pagr : Agreement -> PrepAgr = \a -> case a of { Sg1 => Sg1_Prep ; Sg2 => Sg2_Prep ; - Impers => Impers_Prep ; Pl1 i => Pl1_Prep i ; Pl2 => Pl2_Prep ; _ => P3_Prep @@ -196,7 +194,7 @@ param Preposition = U | Ku | Ka | La | NoPrep ; PrepCombination = Ugu | Uga | Ula | Kaga | Kula | Kala - | Passive | Lagu | Laga -- TODO all combinations with impersonal la + | Passive | Lagu | Laga | Loo | Lala -- TODO all combinations with impersonal la | Single Preposition ; oper @@ -206,6 +204,7 @@ oper => Passive ; => Lagu ; => Laga ; + => Loo ; => Single p ; -- TODO all combinations => case of { => Ugu ; diff --git a/src/somali/ResSom.gf b/src/somali/ResSom.gf index 9640e08b1..1eddc59af 100644 --- a/src/somali/ResSom.gf +++ b/src/somali/ResSom.gf @@ -324,7 +324,7 @@ oper Prep : Type = {s : PrepAgr => Str} ; - mkPrep : (x1,_,_,_,_,_,x7 : Str) -> Prep = \ku,ii,kuu,noo,idiin,isku,loo -> { + mkPrep : (x1,_,_,_,_,x6 : Str) -> Prep = \ku,ii,kuu,noo,idiin,isku -> { s = table { P3_Prep => ku ; Sg1_Prep => ii ; @@ -332,72 +332,63 @@ oper Pl2_Prep => idiin ; Pl1_Prep Excl => noo ; Pl1_Prep Incl => "i" + noo ; - Reflexive_Prep => isku ; - Impers_Prep => loo + Reflexive_Prep => isku } } ; prep : Preposition -> (Prep ** {c2 : Preposition}) = \p -> prepTable ! p ** {c2 = p} ; prepTable : Preposition => Prep = table { - Ku => mkPrep "ku" "igu" "kugu" "nagu" "idinku" "isku" "lagu" ; - Ka => mkPrep "ka" "iga" "kaa" "naga" "idinka" "iska" "laga" ; - La => mkPrep "la" "ila" "kula" "nala" "idinla" "isla" "lala" ; - U => mkPrep "u" "ii" "kuu" "noo" "idiin" "is_u_???:TODO" "loo" ; - NoPrep => mkPrep [] "i" "ku" "na" "idin" "is" "la" + Ku => mkPrep "ku" "igu" "kugu" "nagu" "idinku" "isku" ; + Ka => mkPrep "ka" "iga" "kaa" "naga" "idinka" "iska" ; + La => mkPrep "la" "ila" "kula" "nala" "idinla" "isla" ; + U => mkPrep "u" "ii" "kuu" "noo" "idiin" "isu" ; + _ => mkPrep [] "i" "ku" "na" "idin" "is" } ; prepCombTable : PrepAgr => PrepCombination => Str = table { Sg1_Prep => table { - Ugu => "iigu" ; Uga => "iiga" ; - Ula => "iila" ; Kaga => "igaga" ; - Kula => "igula" ; Kala => "igala" ; - Passive => "la i" ; + Ugu => "iigu" ; Uga => "iiga" ; Ula => "iila" ; + Kaga => "igaga" ; Kula => "igula" ; Kala => "igala" ; + Passive => "la i" ; Loo => "la ii" ; Lala => "la ila" ; Lagu => "laygu" ; Laga => "layga" ; Single p => (prepTable ! p).s ! Sg1_Prep } ; - Sg2_Prep => table { Ugu => "kuugu" ; Uga => "kaaga" ; - Ula => "kuula" ; Kaga => "kaaga" ; - Kula => "kugula" ; Kala => "kaala" ; - Passive => "lagu" ; + Sg2_Prep => table { Ugu => "kuugu" ; Uga => "kaaga" ; Ula => "kuula" ; + Kaga => "kaaga" ; Kula => "kugula" ; Kala => "kaala" ; + Passive => "lagu" ; Loo => "laguu" ; Lala => "lagula" ; Lagu => "lagugu" ; Laga => "lagaa" ; Single p => (prepTable ! p).s ! Sg2_Prep } ; Pl1_Prep Excl => - table { Ugu => "noogu" ; Uga => "nooga" ; - Ula => "noola" ; Kaga => "nagaga" ; - Kula => "nagula" ; Kala => "nagala" ; - Passive => "nala" ; + table { Ugu => "noogu" ; Uga => "nooga" ; Ula => "noola" ; + Kaga => "nagaga" ; Kula => "nagula" ; Kala => "nagala" ; + Passive => "nala" ; Loo => "???" ; Lala => "???" ; Lagu => "nalagu" ; Laga => "nalaga" ; Single p => (prepTable ! p).s ! Pl1_Prep Excl } ; Pl1_Prep Incl => - table { Ugu => "inoogu" ; Uga => "inooga" ; - Ula => "inoola" ; Kaga => "inagaga" ; - Kula => "inagula" ; Kala => "inagala" ; - Passive => "inala" ; + table { Ugu => "inoogu" ; Uga => "inooga" ; Ula => "inoola" ; + Kaga => "inagaga" ; Kula => "inagula" ; Kala => "inagala" ; + Passive => "inala" ; Loo => "???" ; Lala => "???" ; Lagu => "inalagu" ; Laga => "inalaga" ; Single p => (prepTable ! p).s ! Pl1_Prep Incl } ; - Pl2_Prep => table { Ugu => "idiinku" ; Uga => "idiinka" ; - Ula => "idiinla" ; Kaga => "idinkaga" ; - Kula => "idinkula" ; Kala => "idinkala" ; - Passive => "laydin" ; + Pl2_Prep => table { Ugu => "idiinku" ; Uga => "idiinka" ; Ula => "idiinla" ; + Kaga => "idinkaga" ; Kula => "idinkula" ; Kala => "idinkala" ; + Passive => "laydin" ; Loo => "laydiin" ; Lala => "laydinla" ; Lagu => "laydinku" ; Laga => "laydinka" ; Single p => (prepTable ! p).s ! Pl2_Prep } ; - Impers_Prep => - table { Ugu => "loogu" ; Uga => "looga" ; - Ula => "loola" ; Kaga => "lagaga" ; - Kula => "lagula" ; Kala => "lagala" ; - Passive => "la" ; - Lagu => "lagu" ; Laga => "laga" ; -- TODO check these two - Single p => (prepTable ! p).s ! Impers_Prep } ; + -- Impers_Prep => -- TODO: put these later into other tables + -- table { Ugu => "loogu" ; Uga => "looga" ; + -- Ula => "loola" ; Kaga => "lagaga" ; + -- Kula => "lagula" ; Kala => "lagala" ; + -- Passive => "la" ; + -- Lagu => "lagu" ; Laga => "laga" ; } ; Reflexive_Prep => -- TODO check every form - table { Ugu => "isugu" ; Uga => "isuga" ; - Ula => "isula" ; Kaga => "iskaga" ; - Kula => "iskula" ; Kala => "iskala" ; - Passive => "lays" ; + table { Ugu => "isugu" ; Uga => "isuga" ; Ula => "isula" ; + Kaga => "iskaga" ; Kula => "iskula" ; Kala => "iskala" ; + Passive => "lays" ; Loo => "???" ; Lala => "???" ; Lagu => "laysku" ; Laga => "layska" ; Single p => (prepTable ! p).s ! Reflexive_Prep } ; - a => table { Ugu => "ugu" ; Uga => "uga" ; - Ula => "ula" ; Kaga => "kaga" ; - Kula => "kula" ; Kala => "kala" ; - Passive => "la" ; + a => table { Ugu => "ugu" ; Uga => "uga" ; Ula => "ula" ; + Kaga => "kaga" ; Kula => "kula" ; Kala => "kala" ; + Passive => "la" ; Loo => "loo" ; Lala => "lala" ; Lagu => "lagu" ; Laga => "laga" ; Single p => (prepTable ! p).s ! a } } ; @@ -776,10 +767,10 @@ oper subjpron : Str = if_then_Str np.isPron (subj.s ! Nom) np.empty ; obj : {p1,p2 : Str} = let o : {p1,p2 : Str} = vp.comp ! subj.a ; - bind : Str = case of { - => [] ; - _ => BIND } ; - in case p of { + bind : Str = case of { + => [] ; + _ => BIND } ; + in case p of { Pos => o ; Neg => {p2 = [] ; p1 = o.p1 ++ o.p2 ++ bind} -- object pronoun, prepositions and negation all contract } ; From e4bc20e482a4488f5ddb30f38aef41f63ba69f79 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Thu, 25 Jul 2019 18:42:16 +0300 Subject: [PATCH 3/3] (Som) WIP: subordinate clauses --- src/somali/AdverbSom.gf | 9 ++--- src/somali/CatSom.gf | 12 +++---- src/somali/ExtendSom.gf | 16 ++++++--- src/somali/NounSom.gf | 12 ++++--- src/somali/ParamSom.gf | 8 +++++ src/somali/PhraseSom.gf | 2 +- src/somali/QuestionSom.gf | 2 +- src/somali/RelativeSom.gf | 32 ++++++++--------- src/somali/ResSom.gf | 68 ++++++++++++++++++++++--------------- src/somali/SentenceSom.gf | 45 +++++++++++------------- src/somali/StructuralSom.gf | 14 ++++---- 11 files changed, 120 insertions(+), 100 deletions(-) diff --git a/src/somali/AdverbSom.gf b/src/somali/AdverbSom.gf index cf4225258..f57e900d1 100644 --- a/src/somali/AdverbSom.gf +++ b/src/somali/AdverbSom.gf @@ -1,4 +1,4 @@ -concrete AdverbSom of Adverb = CatSom ** open ResSom, ParamSom, Prelude in { +concrete AdverbSom of Adverb = CatSom ** open ResSom, ParamSom, ParadigmsSom, Prelude in { lin @@ -24,15 +24,10 @@ lin -- Subordinate clauses can function as adverbs. -- : Subj -> S -> Adv ; --- SubjS subj s = {} ; + SubjS subj s = mkAdv (subj.s ++ s.s ! True) ; -- Comparison adverbs also work as numeral adverbs. --AdnCAdv : CAdv -> AdN ; -- less (than five) --AdnCAdv cadv = {s = } ; } ; - -{- -gt PrepNP in_Prep (DetCN (DetQuant DefArt ?) (UseN ?) | l -bind -gt PrepNP from_Prep (DetCN (DetQuant DefArt ?) (UseN ?)) | l -bind --} diff --git a/src/somali/CatSom.gf b/src/somali/CatSom.gf index 5ec479ba8..1b6f06df8 100644 --- a/src/somali/CatSom.gf +++ b/src/somali/CatSom.gf @@ -8,8 +8,8 @@ concrete CatSom of Cat = CommonX - [Adv] ** open ResSom, Prelude in { -- Constructed in SentenceSom, and also in IdiomSom S = ResSom.Sentence ; - QS = ResSom.Sentence ; - RS = { s : Agreement => Str } ; + QS = SS ; + RS = {s : {-Agreement =>-} Str} ; -- TODO -- relative sentence. Tense and polarity fixed, -- but agreement may depend on the CN/NP it modifies. @@ -28,11 +28,9 @@ concrete CatSom of Cat = CommonX - [Adv] ** open ResSom, Prelude in { IDet = ResSom.Determiner ; -- interrogative determiner e.g. "how many" IQuant = ResSom.Quant ; -- interrogative quantifier e.g. "which" ---2 Relative clauses and pronouns +--2 Subord clauses and pronouns --- Constructed in RelativeSom. - - RCl = ResSom.RClause ; + RCl = ResSom.QClause ; RP = SS ; --2 Verb phrases @@ -85,7 +83,7 @@ concrete CatSom of Cat = CommonX - [Adv] ** open ResSom, Prelude in { -- Constructed in StructuralSom. Conj = { s1,s2 : Str ; n : Number } ; - Subj = { s : Str ; isPre : Bool } ; --ba+dut vs. dut+en + Subj = SS ; Prep = ResSom.Prep ** {c2 : Preposition ; berri, sii, dhex : Str} ; diff --git a/src/somali/ExtendSom.gf b/src/somali/ExtendSom.gf index a73a83a6e..e696a76d9 100644 --- a/src/somali/ExtendSom.gf +++ b/src/somali/ExtendSom.gf @@ -1,7 +1,15 @@ --# -path=.:../common:../abstract -concrete ExtendSom of Extend = {} ; - -- CatSom ** ExtendFunctor +concrete ExtendSom of Extend = CatSom + -- ** ExtendFunctor -- Add this back when all relevant functions are implemented -- with (Grammar=GrammarSom) - -- ** open Prelude, ResSom in { - -- } ; + ** open Prelude, ResSom in { + +lin + -- : NP -> SSlash -> Utt ; -- her I love -- Sayeed p. 189- + FocusObj np sslash = + + -- FocusAdv : Adv -> S -> Utt ; -- today I will sleep + -- FocusAdV : AdV -> S -> Utt ; -- never will I sleep + -- FocusAP : AP -> NP -> Utt ; -- green was the tree +} ; diff --git a/src/somali/NounSom.gf b/src/somali/NounSom.gf index 41b08eaf3..6b634ffa3 100644 --- a/src/somali/NounSom.gf +++ b/src/somali/NounSom.gf @@ -69,7 +69,9 @@ concrete NounSom of Noun = CatSom ** open ResSom, Prelude in { --AdvNP,ExtAdvNP = \np,adv -> np ** {} ; --adverbs are complicated -- : NP -> RS -> NP ; -- Paris, which is here - -- RelNP np rs = np ** { s = \\c => rs.s ! np.agr ++ np.s ! c } ; + RelNP np rs = np ** { + s = \\c => np.s ! c ++ rs.s + } ; -- Determiners can form noun phrases directly. @@ -225,11 +227,13 @@ concrete NounSom of Noun = CatSom ** open ResSom, Prelude in { hasMod = True } ; -{- + -- : CN -> RS -> CN ; - RelCN cn rs = cn ** { } ; - + RelCN cn rs = cn ** { + mod = \\n,c => cn.mod ! n ! c ++ rs.s + } ; +{- -- : CN -> Adv -> CN ; AdvCN cn adv = cn ** { } ; diff --git a/src/somali/ParamSom.gf b/src/somali/ParamSom.gf index fbf98ac5d..f1d380934 100644 --- a/src/somali/ParamSom.gf +++ b/src/somali/ParamSom.gf @@ -280,4 +280,12 @@ oper Sg2|Sg3 Fem => Sg2_Sg3Fem ; Pl1 _ => Pl1_ ; Pl2 => Pl2_ ; Pl3 => Pl3_ } ; + +-------------------------------------------------------------------------------- +-- Clauses + +param + + ClType = Statement | Question | Subord ; + } diff --git a/src/somali/PhraseSom.gf b/src/somali/PhraseSom.gf index 02ceafa37..8644c3bad 100644 --- a/src/somali/PhraseSom.gf +++ b/src/somali/PhraseSom.gf @@ -3,7 +3,7 @@ concrete PhraseSom of Phrase = CatSom ** open Prelude, ResSom in { lin PhrUtt pconj utt voc = {s = pconj.s ++ utt.s ++ voc.s} ; - UttS s = s ; + UttS s = {s = s.s ! False} ; UttQS qs = qs ; UttImpSg pol imp = diff --git a/src/somali/QuestionSom.gf b/src/somali/QuestionSom.gf index ccf9be937..768da0d09 100644 --- a/src/somali/QuestionSom.gf +++ b/src/somali/QuestionSom.gf @@ -6,7 +6,7 @@ concrete QuestionSom of Question = CatSom ** open lin -- : Cl -> QCl ; - QuestCl cl = {s = cl.s ! True} ; + QuestCl cl = {s = cl.s ! Question} ; -- : IP -> VP -> QCl ; -- QuestVP ip vp = ; diff --git a/src/somali/RelativeSom.gf b/src/somali/RelativeSom.gf index a820850d4..41d7db84b 100644 --- a/src/somali/RelativeSom.gf +++ b/src/somali/RelativeSom.gf @@ -1,36 +1,36 @@ concrete RelativeSom of Relative = CatSom ** open ResSom, Prelude, (NS=NounSom), (SS=StructuralSom) in { -{- + lin -- : Cl -> RCl ; -- such that John loves her - RelCl cl = { } ; + -- RelCl cl = {s = cl.s ! Subord} ; +{- -- Sayeed p. 95-96 + ch 8 Reduced present general in relative clauses; as absolutive 1/2SG/3SG M/2PL/3PL sugá -- same as imperative (TODO check if for all conjugations) -3 SG F sugtá -- doesn't exist -1PL sugná -- doesn't exist +3 SG F sugtá -- not yet in the grammar +1PL sugná -- not yet in the grammar +(18) (a) nimánka buugágga keená men-the books-the bring +'the men who bring the books' +(b) buugágga nimanku keenàan +books-the men-the bring 'the books which the men bring' +-} -- : RP -> VP -> RCl ; - RelVP rp vp = ; + RelVP rp vp = RelSlash rp (predVPSlash emptyNP vp) ; -- : RP -> ClSlash -> RCl ; -- whom John loves - RelSlash rp cls = ; + RelSlash rp cls = { + s = \\t,a,p => rp.s ++ cls.s ! True ! t ! a ! p + } ; -- : RP ; - IdRP = { s = "" } ; + IdRP = {s = "waxa"} ; -- : Prep -> NP -> RP -> RP ; -- the mother of whom - FunRP prep np rp = { s = applyPost prep whom ++ np.s ! Abs } - where { num = case np.agr of { - Sg3 _ => NS.NumSg ; - _ => NS.NumPl } ; - whom = NS.DetNP (NS.DetQuant SS.which_IQuant num) } ; - - - --} + --FunRP prep np rp = {} ; } diff --git a/src/somali/ResSom.gf b/src/somali/ResSom.gf index 1eddc59af..442a574c3 100644 --- a/src/somali/ResSom.gf +++ b/src/somali/ResSom.gf @@ -749,19 +749,24 @@ oper } ; -------------------------------------------------------------------------------- -- Sentences etc. - Clause : Type = {s : Bool {-is question-} => Tense => Anteriority => Polarity => Str} ; + Clause : Type = {s : ClType => Tense => Anteriority => Polarity => Str} ; QClause : Type = {s : Tense => Anteriority => Polarity => Str} ; - RClause, - ClSlash, - Sentence : Type = SS ; ---- TODO + ClSlash : Type = {s : Bool {-is subordinate-} => Tense => Anteriority => Polarity => Str} ; + Sentence : Type = {s : Bool {-is subordinate-} => Str} ; + + predVPSlash : NounPhrase -> VPSlash -> ClSlash = \np,vps -> + let cl = predVP np vps in {s = table { + True => cl.s ! Subord ; + False => cl.s ! Statement } + } ; predVP : NounPhrase -> VerbPhrase -> Clause = \np,vps -> { - s = \\isQ,t,a,p => - let predRaw : {fin : Str ; inf : Str} = vf t a p subj.a vp ; - pred : {fin : Str ; inf : Str} = case of { - => {fin,inf = []} ; - <_ , _,Copula> => {fin = presCopula ! {agr=subj.a ; pol=p} ; inf=[]} ; - _ => predRaw + s = \\cltyp,t,a,p => + let predRaw : {fin : Str ; inf : Str} = vf cltyp t a p subj.a vp ; + pred : {fin : Str ; inf : Str} = case of { + => {fin,inf = []} ; + <_ , _, Copula> => {fin = presCopula ! {agr=subj.a ; pol=p} ; inf=[]} ; + _ => predRaw } ; subjnoun : Str = if_then_Str np.isPron np.empty (subj.s ! Nom) ; subjpron : Str = if_then_Str np.isPron (subj.s ! Nom) np.empty ; @@ -774,21 +779,18 @@ oper Pos => o ; Neg => {p2 = [] ; p1 = o.p1 ++ o.p2 ++ bind} -- object pronoun, prepositions and negation all contract } ; - stm : Str = case of { - => "waa" ; - => "ma" ; - _ => case of { - => "waa" ++ subjpron ; -- to force some string from NP to show in the tree - => "ma" ; -- ++ subjpron ; -- TODO check subj pron or not? - => stmarkerNoContr ! subj.a ! p - } - } ; + stm : Str = case cltyp of { + Subord => if_then_Pol p [] "aan" ++ subjpron ; -- if we form a ClSlash, no sentence type marker; negation with aan (Sayeed p. 210) + Question => "ma" ; -- TODO find out how negative questions work + Statement => case of { + => "waa" ; + _ => stmarkerNoContr ! subj.a ! p }} ; in wordOrder subjnoun subjpron stm obj pred vp ; } where { vp = case vps.isPassive of { True => complSlash (insertComp vps np) ; _ => complSlash vps } ; - subj = case vps.isPassive of {True => impersNP ; _ => np} ; + subj = case vps.isPassive of {True => impersNP ; _ => np} } ; wordOrder : (sn,sp,stm : Str) -> {p1,p2 : Str} -> {fin,inf : Str} -> VerbPhrase -> Str = @@ -806,8 +808,13 @@ oper ++ vp.miscAdv ; ---- NB. Only used if there are several adverbs. ---- Primary places for adverbs are obj, sii or dhex. - vf : Tense -> Anteriority -> Polarity -> Agreement -> Verb - -> {fin : Str ; inf : Str} = \t,ant,p,agr,vp -> + VFun : Type = Tense -> Anteriority -> Polarity -> Agreement -> Verb + -> {fin : Str ; inf : Str} ; + + vf : ClType -> VFun = \clt -> case clt of { + Subord => vfSubord ; _ => vfStatement } ; + + vfStatement : VFun = \t,ant,p,agr,vp -> case of { => {fin = presV vp ; inf = [] } ; => {fin = pastV vp ; inf = [] } ; @@ -827,17 +834,24 @@ oper presV : Verb -> Str = \v -> v.s ! VPres Simple (agr2vagr agr) p ; } ; + vfSubord : VFun = \t,ant,p,agr,vp -> + case of { + => vfStatement Pres ant Neg agr vp ; + _ => vfStatement t ant p agr vp + } ; -- TODO other relative forms + infVP : VerbPhrase -> Str = \vp -> - let inf = (vf Past Anter Pos (Sg3 Masc) vp) ** {fin=[]} + let inf = {inf = vp.s ! VInf ; fin=[]} in wordOrder [] [] [] (vp.comp ! Pl3) inf vp ; - stmarker : Agreement => Polarity => Str = \\a,b => + stmarkerContr : Agreement => Polarity => Str = \\a,b => let stm = if_then_Pol b "w" "m" in stm + subjpron ! a ; - stmarkerNoContr : Agreement => Polarity => Str = \\a,b => - let stm = if_then_Pol b "waa" "ma" - in stm ++ subjpron ! a ; + stmarkerNoContr : Agreement => Polarity => Str = \\a,p => + case p of { + Pos => "waa" ++ subjpron ! a ; + Neg => "ma" } ; subjpron : Agreement => Str = table { Sg1|Pl1 Excl => "aan" ; diff --git a/src/somali/SentenceSom.gf b/src/somali/SentenceSom.gf index 4dd5b7c9c..ebced1044 100644 --- a/src/somali/SentenceSom.gf +++ b/src/somali/SentenceSom.gf @@ -10,14 +10,13 @@ lin -- : NP -> VP -> Cl PredVP = predVP ; -{- - -- : SC -> VP -> Cl ; -- that she goes is good - PredSCVP sc vp = ; + -- : SC -> VP -> Cl ; -- that she goes is good (Sayeed p. 94) + --PredSCVP sc vp = ; --2 Clauses missing object noun phrases -- : NP -> VPSlash -> ClSlash ; - SlashVP np vps = ; - + SlashVP = predVPSlash ; +{- -- : ClSlash -> Adv -> ClSlash ; -- (whom) he sees today AdvSlash cls adv = cls ** insertAdv adv cls ; @@ -26,17 +25,17 @@ lin -- : NP -> VS -> SSlash -> ClSlash ; -- (whom) she says that he loves -- SlashVS np vs ss = {} ; - +-} -- : Temp -> Pol -> ClSlash -> SSlash ; -- (that) she had not seen - UseSlash t p cls = UseCl t p (PredVP he_Pron cls) ; + UseSlash t p cls = {s = \\b => t.s ++ p.s ++ cls.s ! b ! t.t ! t.a ! p.p} ; --2 Imperatives -- : VP -> Imp ; - ImpVP vp = { s = linVP vp } ; + --ImpVP vp = { s = linVP vp } ; --2 Embedded sentences - +{- -- : S -> SC ; EmbedS s = { } ; @@ -50,35 +49,31 @@ lin -} -- : Temp -> Pol -> Cl -> S ; - UseCl t p cl = {s = t.s ++ p.s ++ cl.s ! False ! t.t ! t.a ! p.p} ; + UseCl t p cl = {s = \\b => + let cltyp = if_then_else ClType b Subord Statement in + t.s ++ p.s ++ cl.s ! cltyp ! t.t ! t.a ! p.p + } ; -- : Temp -> Pol -> QCl -> QS ; UseQCl t p cl = {s = t.s ++ p.s ++ cl.s ! t.t ! t.a ! p.p} ; -{- -- : Temp -> Pol -> RCl -> RS ; - UseRCl t p cl = { s = t.s ++ p.s ++ cl.s ! t.t ! t.a ! p.p } ; + UseRCl t p cl = {s = t.s ++ p.s ++ cl.s ! t.t ! t.a ! p.p} ; --- An adverb can be added to the beginning of a sentence, either with comma ("externally") --- or without: - - -- : Adv -> S -> S ; -- then I will go home - AdvS = advS ; - - -- : Adv -> S -> S ; -- next week, I will go home - ExtAdvS adv = advS {s = adv.s ++ SOFT_BIND ++ ","} ; + -- AdvS : Adv -> S -> S ; -- then I will go home + -- ExtAdvS : Adv -> S -> S ; -- next week, I will go home + AdvS, ExtAdvS = advS ; -- There's an SubjS already in AdverbSom -- should this be deprecated? -- : S -> Subj -> S -> S ; SSubjS s1 subj s2 = AdvS (AS.SubjS subj s2) s1 ; --- A sentence can be modified by a relative clause referring to its contents. - -- : S -> RS -> S ; -- she sleeps, which is good - RelS sent rs = advS { s = rs.s ! Sg3 Masc ++ SOFT_BIND ++ ","} sent ; + -- RelS sent rs = advS {s = rs.s ! Sg3 Masc ++ SOFT_BIND ++ ","} sent ; oper - advS : Adv -> SS -> SS = \a,s -> {s = a.s ++ s.s} ; --} + advS : Adverb -> S -> S = \a,s -> s ** {s = \\b => + linAdv a ++ s.s ! b} ; + } diff --git a/src/somali/StructuralSom.gf b/src/somali/StructuralSom.gf index 2a8526715..278c521fe 100644 --- a/src/somali/StructuralSom.gf +++ b/src/somali/StructuralSom.gf @@ -133,20 +133,18 @@ lin whatSg_IP = ; lin whoPl_IP = ; lin whoSg_IP = ; - - +-} ------- -- Subj -lin although_Subj = mkSubj "" False ; -lin because_Subj = mkSubj "" False ; -lin if_Subj = mkSubj "" True ; -lin that_Subj = mkSubj "" False ; -lin when_Subj = mkSubj "" False ; +-- lin although_Subj = mkSubj "" False ; +-- lin because_Subj = mkSubj "" False ; +-- lin if_Subj = mkSubj "" True ; +lin that_Subj = {s = "in" ++ BIND} ; +-- lin when_Subj = mkSubj "" False ; --} ------ -- Utt