From 267ef1b178880d37c7eae93322a080c4cfbc9b7d Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 29 Jan 2019 14:11:05 +0100 Subject: [PATCH 1/5] (Ara) Move mkQuant functions from Paradigms to Res --- src/arabic/ParadigmsAra.gf | 28 ++++------------------------ src/arabic/ResAra.gf | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/arabic/ParadigmsAra.gf b/src/arabic/ParadigmsAra.gf index 93c44e2e..c8e6b525 100644 --- a/src/arabic/ParadigmsAra.gf +++ b/src/arabic/ParadigmsAra.gf @@ -657,32 +657,12 @@ resource ParadigmsAra = open mkQuant7 : (_,_,_,_,_,_,_ : Str) -> State -> Quant = - \hava,havihi,havAn,havayn,hAtAn,hAtayn,hA'ulA,det -> lin Quant (baseQuant ** - { s = \\n,s,g,c => - case of { - <_,Masc,_,Sg> => hava; - <_,Fem,_,Sg> => havihi; - <_,Masc,Nom,Dl>=> havAn; - <_,Masc,_,Dl> => havayn; - <_,Fem,Nom,Dl> => hAtAn; - <_,Fem,_,Dl> => hAtayn; - => hA'ulA; - _ => havihi - }; - d = det - }); + \hava,havihi,havAn,havayn,hAtAn,hAtayn,hA'ulA,det -> + lin Quant (ResAra.mkQuant7 hava havihi havAn havayn hAtAn hAtayn hA'ulA det) ; mkQuant3 : (_,_,_ : Str) -> State -> Quant = - \dalika,tilka,ula'ika,det -> lin Quant (baseQuant ** - { s = \\n,s,g,c => - case of { - <_,Masc,_,Sg> => dalika; - <_,Fem,_,Sg> => tilka; - => ula'ika; - _ => tilka - }; - d = det - }); + \dalika,tilka,ula'ika,det -> + lin Quant (ResAra.mkQuant3 dalika tilka ula'ika det) ; brkA : (root,sg,pl : Str) -> Adj -- also broken feminine = brkABool False ; diff --git a/src/arabic/ResAra.gf b/src/arabic/ResAra.gf index 64846940..91445056 100644 --- a/src/arabic/ResAra.gf +++ b/src/arabic/ResAra.gf @@ -61,6 +61,34 @@ oper is1sg : Agr -> Bool = \a -> case a.pgn of {Per1 Sing => True; _ => False} ; + mkQuant7 : (_,_,_,_,_,_,_ : Str) -> State -> Quant = + \hava,havihi,havAn,havayn,hAtAn,hAtayn,hA'ulA,det -> lin Quant (baseQuant ** + { s = \\n,s,g,c => + case of { + <_,Masc,_,Sg> => hava; + <_,Fem,_,Sg> => havihi; + <_,Masc,Nom,Dl>=> havAn; + <_,Masc,_,Dl> => havayn; + <_,Fem,Nom,Dl> => hAtAn; + <_,Fem,_,Dl> => hAtayn; + => hA'ulA; + _ => havihi + }; + d = det + }); + + mkQuant3 : (_,_,_ : Str) -> State -> Quant = + \dalika,tilka,ula'ika,det -> lin Quant (baseQuant ** + { s = \\n,s,g,c => + case of { + <_,Masc,_,Sg> => dalika; + <_,Fem,_,Sg> => tilka; + => ula'ika; + _ => tilka + }; + d = det + }); + mkDet = overload { mkDet : Str -> Number -> State -> Det = mkDetDecl True ; From 08c0b3fe5400a629b90e31249cc4441e5dee6911 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 29 Jan 2019 15:46:59 +0100 Subject: [PATCH 2/5] (Ara) Fixes in DetNP + some Dets and Quants --- src/arabic/NounAra.gf | 11 +++++++++-- src/arabic/ResAra.gf | 3 +++ src/arabic/StructuralAra.gf | 11 ++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/arabic/NounAra.gf b/src/arabic/NounAra.gf index 63ca7065..108f09bf 100644 --- a/src/arabic/NounAra.gf +++ b/src/arabic/NounAra.gf @@ -47,7 +47,14 @@ lin UsePron p = p ; - DetNP det = emptyNP ** {s = det.s ! NoHum ! Masc} ; ---- + DetNP det = case det.isEmpty of { + True => case of { -- if the s field is empty, make up some other determiner + => he_Pron ; + => theyMasc_Pron ; + => emptyNP ** {s = someSg_Det.s ! NoHum ! Masc} ; + _ => emptyNP ** {s = somePl_Det.s ! NoHum ! Masc} + } ; + False => emptyNP ** {s = det.s ! NoHum ! Masc} } ; PredetNP det np = np ** { s = \\c => case det.isDecl of { @@ -75,7 +82,7 @@ lin DetQuantOrd quant num ord = quant ** { s = \\h,g,c => let d = toDef quant.d num.n in - quant.s ! Pl ! h ! g ! c + quant.s ! Pl ! h ! g ! c -- TODO what is this Pl? Was there when I started /IL ++ num.s ! g ! d ! c --FIXME check this: ++ ord.s ! g diff --git a/src/arabic/ResAra.gf b/src/arabic/ResAra.gf index 91445056..37cad39e 100644 --- a/src/arabic/ResAra.gf +++ b/src/arabic/ResAra.gf @@ -61,6 +61,9 @@ oper is1sg : Agr -> Bool = \a -> case a.pgn of {Per1 Sing => True; _ => False} ; + someSg_Det = mkDet "أَحَد" Sg Const ; + somePl_Det = mkDet "بَعض" Pl Const ; + mkQuant7 : (_,_,_,_,_,_,_ : Str) -> State -> Quant = \hava,havihi,havAn,havayn,hAtAn,hAtayn,hA'ulA,det -> lin Quant (baseQuant ** { s = \\n,s,g,c => diff --git a/src/arabic/StructuralAra.gf b/src/arabic/StructuralAra.gf index e419ae53..8eb4cd31 100644 --- a/src/arabic/StructuralAra.gf +++ b/src/arabic/StructuralAra.gf @@ -1,5 +1,5 @@ concrete StructuralAra of Structural = CatAra ** - open MorphoAra, ResAra, ParadigmsAra, Prelude in { + open MorphoAra, ResAra, ParadigmsAra, (N=NounAra), Prelude in { flags optimize=all ; coding=utf8 ; @@ -47,10 +47,11 @@ concrete StructuralAra of Structural = CatAra ** } ; -- IL how8much_IAdv = ss "كَمْ" ; if_Subj = mkSubj "إِذَا" Verbal ; + --whether_Subj = mkSubj "مَا إِذَا" Verbal ; in8front_Prep = mkPrep "مُقَابِلَ" ; i_Pron = ResAra.i_Pron ; in_Prep = mkPrep "فِي" ; - it_Pron = emptyNP ** {s = \\_ => "هَذَا"} ; -- was: it_Pron = mkPron "ِت" "ِت" "ِتس" (Per3 Masc Sg); + it_Pron = N.DetNP (N.DetQuant this_Quant N.NumSg) ; -- was: it_Pron = mkPron "ِت" "ِت" "ِتس" (Per3 Masc Sg); -- less_CAdv = ss "لسّ" ; many_Det = mkDet "جَمِيع" Pl Const ; -- more_CAdv = ss "مْري" ; @@ -74,8 +75,8 @@ concrete StructuralAra of Structural = CatAra ** she_Pron = ResAra.she_Pron ; so_AdA = very_AdA ; somebody_NP = regNP "أَحَد" Sg Indef ; - someSg_Det = mkDet "أَحَد" Sg Const ; - somePl_Det = mkDet "بَعض" Pl Const ; + someSg_Det = ResAra.someSg_Det ; + somePl_Det = ResAra.somePl_Det ; something_NP = regNP "شَيْء" Sg Indef ; -- somewhere_Adv = ss "سْموهري" ; that_Quant = mkQuant3 "ذَلِكَ" "تِلكَ" "أُلٱِكَ" Def; @@ -87,7 +88,7 @@ concrete StructuralAra of Structural = CatAra ** -- therefore_PConj = ss "تهرفْري" ; ----b these_NP = indeclNP "هَؤُلَاء" Pl ; they_Pron = theyMasc_Pron ; - this_Quant = mkQuant7 "هَذا" "هَذِهِ" "هَذَان" "هَذَيْن" "هَاتَان" "هَاتَيْن" "هَؤُلَاء" Def; + this_Quant = mkQuant7 "هَذا" "هَذِهِ" "هَذَان" "هَذَيْن" "هَاتَان" "هَاتَيْن" "هَؤُلَاء" Def ; ----b this_NP = indeclNP "هَذا" Sg ; ----b those_NP = indeclNP "هَؤُلَاءكَ" Pl ; through_Prep = mkPrep "عَبْرَ" ; From ac5352f852761fe685ea2c166927273453b26c71 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 29 Jan 2019 17:54:44 +0100 Subject: [PATCH 3/5] (Ara) Replace two 2-valued params in VP with one 3-valued param. * is copula / is have_V2 / is neither There is no difference; all three options are is mutually exclusive. There 2 params in the first place only by accident. First one was added by AED 10 years agon, second by me only some weeks ago, without thinking that the params are mutually exclusive. Also tested with gftest, no difference found after 2 hours of running. --- src/arabic/IdiomAra.gf | 2 +- src/arabic/QuestionAra.gf | 2 +- src/arabic/ResAra.gf | 56 ++++++++++++++++++++++----------------- src/arabic/VerbAra.gf | 8 +++--- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/arabic/IdiomAra.gf b/src/arabic/IdiomAra.gf index 884763b5..3a2117f1 100644 --- a/src/arabic/IdiomAra.gf +++ b/src/arabic/IdiomAra.gf @@ -25,7 +25,7 @@ concrete IdiomAra of Idiom = CatAra ** open CleftAdv adv s = let comp : Comp = CompAdv (lin Adv {s = adv.s ++ s.s ! Verbal}) ; -- no idea about word order /IL pass_V = mkV "مضي" va vi ; -- switch to copula or some other verb if better /IL - in predVP emptyNP (UseV pass_V ** {isPred=True ; pred=comp}) ; -- very hacky /IL + in predVP emptyNP (UseV pass_V ** {vtype=Copula ; pred=comp}) ; -- very hacky /IL -- : NP -> Cl ; -- there is a house ExistNP np = diff --git a/src/arabic/QuestionAra.gf b/src/arabic/QuestionAra.gf index 3a418fa6..73ab0664 100644 --- a/src/arabic/QuestionAra.gf +++ b/src/arabic/QuestionAra.gf @@ -14,7 +14,7 @@ lin -- : IP -> VP -> QCl ; -- who walks QuestVP qp vp = - let np = ip2np qp vp.isPred ; + let np = ip2np qp (case vp.vtype of {Copula=>True ; _=>False}) ; cl = PredVP np vp ; in { s = \\t,p,qf => cl.s ! t ! p ! toOrder qf } ; diff --git a/src/arabic/ResAra.gf b/src/arabic/ResAra.gf index 37cad39e..62164573 100644 --- a/src/arabic/ResAra.gf +++ b/src/arabic/ResAra.gf @@ -469,19 +469,25 @@ param | VPImp | VPGer ; + VType = -- indicates if there is a predicate (xabar): + Copula -- 1) disappears in equational sentences + -- 2) its argument ('xabar') is in the pred field + -- 3) it is negated with laysa + | Have -- stays in eq. sentence, argument is in obj field, but is negated with laysa. + | NotPred ; -- any other verb but copula and have_V2 + oper BaseVP : Type = { -- to minimise duplication of code for VPS sc : Preposition ; -- subject case: e.g. يُمْكِنُ *لِ*Xِ obj : Obj; pred : Comp; - isPred : Bool; -- indicates if there is a predicate (xabar) + vtype : VType ; -- copula, have_V2 or normal verb s2 : Str } ; VP : Type = BaseVP ** { s : PerGenNum => VPForm => Str ; - isPoss : Bool; -- special case for have_V2, to get negation right /IL } ; uttVP : VPForm -> VP -> (Gender=>Str) = \vpf,vp -> @@ -502,7 +508,7 @@ oper obj = emptyObj ; s2 = []; pred = {s = \\_,_ => []} ; - isPred,isPoss = False + vtype = NotPred }; passPredV : Verb -> VP = \v -> @@ -543,18 +549,18 @@ oper bindIf : Bool -> Str = \b -> if_then_Str b BIND [] ; - bindIfPron : NP -> {c2:Preposition; isPred:Bool} -> Str = \np,vp -> + bindIfPron : NP -> {c2:Preposition; vtype:VType} -> Str = \np,vp -> let notNom : Case -> Bool = \c -> case c of {Nom => False; _=>True} ; - bind = case vp.isPred of { - False => bindIf ( - orB (andB np.a.isPron (notNom vp.c2.c)) --if np is pron, not in nominative - vp.c2.binds) ; - True => [] } + bind = case vp.vtype of { + Copula => [] ; + _ => bindIf (orB (andB np.a.isPron (notNom vp.c2.c)) --if np is pron, not in nominative + vp.c2.binds) + } in vp.c2.s ++ bind ++ np.s ! vp.c2.c ; insertPred : Comp -> VP -> VP = \p,vp -> vp ** { pred = p; - isPred = True + vtype = Copula }; insertStr : Str -> VP -> VP = \str,vp -> vp ** @@ -584,9 +590,9 @@ oper _ => vp.sc } } ; subj = np.empty ++ sc.s ++ bindIf sc.binds - ++ case vp.isPred of { - False => (proDrop np).s ! sc.c ; -- prodrop if it's not predicative - True => np.s ! sc.c + ++ case vp.vtype of { + Copula => np.s ! sc.c ; + _ => (proDrop np).s ! sc.c -- prodrop if it's not predicative } ; in wordOrder o vp.obj.a.isPron np.a.isPron np.isHeavy @@ -631,9 +637,9 @@ oper pred : VP -> PerGenNum -> ParamX.Tense -> Polarity -> Str = \vp,pgn,tn,pl -> let gn = pgn2gn pgn - in case of { - => vp.pred.s ! gn ! Nom; --xabar marfooc - _ => vp.pred.s ! gn ! Acc --xabar kaana wa laysa manSoob + in case of { + => vp.pred.s ! gn ! Nom; --xabar marfooc + _ => vp.pred.s ! gn ! Acc --xabar kaana wa laysa manSoob } ; vStr : VP -> PerGenNum -> ParamX.Tense -> Polarity -> Order -> Str = \vp,pgn,tn,pl,o -> @@ -646,12 +652,12 @@ oper lam = "لَمْ" ; -- neg. past alla = "أَلَّا" ; -- neg. subjunctive lan = "لَنْ" ; -- neg. future - in case of { - => laysa ! Per3 Masc Sg ++ yaktubu ; -- special case for have_V2 - => yaktubu ; - => la ++ yaktubu ; - => [] ; --no verb "to be" in present - => laysa ! pgn ; -- negative copula + in case of { + => laysa ! Per3 Masc Sg ++ yaktubu ; -- special case for have_V2 + => [] ; --no verb "to be" in present + => laysa ! pgn ; -- negative copula + <_, Pres, Pos, _> => yaktubu ; + <_, Pres, Neg, _> => la ++ yaktubu ; <_, Past, Pos, _> => kataba ; <_, Past, Neg, _> => lam ++ yaktub ; <_, Cond, Pos, _> => yaktuba ; @@ -682,9 +688,9 @@ oper slashV2 : Verb2 -> VPSlash = \v -> predV v ** { c2 = v.c2 ; agrObj = \\_ => [] ; - isPoss = case v.c2.c of { - Nom => True ; -- for have_V2 - _ => False } ; + vtype = case v.c2.c of { + Nom => Have ; -- for have_V2 + _ => NotPred } ; } ; -- Add subject string, fix agreement to the subject, diff --git a/src/arabic/VerbAra.gf b/src/arabic/VerbAra.gf index d170a9a0..e2b198e3 100644 --- a/src/arabic/VerbAra.gf +++ b/src/arabic/VerbAra.gf @@ -16,7 +16,7 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra, ParamX in { ++ vp.s ! pgn ! VPImpf Cnj -- this will agree with the object added by ComplSlash ++ vp.obj.s ; obj = emptyObj ; - isPred = False ; + vtype = NotPred ; c2 = v2v.c2 ; -- preposition for the direct object sc = v2v.sc } ; @@ -30,7 +30,7 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra, ParamX in { ++ vps.s ! np.a.pgn ! VPImpf Cnj -- verb from old VP agrees with object ++ vps.obj.s ; -- otherwise obj appears in a weird place /IL obj = emptyObj ; - isPred = False ; + vtype = NotPred ; -- preposition for the direct object comes from VP sc = v2v.sc } ; @@ -68,7 +68,7 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra, ParamX in { s = \\pgn,vpf => vvVP.s ! pgn ! vpf ++ vv.s2 -- أَنْ ++ vp.s ! pgn ! VPImpf Cnj ; - isPred = False ; + vtype = NotPred ; sc = vv.sc } ; @@ -92,7 +92,7 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra, ParamX in { UseComp xabar = case xabar.isNP of { False => kaan xabar ; - True => predV copula ** {obj = xabar.obj ; isPred=True} + True => predV copula ** {obj = xabar.obj ; vtype=Copula} } ; UseCopula = predV copula ; From e468b48ded21ca9e91a5f687576a902c02d2ca2a Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 29 Jan 2019 17:57:21 +0100 Subject: [PATCH 4/5] (Ara) Fix the corner case where ReflVP is called after VPSlashPrep. Also fix noPrep to accPrep (the default object case). Tested with gftest -o, only changes were in combinations of ReflVP and VPSlashPrep. --- src/arabic/VerbAra.gf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/arabic/VerbAra.gf b/src/arabic/VerbAra.gf index e2b198e3..e0fd3d0e 100644 --- a/src/arabic/VerbAra.gf +++ b/src/arabic/VerbAra.gf @@ -111,9 +111,11 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra, ParamX in { -- : VPSlash -> VP ; -- love himself ReflVP vps = vps ** { s = \\pgn,vf => vps.s ! pgn ! vf + ++ vps.obj.s -- only relevant if the VPSlash has been through VPSlashPrep ++ vps.c2.s ++ bindIf vps.c2.binds ++ reflPron vps.c2.c pgn ; - c2 = noPrep + c2 = accPrep ; + obj = emptyObj ; -- because old obj was moved in s } ; PassV2 = passPredV ; From 7cdcc0931f91a240d995b8cc30a4af834928a443 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 29 Jan 2019 17:57:38 +0100 Subject: [PATCH 5/5] (Ara) Small typofix + add comment --- src/arabic/StructuralAra.gf | 2 +- src/arabic/VerbAra.gf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arabic/StructuralAra.gf b/src/arabic/StructuralAra.gf index 8eb4cd31..744af228 100644 --- a/src/arabic/StructuralAra.gf +++ b/src/arabic/StructuralAra.gf @@ -88,7 +88,7 @@ concrete StructuralAra of Structural = CatAra ** -- therefore_PConj = ss "تهرفْري" ; ----b these_NP = indeclNP "هَؤُلَاء" Pl ; they_Pron = theyMasc_Pron ; - this_Quant = mkQuant7 "هَذا" "هَذِهِ" "هَذَان" "هَذَيْن" "هَاتَان" "هَاتَيْن" "هَؤُلَاء" Def ; + this_Quant = mkQuant7 "هَذَا" "هَذِهِ" "هَذَان" "هَذَيْن" "هَاتَان" "هَاتَيْن" "هَؤُلَاء" Def ; ----b this_NP = indeclNP "هَذا" Sg ; ----b those_NP = indeclNP "هَؤُلَاءكَ" Pl ; through_Prep = mkPrep "عَبْرَ" ; diff --git a/src/arabic/VerbAra.gf b/src/arabic/VerbAra.gf index e0fd3d0e..9eb5b165 100644 --- a/src/arabic/VerbAra.gf +++ b/src/arabic/VerbAra.gf @@ -100,7 +100,7 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra, ParamX in { -- : VP -> Prep -> VPSlash ; -- live in (it) VPSlashPrep vp prep = vp ** { c2 = prep ; - agrObj = \\_ => [] + agrObj = \\_ => [] -- to make it into VPSlash, VP didn't have that field before } ; AdvVP vp adv = insertStr adv.s vp ;