a majour refactoring to support clitic pronouns

This commit is contained in:
Krasimir Angelov
2018-07-04 13:01:06 +02:00
parent 6fe595104c
commit 21961e39ba
16 changed files with 404 additions and 336 deletions
+135 -100
View File
@@ -22,7 +22,7 @@ resource ResBul = ParamX ** open Prelude, Predef in {
param
Role = RSubj | RObj Case | RVoc ;
Case = Acc | Dat | WithPrep ;
Case = Acc | Dat | WithPrep | CPrep ;
NForm =
NF Number Species
@@ -38,7 +38,7 @@ resource ResBul = ParamX ** open Prelude, Predef in {
GenNum = GSg Gender | GPl ;
-- Agreement of $NP$ is a record. We'll add $Gender$ later.
PronPerson = PronP1 | PronP2 | PronP3 | NounP3 Polarity ;
oper
Agr = {gn : GenNum ; p : Person} ;
@@ -120,11 +120,6 @@ resource ResBul = ParamX ** open Prelude, Predef in {
_ => GPl
} ;
conjAgr : Agr -> Agr -> Agr = \a,b -> {
gn = conjGenNum a.gn b.gn ;
p = conjPerson a.p b.p
} ;
gennum : AGender -> Number -> GenNum = \g,n ->
case n of {
Sg => GSg (case g of {
@@ -147,6 +142,22 @@ resource ResBul = ParamX ** open Prelude, Predef in {
NCountable => Pl
} ;
personPol : PronPerson -> Polarity = \p ->
case p of {
NounP3 pol => pol;
_ => Pos
} ;
personAgr : GenNum -> PronPerson -> Agr = \gn,p ->
{gn = gn;
p = case p of {
PronP1 => P1 ;
PronP2 => P2 ;
PronP3 => P3 ;
NounP3 _ => P3
}
} ;
orPol : Polarity -> Polarity -> Polarity = \p1,p2 ->
case p1 of {
Neg => Neg;
@@ -223,62 +234,68 @@ resource ResBul = ParamX ** open Prelude, Predef in {
} ;
VP : Type = {
s : Aspect => VTable ;
ad : {isEmpty : Bool; s : Str} ; -- sentential adverb
compl : Agr => Str ;
vtype : VType ;
p : Polarity ;
s : Aspect => VTable ;
ad : {isEmpty : Bool; s : Str} ; -- sentential adverb
clitics : Str ;
compl : Agr => Str ;
vtype : VType ;
p : Polarity ;
isSimple : Bool -- regulates the place of participle used as adjective
} ;
VPSlash = {
s : Aspect => VTable ;
ad : {isEmpty : Bool; s : Str} ; -- sentential adverb
compl1 : Agr => Str ;
compl2 : Agr => Str ;
vtype : VType ;
p : Polarity ;
c2 : Preposition ;
s : Aspect => VTable ;
ad : {isEmpty : Bool; s : Str} ; -- sentential adverb
clitics : Str ;
compl1 : Agr => Str ;
compl2 : Agr => Str ;
vtype : VType ;
p : Polarity ;
c2 : Preposition ;
isSimple : Bool ; -- regulates the place of participle used as adjective
subjCtrl : Bool -- the second complement agrees with the subject or with the first complement
} ;
predV : Verb -> VP = \verb -> {
s = verb.s ;
ad = {isEmpty=True; s=[]} ;
compl = \\_ => [] ;
vtype = verb.vtype ;
p = Pos ;
s = verb.s ;
ad = {isEmpty=True; s=[]} ;
clitics = [] ;
compl = \\_ => [] ;
vtype = verb.vtype ;
p = Pos ;
isSimple = True
} ;
slashV : Verb -> Preposition -> Bool -> VPSlash = \verb,prep,subjCtrl -> {
s = verb.s ;
ad = {isEmpty=True; s=[]} ;
compl1 = \\_ => [] ;
compl2 = \\_ => [] ;
vtype = verb.vtype ;
p = Pos ;
c2 = prep ;
s = verb.s ;
ad = {isEmpty=True; s=[]} ;
clitics = [] ;
compl1 = \\_ => [] ;
compl2 = \\_ => [] ;
vtype = verb.vtype ;
p = Pos ;
c2 = prep ;
isSimple = True ;
subjCtrl = subjCtrl
} ;
insertObj : (Agr => Str) -> Polarity -> VP -> VP = \obj,p,vp -> {
s = vp.s ;
ad = vp.ad ;
compl = \\a => vp.compl ! a ++ obj ! a ;
vtype = vp.vtype ;
p = case p of {
Neg => Neg;
_ => vp.p
} ;
s = vp.s ;
ad = vp.ad ;
clitics= vp.clitics ;
compl = \\a => vp.compl ! a ++ obj ! a ;
vtype = vp.vtype ;
p = case p of {
Neg => Neg;
_ => vp.p
} ;
isSimple = False
} ;
insertSlashObj1 : (Agr => Str) -> Polarity -> VPSlash -> VPSlash = \obj,p,slash -> {
s = slash.s ;
ad = slash.ad ;
clitics= slash.clitics ;
compl1 = \\a => slash.compl1 ! a ++ obj ! a ;
compl2 = slash.compl2 ;
vtype = slash.vtype ;
@@ -294,6 +311,7 @@ resource ResBul = ParamX ** open Prelude, Predef in {
insertSlashObj2 : (Agr => Str) -> Polarity -> VPSlash -> VPSlash = \obj,p,slash -> {
s = slash.s ;
ad = slash.ad ;
clitics= slash.clitics ;
compl1 = slash.compl1 ;
compl2 = \\a => slash.compl2 ! a ++ obj ! a ;
vtype = slash.vtype ;
@@ -377,12 +395,12 @@ resource ResBul = ParamX ** open Prelude, Predef in {
verbBe : Verb = {s=table Aspect [auxBe; auxWould] ; vtype=VNormal} ;
reflClitics : Case => Str = table {Acc => "ñå"; Dat => "ñè"; WithPrep => with_Word ++ "ñåáå ñè"} ;
reflClitics : Case => Str = table {Acc => "ñå"; Dat => "ñè"; WithPrep => with_Word ++ "ñåáå ñè"; CPrep => "ñåáå ñè"} ;
personalClitics : Case => GenNum => Person => Str =
personalClitics : Agr -> Case => Str = \agr ->
table {
Acc => table {
GSg g => table {
Acc => case agr.gn of {
GSg g => case agr.p of {
P1 => "ìå" ;
P2 => "òå" ;
P3 => case g of {
@@ -391,14 +409,14 @@ resource ResBul = ParamX ** open Prelude, Predef in {
Neut => "ãî"
}
} ;
GPl => table {
GPl => case agr.p of {
P1 => "íè" ;
P2 => "âè" ;
P3 => "ãè"
}
} ;
Dat => table {
GSg g => table {
Dat => case agr.gn of {
GSg g => case agr.p of {
P1 => "ìè" ;
P2 => "òè" ;
P3 => case g of {
@@ -407,14 +425,14 @@ resource ResBul = ParamX ** open Prelude, Predef in {
Neut => "ìó"
}
} ;
GPl => table {
GPl => case agr.p of {
P1 => "íè" ;
P2 => "âè" ;
P3 => "èì"
}
} ;
WithPrep => table {
GSg g => table {
WithPrep => case agr.gn of {
GSg g => case agr.p of {
P1 => with_Word ++ "ìåí" ;
P2 => with_Word ++ "òåá" ;
P3 => case g of {
@@ -423,11 +441,27 @@ resource ResBul = ParamX ** open Prelude, Predef in {
Neut => with_Word ++ "íåãî"
}
} ;
GPl => table {
GPl => case agr.p of {
P1 => with_Word ++ "íàñ" ;
P2 => with_Word ++ "âàñ" ;
P3 => with_Word ++ "òÿõ"
}
} ;
CPrep => case agr.gn of {
GSg g => case agr.p of {
P1 => "ìåí" ;
P2 => "òåá" ;
P3 => case g of {
Masc => "íåãî" ;
Fem => "íåÿ" ;
Neut => "íåãî"
}
} ;
GPl => case agr.p of {
P1 => "íàñ" ;
P2 => "âàñ" ;
P3 => "òÿõ"
}
}
} ;
@@ -463,17 +497,18 @@ resource ResBul = ParamX ** open Prelude, Predef in {
s : Tense => Anteriority => Polarity => Order => Str
} ;
mkClause : Str -> Agr -> Polarity -> VP -> Clause =
\subj,agr,p1,vp -> {
mkClause : Str -> GenNum -> PronPerson -> VP -> Clause =
\subj,gn,p1,vp -> {
s = \\t,a,p2,o =>
let
p : Polarity
= case <p1,p2,vp.p> of {
= case <personPol p1,p2,vp.p> of {
<Neg,_,_> => Neg ;
<_,Neg,_> => Neg ;
<_,_,Neg> => Neg ;
_ => Pos
} ;
agr = personAgr gn p1 ;
verb : Bool => Str
= \\q => vpTenses vp ! t ! a ! p ! agr ! q ! Perf ;
compl = vp.compl ! agr
@@ -487,9 +522,10 @@ resource ResBul = ParamX ** open Prelude, Predef in {
vpTenses : VP -> Tense => Anteriority => Polarity => Agr => Bool => Aspect => Str =
\verb -> \\t,a,p,agr,q0,asp =>
let clitic = case verb.vtype of {
VNormal => {s=[]; agr=agr} ;
VMedial c => {s=reflClitics ! c; agr=agr} ;
VPhrasal c => {s=personalClitics ! c ! agr.gn ! agr.p; agr={gn=GSg Neut; p=P3}}
VNormal => {s=verb.clitics; agr=agr} ;
VMedial c => {s=verb.clitics++reflClitics ! c; agr=agr} ;
VPhrasal Dat => {s=personalClitics agr ! Dat++verb.clitics; agr={gn=GSg Neut; p=P3}} ;
VPhrasal c => {s=verb.clitics++personalClitics agr ! c; agr={gn=GSg Neut; p=P3}}
} ;
present = verb.s ! asp ! (VPres (numGenNum clitic.agr.gn) clitic.agr.p) ;
@@ -524,8 +560,8 @@ resource ResBul = ParamX ** open Prelude, Predef in {
Pos => case q of {True => {s1=[]; s2="ëè"++s};
False => {s1=s; s2=[]}} ;
Neg => case verb.vtype of
{VNormal => {s1="íå"; s2=li} ;
_ => {s1="íå"++s++li; s2=[]}}
{VNormal => {s1="íå"++s; s2=li} ;
_ => {s1="íå"++s++li; s2=[]}}
} ;
vf3 : Str -> {s1 : Str; s2 : Str} = \s ->
@@ -557,10 +593,11 @@ resource ResBul = ParamX ** open Prelude, Predef in {
daComplex : Anteriority -> Polarity -> VP -> Aspect => Agr => Str =
\a,p,vp -> \\asp,agr =>
let clitic = case vp.vtype of {
VNormal => {s=[]; agr=agr} ;
VMedial c => {s=reflClitics ! c; agr=agr} ;
VPhrasal c => {s=personalClitics ! c ! agr.gn ! agr.p; agr={gn=GSg Neut; p=P3}}
} ;
VNormal => {s=vp.clitics; agr=agr} ;
VMedial c => {s=vp.clitics++reflClitics ! c; agr=agr} ;
VPhrasal Dat => {s=personalClitics agr ! Dat++vp.clitics; agr={gn=GSg Neut; p=P3}} ;
VPhrasal c => {s=vp.clitics++personalClitics agr ! c; agr={gn=GSg Neut; p=P3}}
} ;
pol = case p of {Pos => ""; Neg => "íå"}
in vp.ad.s ++ "äà" ++ pol ++ clitic.s ++
case a of {
@@ -576,21 +613,32 @@ resource ResBul = ParamX ** open Prelude, Predef in {
clitic = case vp.vtype of {
VNormal => {s=[]; agr=agr} ;
VMedial c => {s=reflClitics ! c; agr=agr} ;
VPhrasal c => {s=personalClitics ! c ! agr.gn ! agr.p; agr={gn=GSg Neut; p=P3}}
VPhrasal c => {s=personalClitics agr ! c; agr={gn=GSg Neut; p=P3}}
} ;
in vp.ad.s ++
vp.s ! Imperf ! VPres (numGenNum clitic.agr.gn) clitic.agr.p ++ clitic.s ++
vp.compl ! agr ;
linrefPrep : {s:Str; c:Case} -> Str =
\p -> case p.c of {Acc=>""; Dat=>"íà"; WithPrep=>with_Word} ++ p.s ;
linCase : Case -> Polarity -> Str =
\c,p -> case c of {
Acc => "" ;
Dat => "íà" ;
WithPrep => case p of {
Pos => with_Word ;
Neg => "áåç"
} ;
CPrep => ""
} ;
linPrep : {s:Str; c:Case} -> Str =
\p -> p.s ++ linCase p.c Pos ;
gerund : VP -> Aspect => Agr => Str =
\vp -> \\asp,agr =>
let clitic = case vp.vtype of {
VNormal => {s=[]; agr=agr} ;
VMedial c => {s=reflClitics ! c; agr=agr} ;
VPhrasal c => {s=personalClitics ! c ! agr.gn ! agr.p; agr={gn=GSg Neut; p=P3}}
VPhrasal c => {s=personalClitics agr ! c; agr={gn=GSg Neut; p=P3}}
}
in vp.ad.s ++ clitic.s ++ vp.s ! asp ! VGerund ++ vp.compl ! agr ;
@@ -686,6 +734,7 @@ resource ResBul = ParamX ** open Prelude, Predef in {
RObj Acc => table QForm [kogo; kogo+"òî"] ;
RObj Dat => table QForm ["íà" ++ kogo; "íà" ++ kogo+"òî"] ;
RObj WithPrep => table QForm [with_Word ++ kogo; with_Word ++ kogo+"òî"] ;
RObj CPrep => table QForm [kogo; kogo+"òî"] ;
RVoc => table QForm [koi; koi+"òî"]
} ;
gn = gn
@@ -696,25 +745,18 @@ resource ResBul = ParamX ** open Prelude, Predef in {
"ñúñ" / strs {"ñ" ; "ç" ; "Ñ" ; "Ç"}
} ;
mkPron : (az,men,me,mi,moj,moia,moiat,moia_,moiata,moe,moeto,moi,moite : Str) ->
GenNum -> Person -> {s : Role => Str;
clit : Case => Str;
gen : AForm => Str;
a : Agr
} =
\az,men,me,mi,moj,moia,moiat,moia_,moiata,moe,moeto,moi,moite,gn,p -> {
mkPron : (az,moj,moia,moiat,moia_,moiata,moe,moeto,moi,moite : Str) ->
GenNum -> PronPerson -> {s : Role => Str;
gen : AForm => Str;
gn : GenNum;
p : PronPerson
} =
\az,moj,moia,moiat,moia_,moiata,moe,moeto,moi,moite,gn,p -> {
s = table {
RSubj => az ;
RObj Acc => men ;
RObj Dat => "íà" ++ men ;
RObj WithPrep => with_Word ++ men ;
RVoc => az
RSubj => az ;
RObj c => personalClitics (personAgr gn p) ! c ;
RVoc => az
} ;
clit = table {
Acc => me;
Dat => mi;
WithPrep => with_Word ++ men
} ;
gen = table {
ASg Masc Indef => moj ;
ASg Masc Def => moia ;
@@ -726,26 +768,19 @@ resource ResBul = ParamX ** open Prelude, Predef in {
APl Indef => moi ;
APl Def => moite
} ;
a = {
gn = gn ;
p = p
}
gn = gn ;
p = p
} ;
mkNP : Str -> GenNum -> Person -> Polarity -> {s : Role => Str; a : Agr; p : Polarity} =
\s,gn,p,pol -> {
mkNP : Str -> GenNum -> PronPerson -> {s : Role => Str; gn : GenNum; p : PronPerson} =
\s,gn,p -> {
s = table {
RSubj => s ;
RObj Acc => s ;
RObj Dat => "íà" ++ s ;
RObj WithPrep => with_Word ++ s ;
RVoc => s
RSubj => s ;
RObj c => linCase c (personPol p) ++ s ;
RVoc => s
} ;
a = {
gn = gn ;
p = p
} ;
p = pol
gn = gn ;
p = p
} ;
Preposition : Type = {s : Str; c : Case};