From d45303ae172a648db403ac00880b0f02298ae752 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 26 Feb 2019 16:58:16 +0100 Subject: [PATCH 1/2] (Pes) Remove compound tenses from V and add new VerbForms. WIP: * tenses with different classes of VV * Fut and Cond Anter * Progressive forms for copula and have_V2 --- src/persian/CatPes.gf | 4 +- src/persian/IdiomPes.gf | 6 +- src/persian/MorphoPes.gf | 224 ++++++++++++++--------------------- src/persian/NounPes.gf | 2 +- src/persian/ParadigmsPes.gf | 41 +++++-- src/persian/ResPes.gf | 119 +++++++++++++------ src/persian/SentencePes.gf | 8 +- src/persian/StructuralPes.gf | 47 +++----- src/persian/VerbPes.gf | 8 +- 9 files changed, 231 insertions(+), 228 deletions(-) diff --git a/src/persian/CatPes.gf b/src/persian/CatPes.gf index 4f5ca6483..af48895ab 100644 --- a/src/persian/CatPes.gf +++ b/src/persian/CatPes.gf @@ -82,8 +82,8 @@ concrete CatPes of Cat = CommonX - [Adv] ** open ResPes, Prelude in { V2, V2A, V2Q, V2S = ResPes.Verb ** {c2 : Compl} ; V3 = ResPes.Verb ** {c2, c3 : Compl} ; - VV = ResPes.Verb ** {isAux : Bool} ; - V2V = ResPes.Verb ** {c1 : Str ; c2 : Str ; isAux : Bool} ; + VV = ResPes.VV ; + V2V = ResPes.VV ** {c1 : Str ; c2 : Str} ; A = ResPes.Adjective ; A2 = ResPes.Adjective ** {c2 : Str} ; diff --git a/src/persian/IdiomPes.gf b/src/persian/IdiomPes.gf index 47c44473f..db1c5013c 100644 --- a/src/persian/IdiomPes.gf +++ b/src/persian/IdiomPes.gf @@ -30,8 +30,10 @@ lin ProgrVP vp = predProg vp ; - ImpPl1 vp = {s = "بیایید" ++ vp.s ! Vvform (agrP1 Pl)} ; - ImpP3 np vp = {s = "بگذارید" ++ np.s!Bare ++ vp.s ! Vvform np.a}; + ImpPl1 vp = let a = agrP1 Pl in + {s = "بیایید" ++ showVPH (VSubj Pos a) a vp } ; + ImpP3 np vp = + {s = "بگذارید" ++ np.s ! Bare ++ showVPH (VSubj Pos np.a) np.a vp}; } diff --git a/src/persian/MorphoPes.gf b/src/persian/MorphoPes.gf index ac6b4fea9..dff9b2bbe 100644 --- a/src/persian/MorphoPes.gf +++ b/src/persian/MorphoPes.gf @@ -142,36 +142,67 @@ Determiner : Type = {s : Str ; n :Number ; isNum : Bool ; mod : Mod} ; -- Verbs ------------------------------------------------------------------ param - VerbForm = VF Polarity VTense Agr - | Vvform Agr - | Imp Polarity Number - | Inf | Root1 | Root2 ; - VTense = VFPres PrAspect - | VFPast PstAspect - | VFFut FtAspect - | VFInfrPast InfrAspect; - PrAspect = PrPerf | PrImperf ; - PstAspect = PstPerf | PstImperf | PstAorist ; - FtAspect = FtAorist ; -- just keep FtAorist - InfrAspect = InfrPerf | InfrImperf ; + VerbForm = Inf -- kardan + | PastStem -- kard -- Also used for future stem + | PresStem -- kon -- Also imperative stem + | PerfStem -- kardeh -- Perfect, pluperfect + | PastPart -- konandeh + | ImpPrefix Polarity -- mi/nmi, except for be and have + | VAor Polarity Agr -- konam + | VPerf Polarity Agr -- kardeh am/nkardeh am + | VPast Polarity Agr -- kardam/nkardam + | VSubj Polarity Agr -- bekonam/nakonam + | VImp Polarity Number -- bekon,bekonid/nakon,nakonid + ; oper - Verb = {s : VerbForm => Str} ; + impRoot : Str -> Str = \root -> case root of { + st + "ی" => st ; + _ => root + }; - mkVerb : (x1,x2 : Str) -> Verb = \inf,root2 -> - let root1 = tk 1 inf ; - impRoot = impRoot root2 - in { s = table { - Root1 => root1 ; - Root2 => root2 ; - Inf => inf ; - Imp Pos Sg => addBh impRoot ; - Imp Pos Pl => addBh impRoot + "ید" ; - Imp Neg Sg => "ن" + impRoot ; - Imp Neg Pl => "ن" + impRoot + "ید" ; - Vvform ag => mkvVform root2 ag ; - VF p t ag => mkCmnVF root1 root2 p t ag } - } ; + mkVerb : (inf,pres : Str) -> Verb = \kardan,kon -> { + s = table { + Inf => kardan ; + PastStem => kard ; + PresStem => kon ; + PerfStem => kardeh ; + PastPart => kon + "نده" ; + ImpPrefix Pos => "می" + ZWNJ ++ BIND ; + ImpPrefix Neg => "نمی" + ZWNJ ++ BIND ; + VAor _ agr => imperfectSuffixD agr kon ; -- for reg verbs, negation comes from prefix + VPerf pol agr => perfectSuffix agr (addN pol kardeh) ; + VPast pol agr => imperfectSuffix agr (addN pol kard) ; + VSubj Pos agr => addBh (imperfectSuffixD agr kon) ; + VSubj Neg agr => addN (imperfectSuffixD agr kon) ; + VImp Pos Sg => addBh imp ; + VImp Pos Pl => addBh imp + "ید" ; + VImp Neg Sg => addN imp ; + VImp Neg Pl => addN imp + "ید" } ; + prefix = [] -- For compound verbs + } where { + kard = tk 1 kardan ; + kardeh = kard + "ه" ; + imp = impRoot kon ; + } ; + + invarV : (inv : Str) -> Verb = \s -> -- truly invariable + let invReg = defectiveVerb s s s in invReg ** + {s = table {ImpPrefix p => invReg.s ! ImpPrefix p ; _ => s}} ; + + defectiveVerb : (inf,pres,past : Str) -> Verb = \bayestan,bayad,bayest -> + let invReg = mkVerb bayestan bayad in invReg ** + {s = \\vf => case vf of { + VAor pol _ => addN pol bayad ; + VImp pol _ => addN pol bayad ; + VSubj pol _ => addN pol bayad ; + VPast pol _ => addN pol bayest ; + VPerf pol _ => addN pol bayest ; + _ => invReg.s ! vf } + } ; +-- +oper + Verb = {s : VerbForm => Str ; prefix : Str} ; -- Verbs that end in یدن, ادن or ودن -- Also some verbs that don't: دانستن with stem دان @@ -180,67 +211,16 @@ oper -- Most verbs that end in C+تن or C+دن mkVerb2 : (_: Str) -> Verb = \inf -> mkVerb inf (tk 2 inf) ; - mkCmnVF : Str -> Str -> Polarity -> VTense -> Agr -> Str = \root1,root2,pol,t,ag -> - let khordh = root1 + "ه"; - nkhordh = addN khordh ; - mekhor = zwnj "می" root2 ; - nmekhor = zwnj "نمی" root2 ; - mekhord = zwnj "می" root1 ; - nmekhord = zwnj "نمی" root1 ; - mekhordh = zwnj "می" khordh ; - nmekhordh = zwnj "نمی" khordh ; - khah = "خواه" ; - nkhah = "نخواه" ; - -- mekhah = zwnj "می" khah ; - -- nmekhah = zwnj "نمی" khah ; - bvdh = "بوده" ; - impfSuff : Str -> Str = imperfectSuffix ag ; - impfSuffD : Str -> Str = imperfectSuffixD ag ; - perfSuff : Str -> Str = perfectSuffix ag ; - pluperfSuff : Str -> Str = pluperfectSuffix ag - in case of { - => impfSuffD mekhor ; - => perfSuff khordh ; - - => pluperfSuff khordh ; - => impfSuff mekhord ; - => impfSuff root1 ; - - => impfSuffD khah ++ root1; - - => khordh ++ perfSuff bvdh ; - => perfSuff khordh ; - - -- negatives - => impfSuffD nmekhor ; - => perfSuff nkhordh ; - - => pluperfSuff nkhordh ; - => impfSuff nmekhord ; - => impfSuff (addN root1) ; - - => impfSuffD nkhah ++ root1 ; - - => nkhordh ++ perfSuff bvdh ; - => perfSuff nmekhordh - - -- => perfSuffD mekhah ++ addBh (perfSuffD root2) ; - -- => perfSuffD nmekhah ++ addBh (perfSuffD root2) ; - } ; - - mkvVform : Str -> Agr -> Str = \root2,ag -> - addBh (imperfectSuffixD ag root2) ; - - impRoot : Str -> Str = \root -> case root of { - st + "ی" => st ; - _ => root - }; - ------------------- -- making negatives ------------------- - addN : Str -> Str ; - addN str = + addN = overload { + addN : Str -> Str = addN' ; + addN : Polarity -> Str -> Str = \p,s -> + case p of {Pos => s ; Neg => addN' s} + } ; + + addN' : Str -> Str = \str -> case str of { "ا" + st => "نی" + str ; "آ" + st => "نیا" + st ; @@ -293,60 +273,34 @@ oper Ag Pl P2 => zwnj s "اید" ; Ag Pl P3 => zwnj s "اند" } ; - pluperfectSuffix : Agr -> Str -> Str = \ag,s -> s ++ - case ag of { -- not suffix, just using consistent naming scheme :-P /IL - Ag Sg P1 => "بودم" ; - Ag Sg P2 => "بودی" ; - Ag Sg P3 => "بود" ; - Ag Pl P1 => "بودیم" ; - Ag Pl P2 => "بودید" ; - Ag Pl P3 => "بودند" } ; + pluperfAux : Polarity -> Agr -> Str = \pol,agr -> + addN pol (imperfectSuffix agr "بود") ; + futAux : Polarity -> Agr -> Str = \pol,agr -> + addN pol (imperfectSuffixD agr "خواه") ; + + subjAux : Polarity -> Agr -> Str = \pol,agr -> + addN pol (imperfectSuffixD agr "باش") ; ---------------------------------- -- Irregular verbs ---------------------------------- - haveVerb : Verb = {s = table { - Root1 => "داشت" ; - Root2 => "دار" ; - Inf => "داشتن" ; - Imp Pos Sg => "بدار" ; - Imp Pos Pl => "بدارید" ; - Imp Neg Sg => "ندار" ; - Imp Neg Pl => "ندارید" ; - Vvform agr => mkvVform "دار" agr ; - VF pol tense agr => case of { - => imperfectSuffixD agr "دار" ; - => imperfectSuffixD agr (addN "دار") ; - _ => mkCmnVF "داشت" "دار" pol tense agr - } - } - } ; + haveVerb : Verb = haveRegV ** {s = table { + ImpPrefix _ => [] ; + vf => haveRegV.s ! vf } + } where { haveRegV = mkVerb "داشتن" "دار" } ; + + beVerb : Verb = beRegV ** {s = table { + ImpPrefix _ => [] ; + VAor Pos (Ag Sg P3) => "است" ; + VAor Pos agr => imperfectSuffix agr "هست" ; + VAor Neg agr => imperfectSuffix agr "نیست" ; + VSubj pol agr => addN pol (imperfectSuffixD agr "باش") ; + VImp Pos Sg => "باش" ; + VImp Pos Pl => "باشید" ; + VImp Neg Sg => "نباش" ; + VImp Neg Pl => "نباشید" ; + vf => beRegV.s ! vf } + } where { beRegV = mkVerb "بودن" "باش" } ; - -- TODO: merge with auxBe in ResPes - beVerb : Verb = { s = table { - Vvform agr => imperfectSuffixD agr "باش" ; - Imp Pos Sg => "باش" ; - Imp Pos Pl => "باشید" ; - Imp Neg Sg => "نباش" ; - Imp Neg Pl => "نباشید" ; - Inf => "بودن" ; - Root1 => "بود" ; - Root2 => "باش" ; - VF pol tense agr => - let impfSuff = imperfectSuffix agr ; - perfSuff = perfectSuffix agr - in case of { - => "است" ; - => "نیست" ; - => impfSuff "هست" ; - => impfSuff "نیست" ; - => perfSuff "بوده" ; - => perfSuff "نبوده" ; - => impfSuff "بود" ; - => impfSuff "نبود" ; - _ => mkCmnVF "بود" "باش" pol tense agr - } - } - } ; } diff --git a/src/persian/NounPes.gf b/src/persian/NounPes.gf index 4210cbcbf..47b08fe1a 100644 --- a/src/persian/NounPes.gf +++ b/src/persian/NounPes.gf @@ -23,7 +23,7 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in { } ; PPartNP np v2 = np ** { - s = \\ez => np.s ! ez ++ partNP (v2.s ! Root1) + s = \\ez => np.s ! ez ++ partNP v2 } ; RelNP np rs = np ** { diff --git a/src/persian/ParadigmsPes.gf b/src/persian/ParadigmsPes.gf index 196e638fb..667b5917c 100644 --- a/src/persian/ParadigmsPes.gf +++ b/src/persian/ParadigmsPes.gf @@ -24,6 +24,10 @@ oper singular : Number ; -- e.g. mkConj "یا" singular plural : Number ; -- e.g. mkConj "و" plural + VVForm : Type ; -- Argument to mkVV + subjunctive : VVForm ; -- The verbal complement of VV is in subjunctive + indicative : VVForm ; -- The verbal complement of VV is in indicative + --2 Nouns mkN : overload { @@ -88,6 +92,15 @@ oper = \s1, s2 -> lin V (mkVerb s1 s2) } ; + compoundV : overload { + compoundV : Str -> V -> V -- Invariable prefix to a verb, e.g. compoundV "دوست" haveVerb + } ; + + invarV : Str -> V -- no inflection at all + = \s -> lin V (M.invarV s); + defV : (inf,pres,past : Str) -> V -- no personal forms, but past/present difference, like بایستن ('must'), + = \i,pr,pa -> lin V (M.defectiveVerb i pr pa) ; + haveVerb : V -- The verb "have", to be used for light verb constructions: e.g. compoundV "دوست" haveVerb. NB. this has different imperative and VV forms from StructuralPes.have_V2. = lin V M.haveVerb ; beVerb : V -- The verb "be", to be used for light verb constructions: e.g. compoundV "عاشق" beVerb. @@ -99,20 +112,22 @@ oper mkV2 : (listen : V) -> (to : Prep) -> V2 -- V2 out of V. Use given preposition, no را for direct object. } ; - 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 = 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}) ; - --- compund verbs - compoundV : overload { - compoundV : Str -> V -> V -- Invariable prefix to a verb, e.g. compoundV "دوست" haveVerb + mkVV = overload { + mkVV : V -> VV -- takes its VP complement in subjunctive. Is auxiliary. + = \v -> v ** {isAux = True ; compl = subjunctive ; isDef = False} ; + mkVV : VVForm -> V -> VV -- takes its VP complement in the given VVForm + = \vvf,v -> v ** {isAux = True ; compl = vvf ; isDef = False} ; + mkVV : (isAux : Bool) -> VVForm -> V -> VV -- takes its VP complement in the given VVForm. Whether it's auxiliary (T/F) given as the first argument. + = \isAux,vvf,v -> v ** {isAux = isAux ; compl = vvf ; isDef = False} } ; - invarV : Str -> V -- for verbs like بایستن ('must'), which don't inflect - = \s -> lin V {s = \\_ => s} ; + mkV2V : V -> (cV, cN : Str) -> (isAux : Bool) -> V2V -- Verb, complementiser for the verb, complementiser for the noun, whether it's auxiliary. + = \v,s1,s2,b -> let vv : VV = mkVV b subjunctive v in + lin V2V (vv ** {c1 = s1 ; c2 = s2}) ; + ----2 Adverbs mkAdv : Str -> Adv -- Takes a string, returns an adverb. @@ -162,6 +177,10 @@ oper animate = human ; inanimate = nonhuman ; + VVForm = ResPes.VVForm ; + subjunctive = ResPes.Subj ; + indicative = Indic ; + -- Removed mkV_1, mkV_2, mkN01 and mkN02 from public API, still available for -- any applications that open ParadigmsPes. /IL 2019-02-08 mkV_1 : Str -> V @@ -240,9 +259,9 @@ oper compoundV = overload { compoundV : Str -> V -> V - = \s,v -> v ** {s = \\vf => s ++ v.s ! vf} ; + = \s,v -> v ** {prefix = s} ; compoundV : Str -> V2 -> V -- hidden from public API - = \s,v -> lin V {s = \\vf => s ++ v.s ! vf} ; + = \s,v -> lin V (v ** {prefix = s}) ; }; regV : Str -> V = \inf -> diff --git a/src/persian/ResPes.gf b/src/persian/ResPes.gf index 07f5a3191..d67e2ea74 100644 --- a/src/persian/ResPes.gf +++ b/src/persian/ResPes.gf @@ -55,22 +55,36 @@ resource ResPes = MorphoPes ** open Prelude,Predef in { ----------------------- --- Verb Phrase ----------------------- +param + VVForm = Indic | Subj ; oper - VPH : Type = { - s : VerbForm => Str ; + VV : Type = Verb ** { + isAux : Bool ; + compl : VVForm ; -- indicative or subjunctive + isDef : Bool -- defective verb forms don't get same inflection + } ; + + VPH : Type = Verb ** { 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. + vComp : Agr => Anteriority => 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 ; -- whether a VV has been added + defVV : Bool ; -- whether a defective VV has been added } ; - showVPH : VerbForm -> Agr -> VPH -> Str = \vf,agr,vp -> - vp.ad ++ vp.comp ! agr ++ vp.obj ++ vp.s ! vf ++ vp.vComp ! agr ++ vp.embComp ; + showVPH = overload { + showVPH : VerbForm -> Agr -> VPH -> Str = showVPH' Simul ; + showVPH : Anteriority -> VerbForm -> Agr -> VPH -> Str = showVPH' + } ; + + showVPH' : Anteriority -> VerbForm -> Agr -> VPH -> Str = + \ant,vf,agr,vp -> vp.ad ++ vp.comp ! agr ++ vp.obj + ++ vp.prefix ++ vp.s ! vf + ++ vp.vComp ! agr ! ant ++ vp.embComp ; Compl : Type = {s : Str ; ra : Str} ; @@ -93,9 +107,9 @@ oper ad, obj, embComp = []; - wish = False ; - comp, - vComp = \\_ => [] } ; + defVV = False ; + comp = \\_ => [] ; + vComp = \\_,_ => [] } ; predVc : (Verb ** {c2,c1 : Str}) -> VPHSlash = \verb -> predV verb ** {c2 = {s = verb.c1 ; ra = []} } ; @@ -116,9 +130,10 @@ oper 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?? + insertVV : Bool -> (Agr => Anteriority => Str) -> VPH -> VPH = + \isDef,infcl,vp -> vp ** { + defVV = True; --isDef ; + vComp = \\agr,ant => vp.vComp ! agr ! ant ++ infcl ! agr ! ant ; } ; embComp : Str -> VPH -> VPH = \str,vp -> vp ** { @@ -135,8 +150,14 @@ oper ---- AR 14/9/2017 trying to fix isAux = True case by inserting conjThat ---- but don't know yet how False should be affect - infVV : Bool -> VPH -> (Agr => Str) = \isAux,vp -> - \\agr => if_then_Str isAux conjThat [] ++ showVPH (Vvform agr) agr vp ; + infVV : VV -> VPH -> (Agr => Anteriority => Str) = \vv,vp -> + \\agr,ant => if_then_Str vv.isAux conjThat [] ++ + case of { + <_Simul,Subj> => showVPH (VSubj Pos agr) agr vp ; + <_Simul,Indic> => showVPH (VAor Pos agr) agr vp + -- TODO: confirm => showVPH PerfStem agr vp ++ subjAux Pos agr + } ; + insertAdV : Str -> VPH -> VPH = \ad,vp -> vp ** { ad = vp.ad ++ ad ; @@ -153,23 +174,32 @@ oper ---- AR 18/9/2017 intermediate SClause to preserve SOV in e.g. QuestionPes.QuestSlash clTable : VPH -> (Agr => VPHTense => Polarity => Str) = \vp -> - \\agr,vt,pol => case vt of { - TA Pres Simul => vp.s ! VF pol (VFPres PrImperf) agr ; - TA Pres Anter => vp.s ! VF pol (VFPres PrPerf) agr ; - TA Past Simul => vp.s ! VF pol (VFPast PstAorist) agr ; - TA Past Anter => vp.s ! VF pol (VFPast PstPerf) agr ; - TA Fut Simul => case vp.wish of { - True => vp.s ! VF pol (VFPres PrImperf) agr ; - False => vp.s ! VF pol (VFFut FtAorist) agr } ; - TA Fut Anter => case vp.wish of { - _True => vp.s ! VF pol (VFPres PrPerf) agr } ; - --False => vp.s ! VF pol (VFFut FtAorist) agr } ; -- verb form need to be confirmed - TA Cond Simul => vp.s ! VF pol (VFPast PstImperf) agr ; - TA Cond Anter => vp.s ! VF pol (VFPast PstImperf) agr ; -- verb form to be confirmed - VVVForm => vp.s ! Vvform agr ; -- AR 21/3/2018 - VRoot1 => vp.s ! Root1 {- ++ Predef.Bind ++ "ه" -} -- AR 22/3/2018 - - } ; + \\agr,vt,pol => vp.prefix ++ case vt of { + TA Pres Simul => vp.s ! ImpPrefix pol ++ vp.s ! VAor pol agr ; -- for reg. verbs, VAor pol is invariant and negation comes in ImpPrefix. + TA Pres Anter => vp.s ! VPerf pol agr ; + TA Past Simul => vp.s ! VPast pol agr ; + TA Past Anter => + case vp.defVV of { + True => vp.s ! ImpPrefix pol ++ vp.s ! VAor pol agr ; + False => vp.s ! PerfStem ++ pluperfAux pol agr } ; + TA Fut Simul => + case vp.defVV of { + True => vp.s ! ImpPrefix pol ++ vp.s ! VAor pol agr ; + False => futAux pol agr ++ vp.s ! PastStem + } ; -- PastStem is, despite the name, used for future too. /IL + TA Fut Anter => + case vp.defVV of { + True => vp.s ! VPerf pol agr ; + False => "خواسته" ++ pluperfAux pol agr ++ vp.s ! PastStem + } ; -- verb form need to be confirmed + TA Cond Simul => vp.s ! VSubj pol agr ; + TA Cond Anter => + case vp.defVV of { + True => vp.s ! VSubj pol agr ; + False => vp.s ! PerfStem ++ subjAux pol agr } ; -- verb form to be confirmed + VVVForm => vp.s ! VSubj Pos agr ; -- AR 21/3/2018 + VRoot1 => vp.s ! PastStem -- AR 22/3/2018 + } ; mkClause : NP -> VPH -> Clause = \np,vp -> let cls = mkSlClause np vp @@ -181,23 +211,34 @@ oper OQuest => "آیا" } ; 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 ++ vps ++ vp.vComp ! np.a ++ vp.embComp + let vps = clTable vp ! np.a ! vt ! b ; + ant = case vp.defVV of { + True => case vt of {TA Pres _ => Simul ; TA _ a => Anter ; _ => Simul} ; + False => Simul } + in vp.ad ++ vp.comp ! np.a ++ vp.obj ++ vps + ++ vp.vComp ! np.a ! ant ++ vp.embComp }; --Clause : Type = {s : VPHTense => Polarity => Order => Str} ; mkSClause : Str -> Agr -> VPH -> Clause = \subj,agr,vp -> { 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 ++ vps ++ vp.vComp ! agr ++ vp.embComp + quest = case ord of { ODir => [] ; OQuest => "آیا" } ; + ant = case vp.defVV of { + True => case vt of {TA Pres _ => Simul ; TA _ a => Anter ; _ => Simul} ; + False => Simul } + in quest ++ subj ++ vp.ad ++ vp.comp ! agr ++ vp.obj + ++ vps ++ vp.vComp ! agr ! ant ++ vp.embComp }; predProg : VPH -> VPH = \verb -> verb ** { s = \\vh => case vh of { - VF pol (VFPres PrImperf) agr => haveVerb.s ! VF Pos (VFPres PrImperf) agr ++ verb.s ! VF pol (VFPres PrImperf) agr ; - VF pol (VFPast PstAorist) agr => haveVerb.s ! VF Pos (VFPast PstAorist) agr ++ verb.s ! VF pol (VFPast PstAorist) agr ; - VF pol (VFPast PstImperf) agr => haveVerb.s ! VF Pos (VFPast PstAorist) agr ++ verb.s ! VF pol (VFPast PstImperf) agr ; + ImpPrefix _ => [] ; + VAor p a => haveVerb.s ! VAor Pos a ++ verb.s ! ImpPrefix p ++ verb.s ! VAor Pos a ; + VPast p a => haveVerb.s ! VPast Pos a ++ verb.s ! ImpPrefix p ++ verb.s ! VPast Pos a ; -- negation in ImpPrefix + -- VF pol (VFPres PrImperf) agr => haveVerb.s ! VF Pos (VFPres PrImperf) agr ++ verb.s ! VF pol (VFPres PrImperf) agr ; + -- VF pol (VFPast PstAorist) agr => haveVerb.s ! VF Pos (VFPast PstAorist) agr ++ verb.s ! VF pol (VFPast PstAorist) agr ; + -- VF pol (VFPast PstImperf) agr => haveVerb.s ! VF Pos (VFPast PstAorist) agr ++ verb.s ! VF pol (VFPast PstImperf) agr ; _ => verb.s ! vh } ; subj = VIntrans } ; @@ -211,7 +252,7 @@ oper -- Noun Phrase ----------------------------- - partNP : Str -> Str = \str -> (Prelude.glue str "ه") ++ "شده" ; + partNP : Verb -> Str = \v -> v.prefix ++ v.s ! PerfStem ++ "شده" ; ----------------------------------- -- Reflexive Pronouns diff --git a/src/persian/SentencePes.gf b/src/persian/SentencePes.gf index 7c66da7a7..a82ace94f 100644 --- a/src/persian/SentencePes.gf +++ b/src/persian/SentencePes.gf @@ -12,9 +12,9 @@ concrete SentencePes of Sentence = CatPes ** open Prelude, ResPes,Predef in { ImpVP vp = { s = \\pol,n => let agr = Ag (numImp n) P2 ; - in case vp.wish of { - True => vp.s ! Imp 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 ! Imp pol (numImp n) ++ vp.embComp } + in case vp.defVV of { + True => vp.s ! VImp pol (numImp n) ++ vp.ad ++ vp.comp ! agr ++ vp.obj ++ vp.vComp ! agr ! Simul ++ vp.embComp; + False => vp.ad ++ vp.comp ! agr ++ vp.obj ++ vp.vComp ! agr ! Simul ++ vp.s ! VImp pol (numImp n) ++ vp.embComp } } ; SlashVP np vp = @@ -59,6 +59,6 @@ concrete SentencePes of Sentence = CatPes ** open Prelude, ResPes,Predef in { AdvS a s = {s = a.s ++ s.s} ; RelS s r = {s = s.s ++ r.s ! agrP3 Sg} ; - SSubjS s sj s = { s = s.s ++ sj.s ++ s.s}; + SSubjS s1 sj s2 = { s = s1.s ++ sj.s ++ s2.s}; } diff --git a/src/persian/StructuralPes.gf b/src/persian/StructuralPes.gf index f63704ed9..e3f880fb9 100644 --- a/src/persian/StructuralPes.gf +++ b/src/persian/StructuralPes.gf @@ -21,7 +21,7 @@ concrete StructuralPes of Structural = CatPes ** by8agent_Prep = ss "توسط" ; by8means_Prep = ss "با" ; -- can8know_VV,can_VV = mkV "سکن" ** { isAux = True} ; - can_VV = mkV_1 " توانستن " ** { isAux = True} ; ---- AR + can_VV = mkVV (mkV_1 "توانستن") ; ---- AR during_Prep = ss ["در طول"] ; either7or_DConj = sd2 "یا" "یا" ** {n = Sg} ; -- everybody_NP = MassNP (UseN (MorphoPnb.mkN11 ["هر کwی"])); -- not a good way coz need to include NounPnb @@ -49,29 +49,16 @@ concrete StructuralPes of Structural = CatPes ** more_CAdv = {s = "بیشتر" ; p = "" } ; most_Predet = ss "اکثر"; much_Det = mkDet ["مقدار زیادی"] Pl ; - must_VV = invarV " بایستن " ** {isAux = True} ; ---- AR --- must_VV = { --- s = table { --- VVF VInf => ["هوe تْ"] ; --- VVF VPres => "مست" ; --- VVF VPPart => ["هد تْ"] ; --- VVF VPresPart => ["هونگ تْ"] ; --- VVF VPast => ["هد تْ"] ; --# notpresent --- VVPastNeg => ["هدn'ت تْ"] ; --# notpresent --- VVPresNeg => "مستn'ت" --- } ; --- isAux = True --- } ; ------b no_Phr = ss "نْ" ; - - + must_VV = + let must_V : V = defV "بایستن" "باید" "بایست" ; + in mkVV must_V ; + -- TODO: ** {isDef=True} ; past tense forms with مجبور+beVerb no_Utt = ss "نه" ; on_Prep = ss "روی" ; --- one_Quant = demoPN "یک" ; -- DEPRECATED only_Predet = ss "فقط" ; or_Conj = sd2 [] "یا" ** {n = Sg} ; otherwise_PConj = ss ["درغیراین صورت"] ; - part_Prep = ss "از" ; -- the object following it should be in Ezafa form + part_Prep = ss "از" ; -- TODO: the object following it should be in Ezafa form please_Voc = ss "لطفاً" ; possess_Prep = ss "" ; -- will be handeled in Ezafeh quite_Adv = ss "کاملاً" ; @@ -95,7 +82,7 @@ concrete StructuralPes of Structural = CatPes ** to_Prep = ss "به" ** {lock_Prep = <>}; under_Prep = ss "زیر" ** {lock_Prep = <>}; very_AdA = ss "خیلی" ; - want_VV = mkV "خواستن" "خواه" ** { isAux = False} ; + want_VV = mkVV False subjunctive (mkV "خواستن" "خواه") ; --not aux we_Pron = personalPron "ما" "مان" Pl P1 ; whatSg_IP = {s = ["چه چیزی"] ; n = Sg } ; whatPl_IP = {s = ["چه چیزهایی"] ; n = Pl } ; @@ -136,16 +123,16 @@ concrete StructuralPes of Structural = CatPes ** -- MorphoPes.haveVerb: "have" as auxiliary. have_V2 = haveVerb ** { s = table { - R.Imp Pos Sg => "داشته باش" ; - R.Imp Pos Pl => "داشته باشید" ; - R.Imp Neg Sg => "نداشته باش" ; - R.Imp Neg Pl => "نداشته باشید" ; - Vvform (Ag Sg P1) => "داشته باشم" ; - Vvform (Ag Sg P2) => "داشته باشی" ; - Vvform (Ag Sg P3) => "داشته باشد" ; - Vvform (Ag Pl P1) => "داشته باشیم" ; - Vvform (Ag Pl P2) => "داشته باشید" ; - Vvform (Ag Pl P3) => "داشته باشند" ; + VImp Pos Sg => "داشته باش" ; + VImp Pos Pl => "داشته باشید" ; + VImp Neg Sg => "نداشته باش" ; + VImp Neg Pl => "نداشته باشید" ; + VSubj _ (Ag Sg P1) => "داشته باشم" ; + VSubj _ (Ag Sg P2) => "داشته باشی" ; + VSubj _ (Ag Sg P3) => "داشته باشد" ; + VSubj _ (Ag Pl P1) => "داشته باشیم" ; + VSubj _ (Ag Pl P2) => "داشته باشید" ; + VSubj _ (Ag Pl P3) => "داشته باشند" ; x => haveVerb.s ! x } ; c2 = { s = [] ; diff --git a/src/persian/VerbPes.gf b/src/persian/VerbPes.gf index afa86db2d..beb5d55e6 100644 --- a/src/persian/VerbPes.gf +++ b/src/persian/VerbPes.gf @@ -14,20 +14,20 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in { ComplSlash = complSlash ; - ComplVV v vp = insertVV (infVV v.isAux vp) (predV v) ; + ComplVV v vp = insertVV v.isDef (infVV v 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 = 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 = []}} ; + SlashV2V v vp = insertVV v.isDef (infVV v vp) (predV v) **{c2 = {s = v.c1 ; ra = []}} ; SlashV2S v s = v ** embComp (conjThat ++ s.s) (predV v) ; SlashV2Q v q = v ** embComp (q.s ! QIndir) (predV v) ; SlashV2A v ap = v ** insertObj (ap.s ! Bare) (predV v) ; ---- paint it red , check form of adjective - SlashVV vv vps = vps ** insertVV (infVV vv.isAux vps) (predV vv) ; + SlashVV vv vps = vps ** insertVV vv.isDef (infVV vv vps) (predV vv) ; SlashV2VNP v2v np vps = - let vvVP : VPH = insertVV (infVV v2v.isAux vps) (predV v2v) ; + let vvVP : VPH = insertVV v2v.isDef (infVV v2v vps) (predV v2v) ; 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} ; From 51eb1dbb1a0da6edc79af7415c16945b588bea11 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 26 Feb 2019 16:59:26 +0100 Subject: [PATCH 2/2] (Pes) WIP vowels for TTS support Vowels are in Str variables, if you want vowels, only change the value of the variable in one place. Default value is empty string. --- src/persian/MorphoPes.gf | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/persian/MorphoPes.gf b/src/persian/MorphoPes.gf index dff9b2bbe..5a9d26a44 100644 --- a/src/persian/MorphoPes.gf +++ b/src/persian/MorphoPes.gf @@ -21,6 +21,11 @@ oper ZWNJ : Str = "‌" ; zwnj : Str -> Str -> Str = \s1,s2 -> s1 + ZWNJ + s2 ; + -- kasre : Str = "ِ" ; -- To enable vowels for TTS input + -- fatha : Str = "َ" ; + kasre,fatha : Str = [] ; + + ---- Nouns param Animacy = Animate | Inanimate ; @@ -55,21 +60,17 @@ oper oper -mkPossStem : Str -> Str = \str -> - - case str of { -_+ "اه" => str ; -_+ "او" => str ; -_+ "وه" => str ; -_+ ("ا"|"و") => str + "ی" ; -_+ "ه" => zwnj str "ا" ; -_ => str } ; + mkPossStem : Str -> Str = \str -> + case str of { + _ + ("اه"|"او"|"وه") + => str + fatha ; + _ + ("ا"|"و") => str + fatha + "ی" ; + _ + "ه" => zwnj str "ا" ; + _ => str + fatha } ; mkEzafe : Str -> Str = \str -> - --let kasre = "ِ" in -- TODO: Eventually use this - let kasre = "" in case str of { st + "اه" => str + kasre ; st + "وه" => str + kasre ;