forked from GitHub/gf-rgl
(Pes) Cleanup, refactoring, add comments
This commit is contained in:
@@ -81,7 +81,7 @@ concrete CatPes of Cat = CommonX - [Adv] ** open ResPes, Prelude in {
|
||||
V, VS, VQ, VA = ResPes.Verb ;
|
||||
|
||||
V2, V2A, V2Q, V2S = ResPes.Verb ** {c2 : Compl} ;
|
||||
V3 = ResPes.Verb ** {c2, c3 : Str} ;
|
||||
V3 = ResPes.Verb ** {c2, c3 : Compl} ;
|
||||
VV = ResPes.Verb ** {isAux : Bool} ;
|
||||
V2V = ResPes.Verb ** {c1 : Str ; c2 : Str ; isAux : Bool} ;
|
||||
A = ResPes.Adjective ;
|
||||
|
||||
@@ -101,7 +101,7 @@ oper
|
||||
|
||||
|
||||
mkV3 : V -> (dir,indir : Str) -> V3 ; -- Takes a verb and two prepositions as strings (can be empty). If the verb takes را for direct object, it's the first Str argument. e.g. talk, با, دربارۀ
|
||||
mkV3 v p q = lin V3 (v ** {c2 = p ; c3 = q}) ;
|
||||
mkV3 v p q = lin V3 (v ** {c2 = prepOrRa p ; c3 = prepOrRa q}) ;
|
||||
|
||||
mkV2V : V -> (cV, cN : Str) -> (isAux : Bool) -> V2V ; -- Verb, complementiser for the verb, complementiser for the noun, whether it's auxiliary.
|
||||
mkV2V v s1 s2 b = lin V2V (v ** {isAux = b ; c1 = s1 ; c2 = s2}) ;
|
||||
@@ -253,15 +253,20 @@ oper
|
||||
|
||||
mkV2 = overload {
|
||||
mkV2 : Str -> V2 -- Predictable V2 with
|
||||
= \s -> lin V2 (regV s ** {c2 = {s = [] ; ra = "را" ; c = VTrans}}) ;
|
||||
= \s -> lin V2 (regV s ** {c2 = prepOrRa "را"}) ;
|
||||
mkV2 : V -> V2
|
||||
= \v -> lin V2 (v ** {c2 = {s = [] ; ra = "را" ; c = VTrans}}) ;
|
||||
= \v -> lin V2 (v ** {c2 = prepOrRa "را"}) ;
|
||||
mkV2 : V -> Prep -> V2
|
||||
= \v,p -> lin V2 (v ** {c2 = {ra = [] ; s = p.s ; c = VTrans}}) ;
|
||||
= \v,p -> lin V2 (v ** {c2 = prepOrRa p.s}) ;
|
||||
mkV2 : V -> Str -> V2
|
||||
= \v,ra -> lin V2 (v ** {c2 = {ra = ra ; s = [] ; c = VTrans}}) ;
|
||||
= \v,ra -> lin V2 (v ** {c2 = prepOrRa ra}) ;
|
||||
mkV2 : V -> Str -> Bool -> V2
|
||||
= \v,p,b -> lin V2 (v ** {c2 = {ra = [] ; s = p ; c = VTrans}}) ;
|
||||
= \v,p,b -> lin V2 (v ** {c2 = {ra = [] ; s = p}}) ;
|
||||
} ;
|
||||
|
||||
prepOrRa : Str -> Compl = \s -> case s of {
|
||||
"را" => {s = [] ; ra = "را"} ;
|
||||
prep => {s = prep ; ra = []}
|
||||
} ;
|
||||
|
||||
mkN2 = overload {
|
||||
@@ -273,11 +278,12 @@ oper
|
||||
|
||||
mkN3 = overload {
|
||||
mkN3 : N -> Str -> Str -> N3
|
||||
= \n,p,q -> lin N3 (n ** {c2=p ; c3=q}) ;
|
||||
= \n,p,q -> lin N3 (n ** {c2 = p ; c3 = q}) ;
|
||||
mkN3 : N -> Prep -> Str -> Str -> N3 -- hidden from public API
|
||||
= \n,p,q,r -> lin N3 (n ** {c2 = p.s ; c3 = q ; c4 = r}) -- there is no c4
|
||||
= \n,p,q,r -> lin N3 (n ** {c2 = p.s ; c3 = q ; c4 = r}) -- there is no c4
|
||||
} ;
|
||||
|
||||
|
||||
mkQuant = overload {
|
||||
-- mkQuant : Pron -> Quant = \p -> {s = \\_,_,c => p.s!c ;a = p.a ; lock_Quant = <>};
|
||||
mkQuant : Str -> Str -> Quant -- hidden from public API
|
||||
|
||||
@@ -59,18 +59,18 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
|
||||
oper
|
||||
|
||||
VPH : Type = {
|
||||
s : VPHForm => Str ;
|
||||
obj : {s : Str ; a : Agr} ; -- direct object of a verb
|
||||
subj : VType ;
|
||||
comp : Agr => Str; -- complements of a verb; those other than a direct object. e.g. indirect object of ditransitive verbs.
|
||||
vComp : Agr => Str; -- when a verb is used as a complement of an auxiliary verb, we store it in this field. Unlike ‘comp’ or ‘obj’, this type of complement follows the auxiliary verb.
|
||||
ad : Str;
|
||||
s : VPHForm => Str ;
|
||||
comp : Agr => Str; -- complements of a verb, agr for e.g. CompCN "I am human/we are humans"
|
||||
vComp : Agr => Str; -- when a verb is used as a complement of an auxiliary verb. Unlike ‘comp’ or ‘obj’, this type of complement follows the auxiliary verb.
|
||||
obj : Str ; -- object of a verb; so far only used for A ("paint it black")
|
||||
subj : VType ;
|
||||
ad : Str ;
|
||||
embComp : Str ; -- when a declarative or interrogative sentence is used as a complement of a verb.
|
||||
wish : Bool ;
|
||||
wish : Bool ; -- whether a VV has been added
|
||||
} ;
|
||||
|
||||
showVPH : VPHForm -> Agr -> VPH -> Str = \vf,agr,vp ->
|
||||
vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.s ! vf ++ vp.vComp ! agr ++ vp.embComp ;
|
||||
vp.ad ++ vp.comp ! agr ++ vp.obj ++ vp.s ! vf ++ vp.vComp ! agr ++ vp.embComp ;
|
||||
|
||||
Compl : Type = {s : Str ; ra : Str} ;
|
||||
|
||||
@@ -127,13 +127,13 @@ oper
|
||||
VPStem2 => verb.s ! Root2 ;
|
||||
VPInf => verb.s ! Inf;
|
||||
VPImp pol n =>verb.s ! Imp pol n };
|
||||
obj = {s = [] ; a = defaultAgr} ;
|
||||
subj = VIntrans ;
|
||||
ad = [];
|
||||
ad,
|
||||
obj,
|
||||
embComp = [];
|
||||
wish = False ;
|
||||
comp,
|
||||
vComp = \\_ => [] ;
|
||||
comp = \\_ => []
|
||||
} ;
|
||||
|
||||
predVc : (Verb ** {c2,c1 : Str}) -> VPHSlash = \verb ->
|
||||
@@ -144,31 +144,32 @@ oper
|
||||
---------------------
|
||||
-- VP complementation
|
||||
---------------------
|
||||
appComp : Compl -> Str -> Str = \c2,obj ->
|
||||
c2.s ++ obj ++ c2.ra ;
|
||||
|
||||
insertComp : (Agr => Str) -> VPH -> VPH = \obj,vp -> vp ** {
|
||||
comp = \\a => vp.comp ! a ++ obj ! a
|
||||
} ;
|
||||
} ;
|
||||
|
||||
insertCompPre : (Agr=>Str) -> VPHSlash -> VPH = \obj,vp -> vp ** {
|
||||
comp = \\a => vp.c2.s ++ obj ! a ++ vp.c2.ra ++ vp.comp ! a
|
||||
comp = \\a => appComp vp.c2 (obj ! a) ++ vp.comp ! a
|
||||
} ;
|
||||
|
||||
insertVV : (Agr => Str) -> VPH -> VPH = \obj1,vp -> vp ** {
|
||||
wish = True ;
|
||||
vComp = \\a => vp.comp ! a ++ obj1 ! a ; -- IL why this is vp.comp and not vp.vComp??
|
||||
} ;
|
||||
} ;
|
||||
|
||||
embComp : Str -> VPH -> VPH = \str,vp -> vp ** {
|
||||
embComp = vp.embComp ++ str ;
|
||||
} ;
|
||||
|
||||
insertObj : Str -> VPH -> VPH = \str,vp -> vp ** {
|
||||
obj = vp.obj ** {s = str ++ vp.obj.s}
|
||||
} ;
|
||||
|
||||
-- TODO: comp or obj? /IL
|
||||
insertObjPre : NP -> VPHSlash -> VPH = \np,vp -> vp ** {
|
||||
comp = \\a => vp.c2.s ++ np.s ! Bare ++ vp.c2.ra ++ np.compl ++ vp.comp ! a
|
||||
insertObj : Str -> VPH -> VPH = \str,vp -> vp ** {
|
||||
obj = vp.obj ++ str
|
||||
} ;
|
||||
|
||||
complSlash : VPHSlash -> NP -> VPH = \vp,np -> vp ** {
|
||||
comp = \\a => appComp vp.c2 (np.s ! Bare) ++ np.compl ++ vp.comp ! a
|
||||
} ;
|
||||
|
||||
---- AR 14/9/2017 trying to fix isAux = True case by inserting conjThat
|
||||
@@ -231,7 +232,7 @@ oper
|
||||
subj = np.s ! Bare ;
|
||||
vp = \\vt,b,ord =>
|
||||
let vps = clTable vp ! np.a ! vt ! b
|
||||
in vp.ad ++ vp.comp ! np.a ++ vp.obj.s ++ vps ++ vp.vComp ! np.a ++ vp.embComp
|
||||
in vp.ad ++ vp.comp ! np.a ++ vp.obj ++ vps ++ vp.vComp ! np.a ++ vp.embComp
|
||||
};
|
||||
|
||||
--Clause : Type = {s : VPHTense => Polarity => Order => Str} ;
|
||||
@@ -239,9 +240,19 @@ oper
|
||||
s = \\vt,b,ord =>
|
||||
let vps = clTable vp ! agr ! vt ! b ;
|
||||
quest = case ord of { ODir => [] ; OQuest => "آیا" }
|
||||
in quest ++ subj ++ vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vps ++ vp.vComp ! agr ++ vp.embComp
|
||||
in quest ++ subj ++ vp.ad ++ vp.comp ! agr ++ vp.obj ++ vps ++ vp.vComp ! agr ++ vp.embComp
|
||||
};
|
||||
|
||||
ta2vt : Tense -> Anteriority -> VPHTense = \t,a -> case <t,a> of {
|
||||
<Pres,Simul> => VPres ;
|
||||
<Pres,Anter> => VPerfPres ;
|
||||
<Past,Simul> => VPast ;
|
||||
<Past,Anter> => VPerfPast ;
|
||||
<Fut,Simul> => VFut ;
|
||||
<Fut,Anter> => VPerfFut ;
|
||||
<Cond,Simul> => VCondSimul ;
|
||||
<Cond,Anter> => VCondSimul } ;
|
||||
|
||||
predAux : Aux -> VPH = \verb -> {
|
||||
s = \\vh => case vh of {
|
||||
VPTense pol (VPPres Simul) agr => verb.inf ! AX pol (AuxPresent PrImperf) agr ;
|
||||
@@ -258,7 +269,7 @@ oper
|
||||
VPInf => "بودن";
|
||||
VPImp _ _ => [] -- need to be confirmed
|
||||
};
|
||||
obj = {s = [] ; a = defaultAgr} ;
|
||||
obj = [] ;
|
||||
subj = VIntrans ;
|
||||
ad = [];
|
||||
embComp = [];
|
||||
|
||||
@@ -13,8 +13,8 @@ concrete SentencePes of Sentence = CatPes ** open Prelude, ResPes,Predef in {
|
||||
s = \\pol,n =>
|
||||
let agr = Ag (numImp n) P2 ;
|
||||
in case vp.wish of {
|
||||
True => vp.s ! VPImp pol (numImp n) ++ vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.vComp ! agr ++ vp.embComp;
|
||||
False => vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.vComp ! agr ++ vp.s ! VPImp pol (numImp n) ++ vp.embComp }
|
||||
True => vp.s ! VPImp pol (numImp n) ++ vp.ad ++ vp.comp ! agr ++ vp.obj ++ vp.vComp ! agr ++ vp.embComp;
|
||||
False => vp.ad ++ vp.comp ! agr ++ vp.obj ++ vp.vComp ! agr ++ vp.s ! VPImp pol (numImp n) ++ vp.embComp }
|
||||
} ;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ concrete SentencePes of Sentence = CatPes ** open Prelude, ResPes,Predef in {
|
||||
SlashPrep cl prep = {
|
||||
subj = [] ; ---- AR 18/9/2017 this can destroy SOV ; Cl should be made discont
|
||||
vp = cl.s ;
|
||||
c2 = { s = prep.s ; ra = [] ; c = VIntrans}
|
||||
c2 = prep ** {ra = []}
|
||||
} ;
|
||||
|
||||
SlashVS np vs slash =
|
||||
@@ -41,61 +41,21 @@ concrete SentencePes of Sentence = CatPes ** open Prelude, ResPes,Predef in {
|
||||
EmbedVP vp = {s = showVPH VPInf defaultAgr vp} ; --- agr
|
||||
|
||||
|
||||
UseCl temp p cl =
|
||||
{ s = case <temp.t,temp.a> of {
|
||||
<Pres,Simul> => temp.s ++ p.s ++ cl.s ! VPres ! p.p ! ODir;
|
||||
<Pres,Anter> => temp.s ++ p.s ++ cl.s ! VPerfPres ! p.p ! ODir;
|
||||
<Past,Simul> => temp.s ++ p.s ++ cl.s ! VPast ! p.p ! ODir;
|
||||
<Past,Anter> => temp.s ++ p.s ++ cl.s ! VPerfPast ! p.p ! ODir;
|
||||
<Fut,Simul> => temp.s ++ p.s ++ cl.s ! VFut ! p.p ! ODir;
|
||||
<Fut,Anter> => temp.s ++ p.s ++ cl.s ! VPerfFut ! p.p ! ODir;
|
||||
<Cond,Simul> => temp.s ++ p.s ++ cl.s ! VCondSimul ! p.p ! ODir;
|
||||
<Cond,Anter> => temp.s ++ p.s ++ cl.s ! VCondAnter ! p.p ! ODir -- this needs to be fixed by making SubjPerf in ResPnb
|
||||
UseCl temp p cl = let vt = ta2vt temp.t temp.a in {
|
||||
s = temp.s ++ p.s ++ cl.s ! vt ! p.p ! ODir
|
||||
} ;
|
||||
|
||||
};
|
||||
} ;
|
||||
UseQCl temp p cl = {
|
||||
s = \\q => case <temp.t,temp.a> of {
|
||||
<Pres,Simul> => temp.s ++ p.s ++ cl.s ! VPres ! p.p ! q;
|
||||
<Pres,Anter> => temp.s ++ p.s ++ cl.s ! VPerfPres ! p.p ! q;
|
||||
<Past,Simul> => temp.s ++ p.s ++ cl.s ! VPast ! p.p ! q;
|
||||
<Past,Anter> => temp.s ++ p.s ++ cl.s ! VPerfPast ! p.p ! q;
|
||||
<Fut,Simul> => temp.s ++ p.s ++ cl.s ! VFut ! p.p ! q;
|
||||
<Fut,Anter> => temp.s ++ p.s ++ cl.s ! VPerfFut ! p.p ! q;
|
||||
<Cond,Simul> => temp.s ++ p.s ++ cl.s ! VCondSimul ! p.p ! q;
|
||||
<Cond,Anter> => temp.s ++ p.s ++ cl.s ! VCondAnter ! p.p ! q
|
||||
UseQCl temp p qcl = let vt = ta2vt temp.t temp.a in {
|
||||
s = \\q => temp.s ++ p.s ++ qcl.s ! vt ! p.p ! q;
|
||||
} ;
|
||||
|
||||
};
|
||||
} ;
|
||||
UseRCl temp p rcl = let vt = ta2vt temp.t temp.a in rcl ** {
|
||||
s = \\q => temp.s ++ p.s ++ rcl.s ! vt ! p.p ! ODir ! q
|
||||
} ;
|
||||
|
||||
UseRCl temp p rcl = {
|
||||
s = \\q => case <temp.t,temp.a> of {
|
||||
<Pres,Simul> => temp.s ++ p.s ++ rcl.s ! VPres ! p.p ! ODir ! q;
|
||||
<Pres,Anter> => temp.s ++ p.s ++ rcl.s ! VPerfPres ! p.p ! ODir ! q;
|
||||
<Past,Simul> => temp.s ++ p.s ++ rcl.s ! VPast ! p.p ! ODir ! q;
|
||||
<Past,Anter> => temp.s ++ p.s ++ rcl.s ! VPerfPast ! p.p ! ODir ! q;
|
||||
<Fut,Simul> => temp.s ++ p.s ++ rcl.s ! VFut ! p.p ! ODir ! q;
|
||||
<Fut,Anter> => temp.s ++ p.s ++ rcl.s ! VPerfFut ! p.p ! ODir ! q;
|
||||
<Cond,Simul> => temp.s ++ p.s ++ rcl.s ! VCondSimul ! p.p ! ODir ! q;
|
||||
<Cond,Anter> => temp.s ++ p.s ++ rcl.s ! VCondAnter ! p.p ! ODir ! q
|
||||
};
|
||||
c = rcl.c
|
||||
} ;
|
||||
|
||||
UseSlash temp p clslash = {
|
||||
s = temp.s ++ p.s ++ clslash.subj ++
|
||||
case <temp.t,temp.a> of {
|
||||
<Pres,Simul> => clslash.vp ! VPres ! p.p ! ODir;
|
||||
<Pres,Anter> => clslash.vp ! VPerfPres ! p.p ! ODir;
|
||||
<Past,Simul> => clslash.vp ! VPast ! p.p ! ODir ;
|
||||
<Past,Anter> => clslash.vp ! VPerfPast ! p.p ! ODir;
|
||||
<Fut,Simul> => clslash.vp ! VFut ! p.p ! ODir;
|
||||
<Fut,Anter> => clslash.vp ! VPerfFut ! p.p ! ODir;
|
||||
<Cond,Simul> => clslash.vp ! VCondSimul ! p.p ! ODir;
|
||||
<Cond,Anter> => clslash.vp ! VCondSimul ! p.p ! ODir
|
||||
};
|
||||
c2 = clslash.c2
|
||||
} ;
|
||||
UseSlash temp p cls = let vt = ta2vt temp.t temp.a in cls ** {
|
||||
s = temp.s ++ p.s ++ cls.subj ++ cls.vp ! vt ! p.p ! ODir
|
||||
} ;
|
||||
|
||||
AdvS a s = {s = a.s ++ s.s} ;
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
|
||||
flags optimize=all_subs ;
|
||||
|
||||
lin
|
||||
UseV v = predV v ;
|
||||
SlashV2a v = predV v ** {c2 = v.c2} ; --{s = v.c2.s ; ra = v.c2.ra ; c = VTrans}} ;
|
||||
Slash2V3 v np = {c2 = {s = [] ; ra = v.c3}} **
|
||||
insertObj (np.s ! Bare ++ v.c2) (predV v) ; -- ** ; c = VTrans}}) ;
|
||||
UseV v = predV v ;
|
||||
SlashV2a v = v ** predV v;
|
||||
Slash2V3 v np = {c2 = v.c3} **
|
||||
complSlash (predV v ** {c2 = v.c2}) np ;
|
||||
|
||||
Slash3V3 v np = {c2 = {s = [] ; ra = v.c2}} **
|
||||
insertObj (v.c3 ++ np.s ! Bare) (predV v) ; -- ** ; c = VTrans}}) ;
|
||||
Slash3V3 v np = {c2 = v.c2} **
|
||||
complSlash (predV v ** {c2 = v.c3}) np ;
|
||||
|
||||
ComplSlash vp np = insertObjPre np vp ;
|
||||
ComplSlash = complSlash ;
|
||||
|
||||
ComplVV v vp = insertVV (infVV v.isAux vp) (predV v) ;
|
||||
ComplVS v s = embComp (conjThat ++ s.s) (predV v) ;
|
||||
ComplVQ v q = embComp (conjThat ++ q.s ! QIndir) (predV v) ;
|
||||
ComplVA v ap = insertComp (\\_ => ap.s ! Bare) (predV v) ; -- check form of adjective
|
||||
ComplVA v ap = insertObj (ap.s ! Bare) (predV v) ; -- check form of adjective
|
||||
SlashV2V v vp = insertVV (infVV v.isAux vp) (predV v) **{c2 = {s = v.c1 ; ra = []}} ;
|
||||
|
||||
SlashV2S v s = v ** embComp (conjThat ++ s.s) (predV v) ;
|
||||
@@ -28,8 +28,8 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
|
||||
|
||||
SlashV2VNP v2v np vps =
|
||||
let vvVP : VPH = insertVV (infVV v2v.isAux vps) (predV v2v) ;
|
||||
vvVPS = vvVP ** {c2={s=v2v.c1 ; ra=v2v.c2}} ;
|
||||
in insertObjPre np vvVPS ** {c2 = vps.c2} ;
|
||||
vvVPS = vvVP ** {c2={s=v2v.c1 ; ra=v2v.c2}} ; -- TODO find out if it's a general rule; only one V2V in the lexicon /IL
|
||||
in complSlash vvVPS np ** {c2 = vps.c2} ;
|
||||
|
||||
|
||||
UseComp comp = insertComp comp.s (predAux auxBe) ;
|
||||
@@ -39,7 +39,7 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
|
||||
AdVVP adv vp = insertAdV adv.s vp ;
|
||||
ReflVP v = insertCompPre reflPron v ;
|
||||
PassV2 v = predV v ; -- need to be fixed
|
||||
CompAP ap ={s = \\_ => ap.s ! Bare} ; -- check form of adjective
|
||||
CompAP ap = {s = \\_ => ap.s ! Bare} ; -- check form of adjective
|
||||
CompAdv adv = {s = \\_ => adv.s } ;
|
||||
|
||||
-- see https://sites.la.utexas.edu/persian_online_resources/nouns/noun-in-a-predicative-position/
|
||||
|
||||
Reference in New Issue
Block a user