diff --git a/src/somali/AdverbSom.gf b/src/somali/AdverbSom.gf index 0eaaabbd6..5c77c6588 100644 --- a/src/somali/AdverbSom.gf +++ b/src/somali/AdverbSom.gf @@ -11,12 +11,12 @@ lin -- ComparAdvAdjS : CAdv -> A -> S -> Adv ; -- more warmly than he runs -- : Prep -> NP -> Adv ; - PrepNP prep np = {s = prep.s ! np.a ; s2 = np.s ! Abs} ; ---- ? + PrepNP prep np = prep ** {s = [] ; np = np} ; -- Adverbs can be modified by 'adadjectives', just like adjectives. --AdAdv : AdA -> Adv -> Adv ; -- very quickly - AdAdv ada adv = adv ** { s = ada.s ++ adv.s } ; + AdAdv ada adv = adv ** {s = ada.s ++ adv.s} ; -- Like adverbs, adadjectives can be produced by adjectives. -- : A -> AdA ; -- extremely diff --git a/src/somali/CatSom.gf b/src/somali/CatSom.gf index 57eaded8b..ee325a075 100644 --- a/src/somali/CatSom.gf +++ b/src/somali/CatSom.gf @@ -90,7 +90,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 - Prep = ResSom.Prep ; + Prep = ResSom.Prep ** {c2 : Preposition} ; @@ -121,7 +121,7 @@ concrete CatSom of Cat = CommonX - [Adv] ** open ResSom, Prelude in { N3 = ResSom.Noun3 ; PN = ResSom.PNoun ; - Adv = ResSom.Adverb ; + Adv = ResSom.Adverb ; -- Preposition of an adverbial can merge with obligatory complements of the verb. linref -- Cl = linCl ; diff --git a/src/somali/ParadigmsSom.gf b/src/somali/ParadigmsSom.gf index f26412ca7..8fd6f78ce 100644 --- a/src/somali/ParadigmsSom.gf +++ b/src/somali/ParadigmsSom.gf @@ -104,11 +104,11 @@ 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) ** {c2=noPrep}) ; mkPrep : (x1,_,_,_,_,x6 : Str) -> CatSom.Prep = \a,b,c,d,e,f -> - lin Prep (ResSom.mkPrep a b c d e f) ; + lin Prep ((ResSom.mkPrep a b c d e f) ** {c2=noPrep}) ; mkPrep : Preposition -> CatSom.Prep = \p -> - lin Prep (prepTable ! p) ; + lin Prep (prep p) ; } ; -- mkConj : (_,_ : Str) -> Number -> Conj = \s1,s2,num -> @@ -117,7 +117,7 @@ oper -- mkSubj : Str -> Bool -> Subj = \s,b -> -- lin Subj { } ; - mkAdv : Str -> Adv = \s -> lin Adv {s = s ; s2 = []} ; + mkAdv : Str -> Adv = \s -> lin Adv {s = s ; c2 = noPrep ; np = emptyNP} ; mkAdV : Str -> AdV = \s -> lin AdV {s = s} ; diff --git a/src/somali/ParamSom.gf b/src/somali/ParamSom.gf index 851e9a719..f16a2f6ca 100644 --- a/src/somali/ParamSom.gf +++ b/src/somali/ParamSom.gf @@ -75,6 +75,11 @@ param | Pl3 | Impers ; -- Verb agrees with Sg3, but needed for preposition contraction + AgreementPlus = + Unassigned -- Dummy value: shows that the slot for object hasn't been filled. + | IsPron Agreement -- Any of Sg1 … Pl3 can be a pronoun. + | NotPronP3 ; -- Sg3 Gender and Pl3 can be pronouns or not. + State = Definite | Indefinite ; NForm = @@ -91,6 +96,9 @@ oper getNum : Agreement -> Number = \a -> case a of { Sg1|Sg2|Sg3 _ => Sg ; _ => Pl } ; + agr2agrplus : (isPron : Bool) -> Agreement -> AgreementPlus = \isPron,a -> + case isPron of {True => IsPron a ; False => NotPronP3} ; + -------------------------------------------------------------------------------- -- Adjectives diff --git a/src/somali/ResSom.gf b/src/somali/ResSom.gf index d63c18545..441c2f432 100644 --- a/src/somali/ResSom.gf +++ b/src/somali/ResSom.gf @@ -133,6 +133,12 @@ oper { mod = \\_,_ => [] ; hasMod = False ; a = Sg3 n.g ; isPron = False ; sp = [] } ; + + emptyNP : NounPhrase = { + s = \\_ => [] ; + a = Pl3 ; + isPron = False + } ; -------------------------------------------------------------------------------- -- Pronouns -- De somaliska possessiva pronomenen, precis som de svenska, har två olika genusformer i singular och en enda form i plural. @@ -232,6 +238,7 @@ oper _ => ku } } ; + prep : Preposition -> (Prep ** {c2 : Preposition}) = \p -> prepTable ! p ** {c2 = p} ; prepTable : Preposition => Prep = table { ku => mkPrep "ku" "igu" "kugu" "nagu" "idinku" "lagu" ; @@ -270,7 +277,6 @@ oper ula => "loola" ; kaga => "lagaga" ; kula => "lagula" ; kala => "lagala" ; Single p => (prepTable ! p).s ! Impers } ; --- a => table { ugu => "ugu" ; uga => "uga" ; ula => "ula" ; kaga => "kaga" ; kula => "kula" ; kala => "kala" ; @@ -517,7 +523,9 @@ oper ------------------ -- VP - Adverb : Type = {s,s2 : Str} ; + Adverb : Type = { + s : Str ; + c2 : Preposition ; np : NounPhrase} ; -- So that adverbs can also contribute to preposition contraction Complement : Type = { comp : Agreement => {p1,p2 : Str} -- Agreement for AP complements @@ -525,24 +533,71 @@ oper VerbPhrase : Type = Verb ** Complement ** { isPred : Bool ; -- to choose right sentence type marker - adv : Adverb ; -- they're ~complicated~ - c2, c3 : Preposition -- can combine together and with object pronouns + adv : Str ; + c2, c3 : Preposition ; -- can combine together and with object pronoun(s?) + obj2 : {s : Str ; a : AgreementPlus} ; } ; - VPSlash : Type = VerbPhrase ; ---- TODO more fields + VPSlash : Type = VerbPhrase ; useV : Verb -> VerbPhrase = \v -> v ** { comp = \\_ => <[],[]> ; isPred = False ; - adv = {s,s2 = []} ; + adv = [] ; c2,c3 = noPrep ; + obj2 = {s = [] ; a = Unassigned} ; } ; - compl : NounPhrase -> VerbPhrase -> Str = \np,vp -> - prepCombTable ! np.a ! combine vp.c2 vp.c3 ; + useVc : Verb2 -> VPSlash = \v2 -> useV v2 ** { + c2 = v2.c2 + } ; - complV2 : NounPhrase -> Verb2 -> Str = \np,vp -> - prepCombTable ! np.a ! combine vp.c2 noPrep ; + complSlash : VPSlash -> VerbPhrase = \vps -> let np = vps.obj2 in vps ** { + comp = \\a => + case np.a of { + Unassigned => vps.comp ! a ; + IsPron ag => {p1 = [] ; -- object is a pronoun => nothing is placed before the verb + p2 = compl np.a vps} ; -- object combines with the preposition of the verb + NotPronP3 => {p1 = np.s ; -- object is a noun => it will come before verb in the sentence + p2 = compl np.a vps} -- object combines with the preposition of the verb + } + } ; + + compl : AgreementPlus -> VerbPhrase -> Str = \a,vp -> + let agr = case a of {IsPron x => x ; _ => Pl3} ; + in "<" ++ prepCombTable ! agr ! combine vp.c2 vp.c3 ++ ">" ; + + insertComp : VPSlash -> NounPhrase -> VerbPhrase = \vp,np -> + let nps = if_then_Str np.isPron [] (np.s ! Abs) ; + in case vp.obj2.a of { + Unassigned => + vp ** {obj2 = {s = nps ; + a = agr2agrplus np.isPron np.a} + } ; + + -- If the old object in obj2 is 3rd person, we can safely replace its agreement, but keep its string. + NotPronP3|IsPron (Sg3 _|Pl3) => + vp ** {obj2 = vp.obj2 ** {a = agr2agrplus np.isPron np.a} ; + adv = vp.adv ++ nps} ; + + -- This happens in two cases: + -- 1) insertAdv placed the preposition into vp.adv and called insertComp. + -- 2) ditransitive verb where both objects are non-3rd person. (Not implemented yet.) + _ => vp ** {adv = vp.adv ++ nps} + } ; + + insertAdv : Adverb -> VerbPhrase -> VerbPhrase = \adv,vp -> + case adv.c2 of { + noPrep => vp ** {adv = adv.s} ; -- The adverb is not formed with PrepNP + prep => insertComp vp' adv.np } + where { vp' : VerbPhrase = + case of { -- NB. This is a safe assumption only for AdvVP, no guarantees for AdvVPSlash. + => vp ** {c2 = adv.c2} ; -- should cover for obligatory argument that is not introduced with a preposition + <_,_,noPrep> => vp ** {c3 = adv.c2} ; + -- if complement slots are full, put preposition just as a string. TODO check word order. + _ => vp ** {adv = (prepTable ! adv.c2).s ! adv.np.a} --only preposition inserted here, adv.np.s ! Abs will be inserted in insertComp! + } + } ; -------------------------------------------------------------------------------- -- Sentences etc. Clause : Type = {s : Tense => Anteriority => Polarity => Str} ; diff --git a/src/somali/SentenceSom.gf b/src/somali/SentenceSom.gf index 5714f9758..532f5044d 100644 --- a/src/somali/SentenceSom.gf +++ b/src/somali/SentenceSom.gf @@ -8,7 +8,7 @@ lin --2 Clauses -- : NP -> VP -> Cl - PredVP np vp = { + PredVP np vps = let vp = complSlash vps in { s = \\t,a,p => let pred : {fin : Str ; inf : Str} = vf t a p np.a vp ; subj : Str = if_then_Str np.isPron [] (np.s ! Nom) ; @@ -24,11 +24,10 @@ lin in subj -- subject if it's a noun ++ obj.p1 -- object if it's a noun ++ stm -- sentence type marker + possible subj. pronoun - ++ vp.adv.s ---- TODO: can it contract with obj. pronoun? + ++ vp.adv ---- TODO word order ++ obj.p2 -- object if it's a pronoun ++ pred.fin -- the verb inflected ++ pred.inf -- potential participle - ++ vp.adv.s2 ---- I have no idea /IL } ; {- -- : SC -> VP -> Cl ; -- that she goes is good diff --git a/src/somali/StructuralSom.gf b/src/somali/StructuralSom.gf index 8a8566526..d65643c2f 100644 --- a/src/somali/StructuralSom.gf +++ b/src/somali/StructuralSom.gf @@ -104,14 +104,14 @@ oper -- lin for_Prep = mkPrep ; -- lin from_Prep = mkPrep "" ; -- lin in8front_Prep = mkPrep "" ; -lin in_Prep = prepTable ! ku ; -lin on_Prep = prepTable ! ku ; +lin in_Prep = prep ku ; +lin on_Prep = prep ku ; -- lin part_Prep = mkPrep ; -- lin possess_Prep = mkPrep ; -- lin through_Prep = mkPrep ; -- lin to_Prep = mkPrep ; -- lin under_Prep = mkPrep "" ; -lin with_Prep = prepTable ! la ; +lin with_Prep = prep la ; -- lin without_Prep = mkPrep ; diff --git a/src/somali/VerbSom.gf b/src/somali/VerbSom.gf index d9da09345..b5c3a5094 100644 --- a/src/somali/VerbSom.gf +++ b/src/somali/VerbSom.gf @@ -5,13 +5,15 @@ lin ----- -- VP - + -- : V -> VP UseV = ResSom.useV ; {- + -- : V2 -> VP ; -- be loved + PassV2 v2 = + -- : VV -> VP -> VP ; ComplVV vv vp = ; - -- : VS -> S -> VP ; ComplVS vs s = ; @@ -21,14 +23,14 @@ lin -- : VA -> AP -> VP ; -- they become red ComplVA va ap = ResSom.insertComp (CompAP ap).s (useV va) ; - +-} -------- -- Slash -- : V2 -> VPSlash - SlashV2a = ResSom.slashDObj ; - + SlashV2a = useVc ; +{- -- : V3 -> NP -> VPSlash ; -- give it (to her) Slash2V3 v3 npNori = slashDObj v3 ** { iobj = { s = npNori.s ! Dat ; @@ -40,7 +42,6 @@ lin { dobj = npNor ** { s = mkDObj npNor } } ; - -- : V2V -> VP -> VPSlash ; -- beg (her) to go SlashV2V v2v vp = ; @@ -55,11 +56,11 @@ lin SlashV2A v2a ap = slashDObj v2a ** { comp = (CompAP ap).s } ; - +-} -- : VPSlash -> NP -> VP - ComplSlash vps np = ResSom.complSlash vps np ; - + ComplSlash = insertComp ; +{- -- : VV -> VPSlash -> VPSlash ; -- Just like ComplVV except missing subject! SlashVV vv vps = ComplVV vv vps ** { missing = vps.missing ; @@ -84,21 +85,21 @@ lin UseComp comp = UseCopula ** comp ** { isPred = True } ; -{- - -- : V2 -> VP ; -- be loved - PassV2 v2 = -- : VP -> Adv -> VP ; -- sleep here - AdvVP vp adv = vp ** {adv = adv} ; ---- TODO: how about combining adverbs? + AdvVP vp adv = insertAdv adv vp ; ---- TODO: how about combining adverbs? + + -- : VPSlash -> Adv -> VPSlash ; -- use (it) here + AdvVPSlash vps adv = insertAdv adv vps ; + +{- -- : VP -> Adv -> VP ; -- sleep , even though ... ExtAdvVP vp adv = ; -- : AdV -> VP -> VP ; -- always sleep AdVVP adv vp = vp ** {adv = adv} ; - -- : VPSlash -> Adv -> VPSlash ; -- use (it) here - AdvVPSlash vps adv = vps ** { adv = vps.adv ++ adv.s } ; -- : AdV -> VPSlash -> VPSlash ; -- always use (it) AdVVPSlash adv vps = vps ** { adv = adv.s ++ vps.adv } ; @@ -125,7 +126,7 @@ lin CompAP ap = { comp = \\a => <[], ap.s ! AF (getNum a) Abs> ; } ; -{-} +{- -- : CN -> Comp ; CompCN cn = { } ;