(Som) Take passive out of Prep + add reflexive as PrepAgr + update tests

This commit is contained in:
Inari Listenmaa
2019-07-24 19:24:19 +03:00
parent c4d7eabc83
commit 8c8612b7d7
4 changed files with 79 additions and 71 deletions

View File

@@ -103,10 +103,10 @@ oper
mkPrep = overload { mkPrep = overload {
mkPrep : Str -> CatSom.Prep = \s -> 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=[]}) ; c2=noPrep ; sii,dhex,berri=[]}) ;
mkPrep : (x1,_,_,_,_,x6 : Str) -> CatSom.Prep = \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) ** { lin Prep ((ResSom.mkPrep a b c d e f g) ** {
c2=noPrep ; sii,dhex,berri=[]}) ; c2=noPrep ; sii,dhex,berri=[]}) ;
mkPrep : Preposition -> CatSom.Prep = \p -> mkPrep : Preposition -> CatSom.Prep = \p ->
lin Prep ((prep p) ** {sii,dhex,berri=[]}) ; lin Prep ((prep p) ** {sii,dhex,berri=[]}) ;

View File

@@ -142,6 +142,7 @@ param
| Pl1_Prep Inclusion | Pl1_Prep Inclusion
| Pl2_Prep | Pl2_Prep
| Impers_Prep | Impers_Prep
| Reflexive_Prep
| P3_Prep ; | P3_Prep ;
State = Definite | Indefinite ; State = Definite | Indefinite ;
@@ -193,25 +194,20 @@ param
param param
Preposition = U | Ku | Ka | La | NoPrep ; 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 PrepCombination = Ugu | Uga | Ula | Kaga | Kula | Kala
| Lagu -- laygu, lagugu, nalagu, laydinku | Passive | Lagu | Laga -- TODO all combinations with impersonal la
| Laga -- layga, lagaa, nalaga, laydinka | Single Preposition ;
-- | TODO rest of combinations with impersonal-la
-- | TODO incorporate reflexive too
| Single PrepositionPlus ;
oper oper
combine : PrepositionPlus -> Preposition -> PrepCombination = \p1,p2 -> combine : (isPassive : Bool) -> Preposition -> Preposition -> PrepCombination = \isPass,p1,p2 ->
let oneWay : PrepositionPlus => Preposition => PrepCombination = let oneWay : Preposition => Preposition => PrepCombination =
\\x,y => case <x,y> of { \\x,y => case <isPass,x,y> of {
<Passive,NoPrep> => Single Passive ; <True,NoPrep,NoPrep> => Passive ;
<Passive,Ku> => Lagu ; <True,Ku,NoPrep> => Lagu ;
<Passive,Ka> => Laga ; <True,Ka,NoPrep> => Laga ;
<Passive,p> => Single (P p) ; -- TODO rest of combinations <True,p,_> => Single p ; -- TODO all combinations
<P z,_> => case <z,y> of { <False,_,_> => case <x,y> of {
<U,U|Ku> => Ugu ; <U,U|Ku> => Ugu ;
<U,Ka> => Uga ; <U,Ka> => Uga ;
<U,La> => Ula ; <U,La> => Ula ;
@@ -219,15 +215,13 @@ oper
Ku|Ka> => Kaga ; Ku|Ka> => Kaga ;
<Ku,La> => Kula ; <Ku,La> => Kula ;
<Ka,La> => Kala ; <Ka,La> => Kala ;
<NoPrep,p> => Single (P p) ; <NoPrep,p> => Single p ;
<p,NoPrep> => Single x ; <p,NoPrep> => Single x ;
<p,_> => Single x }} -- for trying both ways <p,_> => Single x }} -- for trying both ways
in case oneWay ! P p2 ! (pp2prep p1) of { in case oneWay ! p2 ! p1 of {
Single _ => oneWay ! p1 ! p2 ; Single _ => oneWay ! p1 ! p2 ;
z => z } ; z => z } ;
pp2prep : PrepositionPlus -> Preposition = \pp ->
case pp of {P p => p ; _ => NoPrep} ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Verbs -- Verbs

View File

@@ -324,66 +324,80 @@ oper
Prep : Type = {s : PrepAgr => Str} ; 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 { s = table {
P3_Prep => ku ;
Sg1_Prep => ii ; Sg1_Prep => ii ;
Sg2_Prep => kuu ; Sg2_Prep => kuu ;
Pl2_Prep => idiin ; Pl2_Prep => idiin ;
Pl1_Prep Excl => noo ; Pl1_Prep Excl => noo ;
Pl1_Prep Incl => "i" + noo ; Pl1_Prep Incl => "i" + noo ;
Impers_Prep => loo ; Reflexive_Prep => isku ;
P3_Prep => ku 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 { prepTable : Preposition => Prep = table {
P Ku => mkPrep "ku" "igu" "kugu" "nagu" "idinku" "lagu" ; Ku => mkPrep "ku" "igu" "kugu" "nagu" "idinku" "isku" "lagu" ;
P Ka => mkPrep "ka" "iga" "kaa" "naga" "idinka" "laga" ; Ka => mkPrep "ka" "iga" "kaa" "naga" "idinka" "iska" "laga" ;
P La => mkPrep "la" "ila" "kula" "nala" "idinla" "lala" ; La => mkPrep "la" "ila" "kula" "nala" "idinla" "isla" "lala" ;
P U => mkPrep "u" "ii" "kuu" "noo" "idiin" "loo" ; U => mkPrep "u" "ii" "kuu" "noo" "idiin" "is_u_???:TODO" "loo" ;
P NoPrep => mkPrep [] "i" "ku" "na" "idin" "la" ; NoPrep => mkPrep [] "i" "ku" "na" "idin" "is" "la"
-- impersonal subject clitic combining with object clitics.
Passive => mkPrep "la" "la i" "lagu" "nala" "laydin" "la"
} ; } ;
prepCombTable : PrepAgr => PrepCombination => Str = table { prepCombTable : PrepAgr => PrepCombination => Str = table {
Sg1_Prep => table { Ugu => "iigu" ; Uga => "iiga" ; Sg1_Prep => table {
Ugu => "iigu" ; Uga => "iiga" ;
Ula => "iila" ; Kaga => "igaga" ; Ula => "iila" ; Kaga => "igaga" ;
Kula => "igula" ; Kala => "igala" ; Kula => "igula" ; Kala => "igala" ;
Passive => "la i" ;
Lagu => "laygu" ; Laga => "layga" ; Lagu => "laygu" ; Laga => "layga" ;
Single p => (prepTable ! p).s ! Sg1_Prep } ; Single p => (prepTable ! p).s ! Sg1_Prep } ;
Sg2_Prep => table { Ugu => "kuugu" ; Uga => "kaaga" ; Sg2_Prep => table { Ugu => "kuugu" ; Uga => "kaaga" ;
Ula => "kuula" ; Kaga => "kaaga" ; Ula => "kuula" ; Kaga => "kaaga" ;
Kula => "kugula" ; Kala => "kaala" ; Kula => "kugula" ; Kala => "kaala" ;
Passive => "lagu" ;
Lagu => "lagugu" ; Laga => "lagaa" ; Lagu => "lagugu" ; Laga => "lagaa" ;
Single p => (prepTable ! p).s ! Sg2_Prep } ; Single p => (prepTable ! p).s ! Sg2_Prep } ;
Pl1_Prep Excl => Pl1_Prep Excl =>
table { Ugu => "noogu" ; Uga => "nooga" ; table { Ugu => "noogu" ; Uga => "nooga" ;
Ula => "noola" ; Kaga => "nagaga" ; Ula => "noola" ; Kaga => "nagaga" ;
Kula => "nagula" ; Kala => "nagala" ; Kula => "nagula" ; Kala => "nagala" ;
Passive => "nala" ;
Lagu => "nalagu" ; Laga => "nalaga" ; Lagu => "nalagu" ; Laga => "nalaga" ;
Single p => (prepTable ! p).s ! Pl1_Prep Excl } ; Single p => (prepTable ! p).s ! Pl1_Prep Excl } ;
Pl1_Prep Incl => Pl1_Prep Incl =>
table { Ugu => "inoogu" ; Uga => "inooga" ; table { Ugu => "inoogu" ; Uga => "inooga" ;
Ula => "inoola" ; Kaga => "inagaga" ; Ula => "inoola" ; Kaga => "inagaga" ;
Kula => "inagula" ; Kala => "inagala" ; Kula => "inagula" ; Kala => "inagala" ;
Passive => "inala" ;
Lagu => "inalagu" ; Laga => "inalaga" ; Lagu => "inalagu" ; Laga => "inalaga" ;
Single p => (prepTable ! p).s ! Pl1_Prep Incl } ; Single p => (prepTable ! p).s ! Pl1_Prep Incl } ;
Pl2_Prep => table { Ugu => "idiinku" ; Uga => "idiinka" ; Pl2_Prep => table { Ugu => "idiinku" ; Uga => "idiinka" ;
Ula => "idiinla" ; Kaga => "idinkaga" ; Ula => "idiinla" ; Kaga => "idinkaga" ;
Kula => "idinkula" ; Kala => "idinkala" ; Kula => "idinkula" ; Kala => "idinkala" ;
Passive => "laydin" ;
Lagu => "laydinku" ; Laga => "laydinka" ; Lagu => "laydinku" ; Laga => "laydinka" ;
Single p => (prepTable ! p).s ! Pl2_Prep } ; Single p => (prepTable ! p).s ! Pl2_Prep } ;
Impers_Prep => Impers_Prep =>
table { Ugu => "loogu" ; Uga => "looga" ; table { Ugu => "loogu" ; Uga => "looga" ;
Ula => "loola" ; Kaga => "lagaga" ; Ula => "loola" ; Kaga => "lagaga" ;
Kula => "lagula" ; Kala => "lagala" ; 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 } ; 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" ; a => table { Ugu => "ugu" ; Uga => "uga" ;
Ula => "ula" ; Kaga => "kaga" ; Ula => "ula" ; Kaga => "kaga" ;
Kula => "kula" ; Kala => "kala" ; Kula => "kula" ; Kala => "kala" ;
Passive => "la" ;
Lagu => "lagu" ; Laga => "laga" ; Lagu => "lagu" ; Laga => "laga" ;
Single p => (prepTable ! p).s ! a } Single p => (prepTable ! p).s ! a }
} ; } ;
@@ -652,12 +666,12 @@ oper
VerbPhrase : Type = BaseVerb ** Complement ** BaseAdv ** { VerbPhrase : Type = BaseVerb ** Complement ** BaseAdv ** {
-- Prepositions can combine together and with object pronoun. -- Prepositions can combine together and with object pronoun.
c2 : PrepositionPlus ; -- hack to implement passives more efficiently: isPassive : Bool ;
c3 : Preposition ; -- if c2 is Passive, the real preposition is in c3. c2,c3 : Preposition ; -- if c2 is Passive, the real preposition is in c3.
obj2 : NPLite ; -- {s : Str ; a : PrepAgr} obj2 : NPLite ; -- {s : Str ; a : PrepAgr}
secObj : Str ; -- if two overt pronoun objects secObj : Str ; -- if two overt pronoun objects
vComp : Str ; -- VV complement 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 miscAdv : Str ; -- dump for any other kind of adverb, that isn't
} ; -- in a closed class of particles or made with PrepNP. } ; -- in a closed class of particles or made with PrepNP.
@@ -667,37 +681,37 @@ oper
comp = \\_ => <[],[]> ; comp = \\_ => <[],[]> ;
pred = NoPred ; pred = NoPred ;
vComp,berri,miscAdv,refl = [] ; vComp,berri,miscAdv,refl = [] ;
c2 = P NoPrep ; c2, c3 = NoPrep ;
c3 = NoPrep ; isPassive = False ;
obj2 = {s = [] ; a = P3_Prep} ; obj2 = {s = [] ; a = P3_Prep} ;
secObj = [] secObj = []
} ; } ;
useVc : Verb2 -> VPSlash = \v2 -> useV v2 ** { useVc : Verb2 -> VPSlash = \v2 -> useV v2 ** {
c2 = P v2.c2 c2 = v2.c2
} ; } ;
passV2 : Verb2 -> VerbPhrase = \v2 -> passVP (useV v2) ; passV2 : Verb2 -> VerbPhrase = \v2 -> passVP (useV v2) ;
passVP : VerbPhrase -> VerbPhrase = \vp -> vp ** { passVP : VerbPhrase -> VerbPhrase = \vp -> vp ** {
c2 = Passive ; isPassive = True ;
c3 = pp2prep vp.c2 ;
} ; } ;
complSlash : VPSlash -> VerbPhrase = \vps -> let np = vps.obj2 in vps ** { complSlash : VPSlash -> VerbPhrase = \vps -> let np = vps.obj2 in vps ** {
comp = \\agr => let cmp = vps.comp ! agr in 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. {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. -- 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 -> 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 -> insertRefl : VPSlash -> VPSlash = \vps -> vps ** {
case <vps.c2,vps.c3> of { obj2 = vps.obj2 ** {a = Reflexive_Prep} ;
<P NoPrep,NoPrep> => vps ** {refl = "is"} ; -- NB. if AdvVP is called after ReflVP, vps.c2 may change.
_ => vps ** {refl = "is" ++ BIND} -- 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 -> insertComp : VPSlash -> NounPhrase -> VerbPhrase = \vp,np ->
@@ -727,8 +741,8 @@ oper
NoPrep => vp ** adv'' ; -- the adverb is not formed with PrepNP, e.g. "tomorrow" NoPrep => vp ** adv'' ; -- the adverb is not formed with PrepNP, e.g. "tomorrow"
_ => case <vp.c2,vp.c3> of { _ => case <vp.c2,vp.c3> of {
-- if free complement slots, introduce adv.np with insertComp -- if free complement slots, introduce adv.np with insertComp
<P NoPrep,_> => insertCompAgrPlus (vp ** {c2 = P adv.c2}) adv.np ** adv' ; <NoPrep,_> => insertCompAgrPlus (vp ** {c2 = adv.c2}) adv.np ** adv' ;
<_ ,NoPrep> => insertCompAgrPlus (vp ** {c3 = adv.c2}) adv.np ** adv' ; <_,NoPrep> => insertCompAgrPlus (vp ** {c3 = adv.c2}) adv.np ** adv' ;
-- if complement slots are full, just insert strings. -- if complement slots are full, just insert strings.
_ => vp ** adv'' _ => vp ** adv''
@@ -739,7 +753,7 @@ oper
dhex = vp.dhex ++ adv.dhex ; dhex = vp.dhex ++ adv.dhex ;
berri = vp.berri ++ adv.berri } ; berri = vp.berri ++ adv.berri } ;
adv'' : {sii,dhex,berri,miscAdv : Str} -- adv.np inserted into miscAdv 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} miscAdv = adv.np.s}
} ; } ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@@ -763,7 +777,7 @@ oper
obj : {p1,p2 : Str} = obj : {p1,p2 : Str} =
let o : {p1,p2 : Str} = vp.comp ! subj.a ; let o : {p1,p2 : Str} = vp.comp ! subj.a ;
bind : Str = case <isP3 vp.obj2.a, vp.c2> of { bind : Str = case <isP3 vp.obj2.a, vp.c2> of {
<True,P NoPrep> => [] ; <True,NoPrep> => [] ;
_ => BIND } ; _ => BIND } ;
in case p of { in case p of {
Pos => o ; Pos => o ;
@@ -780,10 +794,10 @@ oper
} ; } ;
in wordOrder subjnoun subjpron stm obj pred vp ; in wordOrder subjnoun subjpron stm obj pred vp ;
} where { } where {
vp = case vps.c2 of { vp = case vps.isPassive of {
Passive => complSlash (insertComp vps np) ; True => complSlash (insertComp vps np) ;
_ => complSlash vps } ; _ => complSlash vps } ;
subj = case vps.c2 of {Passive => impersNP ; _ => np} ; subj = case vps.isPassive of {True => impersNP ; _ => np} ;
} ; } ;
wordOrder : (sn,sp,stm : Str) -> {p1,p2 : Str} -> {fin,inf : Str} -> VerbPhrase -> Str = wordOrder : (sn,sp,stm : Str) -> {p1,p2 : Str} -> {fin,inf : Str} -> VerbPhrase -> Str =
@@ -851,7 +865,7 @@ oper
linAdv : Adverb -> Str = \adv -> linAdv : Adverb -> Str = \adv ->
adv.berri adv.berri
++ adv.sii ++ adv.sii
++ (prepTable ! P adv.c2).s ! adv.np.a ++ (prepTable ! adv.c2).s ! adv.np.a
++ adv.dhex ++ adv.dhex
++ adv.np.s ; ++ adv.np.s ;

View File

@@ -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 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 -- 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 Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPast ASimul) PPos (PredVP (UsePron youSg_Pron) (ReflVP (SlashV2a teach_V2))))) NoVoc
-- LangEng: you don't teach yourself -- 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 Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PNeg (PredVP (UsePron youSg_Pron) (ReflVP (SlashV2a teach_V2))))) NoVoc
-- LangEng: one saw you -- LangEng: one saw you