From b33d260377d55ce934b6c19db253a61fd929f47e Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 16 Oct 2018 17:46:28 +0200 Subject: [PATCH 1/3] (Ara) Add NP field to CN for apposition, to attach poss.suff. correctly --- src/arabic/CatAra.gf | 2 +- src/arabic/NounAra.gf | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/arabic/CatAra.gf b/src/arabic/CatAra.gf index 2dbc2278a..ac01f54e3 100644 --- a/src/arabic/CatAra.gf +++ b/src/arabic/CatAra.gf @@ -47,7 +47,7 @@ concrete CatAra of Cat = CommonX - [Utt] ** open ResAra, Prelude, ParamX in { -- Noun - CN = ResAra.Noun ** {adj : NTable}; + CN = ResAra.Noun ** {adj : NTable ; np : Case => Str}; NP, Pron = ResAra.NP; --{s : Case => Str ; a : Agr } ; Num, Ord, diff --git a/src/arabic/NounAra.gf b/src/arabic/NounAra.gf index f383f1806..b7cc77d2f 100644 --- a/src/arabic/NounAra.gf +++ b/src/arabic/NounAra.gf @@ -169,7 +169,9 @@ lin -- isNum = False; isPron = False} ; UseN, - UseN2 = \n -> n ** {adj = \\_,_,_ => []}; + UseN2 = \n -> n ** { + adj = \\_,_,_ => []; + np = \\_ => []}; Use2N3 n3 = n3 ; Use3N3 n3 = n3 ** {c2 = n3.c3} ; @@ -179,16 +181,12 @@ lin ComplN3 n3 np = ComplN2 n3 np ** {c2 = n3.c3} ; - AdjCN ap cn = { - s = \\n,d,c => cn.s ! n ! d ! c; - adj = \\n,d,c => ap.s ! cn.h ! cn.g ! n ! (definite ! d) ! c ; - g = cn.g; - h = cn.h + AdjCN ap cn = cn ** { + adj = \\n,d,c => ap.s ! cn.h ! cn.g ! n ! (definite ! d) ! c }; -- RelCN cn rs = {s = \\n,c => cn.s ! n ! c ++ rs.s ! {n = n ; p = P3}} ; -- AdvCN cn ad = {s = \\n,c => cn.s ! n ! c ++ ad.s} ; -- -- SentCN cn sc = {s = \\n,c => cn.s ! n ! c ++ sc.s} ; - ApposCN cn np = cn ** { - s = \\n,d,c => cn.s ! n ! d ! c ++ np.s ! c } ; + ApposCN cn np = cn ** { np = np.s } ; } From 5f39c419882e81e050e35b2327e7414948e9b798 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 16 Oct 2018 17:47:14 +0200 Subject: [PATCH 2/3] (Ara) Fixes to a few fords --- src/arabic/LexiconAra.gf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arabic/LexiconAra.gf b/src/arabic/LexiconAra.gf index f8f2a5b2f..f6248048a 100644 --- a/src/arabic/LexiconAra.gf +++ b/src/arabic/LexiconAra.gf @@ -234,7 +234,7 @@ flags write_V2 = dirV2 (regV "يَكتُب") ; -- write_V2 = dirV2 (v1 "كتب" a u) ; yellow_A = clrA "صفر" ; - young_A = sndA "شبّ" "فاعّ" ; + young_A = sndA "شبب" "فاعّ" ; do_V2 = dirV2 (regV "يَفعَل") ; -- do_V2 = dirV2 (v1 "فعل" a a ) ; @@ -287,7 +287,7 @@ flags fingernail_N = brkN "ظفر" "فُعل" "أَفاعِل" Masc NoHum; fire_N = brkN "نور" "فاع" "فِيعان" Fem NoHum; flower_N = brkN "زهر" "فَعلة" "فُعُول" Fem NoHum; - fog_N = brkN "ضبّ" "فَعال" "فَعال" Masc NoHum; --no plural ? + fog_N = brkN "ضبب" "فَعال" "فَعال" Masc NoHum; --no plural ? foot_N = brkN "قدم" "فَعَل" "أَفعال" Fem NoHum; forest_N = sdfN "غيب" "فاعة" Fem NoHum; grass_N = brkN "عشب" "فُعلة" "أَفعال" Fem NoHum; @@ -305,7 +305,7 @@ flags liver_N = brkN "كبد" "فَعِل" "أَفعال" Masc NoHum ; louse_N = sdfN "قمل" "فَعلة" Fem NoHum; mouth_N = brkN "فوه" "فُعل" "أَفعال" Masc NoHum ; - name_N = brkN "؟سم" "فِعل" "فَعالِي" Masc NoHum; + name_N = brkN "ءسم" "فِعل" "فَعالِي" Masc NoHum; neck_N = brkN "رقب" "فَعَلة" "فِعال" Fem NoHum; night_N = brkN "ليل" "فَعلة" "فَعالِي" Fem NoHum; --plural? nose_N = brkN "؟نف" "فَعل" "فُعُول" Masc NoHum; From f5525dfbf090cd338c46160cebb82e7e2c621ce3 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 16 Oct 2018 17:47:35 +0200 Subject: [PATCH 3/3] (Ara) Supporting possessive suffixes, WIP --- src/arabic/CatAra.gf | 5 +- src/arabic/MorphoAra.gf | 12 +--- src/arabic/NounAra.gf | 49 ++++++++------- src/arabic/ParadigmsAra.gf | 22 +++---- src/arabic/ResAra.gf | 122 +++++++++++++++++++++--------------- src/arabic/StructuralAra.gf | 1 + 6 files changed, 110 insertions(+), 101 deletions(-) diff --git a/src/arabic/CatAra.gf b/src/arabic/CatAra.gf index ac01f54e3..759e0fd5b 100644 --- a/src/arabic/CatAra.gf +++ b/src/arabic/CatAra.gf @@ -57,10 +57,7 @@ concrete CatAra of Cat = CommonX - [Utt] ** open ResAra, Prelude, ParamX in { Det = ResAra.Det ; -- {s : Species => Gender => Case => Str ; -- d : State; n : Size; isNum : Bool } ; - Quant = {s : ResAra.Number => Species => Gender => Case => Str; - d : State; - isNum : Bool; - isPron: Bool} ; + Quant = ResAra.Quant ; Art = {s : ResAra.Number => Species => Gender => Case => Str; d : State} ; diff --git a/src/arabic/MorphoAra.gf b/src/arabic/MorphoAra.gf index 2d9225c11..b55549b83 100644 --- a/src/arabic/MorphoAra.gf +++ b/src/arabic/MorphoAra.gf @@ -7,9 +7,10 @@ flags optimize = all ;--noexpand; mkDet : Str -> Number -> State -> Det = \word,num,state -> - { s = \\_,_,c => word + vowel ! c ; + { s = \\_,_,c => word + caseTbl ! c ; n = numberToSize num; d = state; --only Const is used now. check StructuralAra + is1sg = False; isNum = False; isPron = False }; @@ -18,7 +19,7 @@ flags optimize = all ;--noexpand; = \word,decl -> { s = \\c => case decl of { - True => word + vowel!c; + True => word + caseTbl!c; False => word }; isDecl = decl @@ -40,11 +41,4 @@ flags optimize = all ;--noexpand; isNum = True }; - vowel : Case => Str = - table { - Nom => "ُ"; - Acc => "َ"; - Gen => "ِ" - }; - } diff --git a/src/arabic/NounAra.gf b/src/arabic/NounAra.gf index b7cc77d2f..d02c0a3be 100644 --- a/src/arabic/NounAra.gf +++ b/src/arabic/NounAra.gf @@ -6,19 +6,27 @@ lin DetCN det cn = let { number = sizeToNumber det.n; + state = possState det.d; determiner : Case -> Str = \c -> det.s ! cn.h ! (detGender cn.g det.n) ! c; - noun : Case -> NTable -> Str = \c,nt -> nt ! - number ! (nounState det.d number) ! (nounCase c det.n det.d) + noun : Case -> NTable -> Str = \c,nt -> + let cas = if_then_else Case det.is1sg Bare c -- no case vowel with 1sg poss. suff. + in nt ! number + ! nounState det.d number + ! nounCase cas det.n det.d } in { s = \\c => case cnB4det det.isPron det.isNum det.n det.d of { - False => determiner c ++ noun c cn.s ++ noun c cn.adj ; - --FIXME use the adj -> cn -> cn rule from below instead of - --repeating code - True => cn.s ! number ! det.d ! c ++ det.s ! cn.h ! cn.g ! c - ++ cn.adj ! number ! det.d ! c - }; + False => determiner c + ++ noun c cn.s -- deal with poss. suffix + ++ cn.adj ! number ! state ! c -- normal case+state + ++ cn.np ! c ; + True => noun c cn.s -- deal with poss. suffix + -- ++ determiner c -- or this? + ++ det.s ! cn.h ! cn.g ! c + ++ cn.adj ! number ! state ! c -- normal case+state + ++ cn.np ! c + }; a = { pgn = agrP3 cn.h cn.g number; isPron = False } }; @@ -70,36 +78,33 @@ lin } ; -} - DetQuantOrd quant num ord = { + DetQuantOrd quant num ord = quant ** { s = \\h,g,c => quant.s ! Pl ! h ! g ! c ++ num.s ! g ! (toDef quant.d num.n) ! c --FIXME check this: ++ ord.s ! g ! (toDef quant.d num.n) ! c ; n = num.n; - d = quant.d; - isPron = quant.isPron; - isNum = case num.n of { - None => ord.isNum ; -- ord may come from OrdDigits or OrdNumeral - _ => True - } + isNum = orB num.isNum ord.isNum ; + -- ord may come from OrdDigits or OrdNumeral + -- num may come from NumCard : Card -> Num + } ; - DetQuant quant num = { + DetQuant quant num = quant ** { s = \\h,g,c => quant.s ! Pl ! h ! g ! c ++ num.s ! g ! (toDef quant.d num.n) ! c ; n = num.n; - d = quant.d; - isPron = quant.isPron; isNum = -- Num may come from NumCard : Card -> Num case num.n of { None => False; - _ => True + _ => num.isNum } } ; PossPron p = { s = \\_,_,_,_ => p.s ! Gen; - d = Const; + d = Poss; + is1sg = case p.a.pgn of { Per1 _ => True ; _ => False } ; isPron = True; isNum = False } ; @@ -152,13 +157,13 @@ lin DefArt = { s = \\_,_,_,_ => []; d = Def ; - isNum,isPron = False + isNum,isPron,is1sg = False } ; IndefArt = { s = \\_,_,_,_ => []; d = Indef ; - isNum,isPron = False + isNum,isPron,is1sg = False } ; MassNP cn = ---- AR diff --git a/src/arabic/ParadigmsAra.gf b/src/arabic/ParadigmsAra.gf index bd1e5da9e..1533bdef9 100644 --- a/src/arabic/ParadigmsAra.gf +++ b/src/arabic/ParadigmsAra.gf @@ -428,9 +428,9 @@ resource ParadigmsAra = open mkPron : (_,_,_ : Str) -> PerGenNum -> NP = \ana,nI,I,pgn -> { s = table { - Nom => ana; Acc => nI; - Gen => I + Gen => I; + _ => ana }; a = {pgn = pgn; isPron = True }; lock_NP = <> @@ -451,7 +451,7 @@ resource ParadigmsAra = open }; mkQuant7 : (_,_,_,_,_,_,_ : Str) -> State -> Quant = - \hava,havihi,havAn,havayn,hAtAn,hAtayn,hA'ulA,det -> + \hava,havihi,havAn,havayn,hAtAn,hAtayn,hA'ulA,det -> lin Quant (baseQuant ** { s = \\n,s,g,c => case of { <_,Masc,_,Sg> => hava; @@ -463,14 +463,11 @@ resource ParadigmsAra = open => hA'ulA; _ => havihi }; - d = Def; - isPron = False; - isNum = False; - lock_Quant = <> - }; + d = det + }); mkQuant3 : (_,_,_ : Str) -> State -> Quant = - \dalika,tilka,ula'ika,det -> + \dalika,tilka,ula'ika,det -> lin Quant (baseQuant ** { s = \\n,s,g,c => case of { <_,Masc,_,Sg> => dalika; @@ -478,11 +475,8 @@ resource ParadigmsAra = open => ula'ika; _ => tilka }; - d = det; - isPron = False; - isNum = False; - lock_Quant = <> - }; + d = det + }); degrA : (posit,compar,plur : Str) -> A = \posit,compar,plur -> lin A {s = clr posit compar plur} ; diff --git a/src/arabic/ResAra.gf b/src/arabic/ResAra.gf index 90222d049..3031f0062 100644 --- a/src/arabic/ResAra.gf +++ b/src/arabic/ResAra.gf @@ -17,10 +17,14 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in { Vowel = u | a | i ; Number = Sg | Dl | Pl; Gender = Masc | Fem ; - Case = Nom | Acc | Gen ; + Case = Nom | Acc | Gen + | Bare ; -- 1st person poss. suff. overrides case Person = P1 | P2 | P3 ; Species = NoHum | Hum ; - State = Def | Indef | Const ; + State = Def | Indef | Const + | Poss ; -- ة turns into ت + -- sound masculine plural drops ن + -- case vowel retained Mood = Ind | Cnj | Jus ; Voice = Act | Pas ; Tense = Pres | Past | Fut ; @@ -783,6 +787,14 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf -> --Nominal Morphology + caseTbl : Case => Str = + table { + Bare => [] ; + Nom => "ُ"; + Acc => "َ"; + Gen => "ِ" + }; + --takes the adjective lemma and gives the Posit table positAdj : Str -> Gender => NTable = \kabIr -> @@ -848,20 +860,22 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf -> \\s,c => defArt s (case word of { lemma + "ِي" => fixShd lemma (dec2sg ! s ! c) ; _ + ("ا"|"ى") => fixShd word (dec3sg ! s ! c) ; + lemma + "ة" => case s of { + Poss => lemma + "ت" + dec1sg ! s ! c ; + _ => word + dec1sg ! s ! c + } ; _ => fixShd word (dec1sg ! s ! c) }) ; -- takes a singular word and tests the ending to -- determine the declension and gives the corresponding dual inf table - dual : Str -> State => Case => Str = - \caSaA -> - case caSaA of { - lemma + ("ا"|"ى") => \\s,c => defArt s lemma + "ي" + dl ! s ! c ; - lemma + "ة" => - \\s,c => defArt s (lemma + "ت") + dl ! s ! c ; - _ => \\s,c => defArt s caSaA + dl ! s ! c - }; + dual : Str -> State => Case => Str = \caSaA -> + \\s,c => defArt s (case caSaA of { + lemma + ("ا"|"ى") => lemma + "ي" + dl ! s ! c ; + lemma + "ة" => lemma + "ت" + dl ! s ! c ; + _ => fixShd caSaA (dl ! s ! c) + }); -- takes a singular word and gives the corresponding sound --plural feminine table @@ -898,52 +912,39 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf -> table { Indef => table { + Bare => []; Nom => "ٌ"; Acc => "ً"; Gen => "ٍ" }; - _ => - table { --think of ?axU, ?axA, (the five nouns) - Nom => "ُ"; - Acc => "َ"; - Gen => "ِ" - } + _ => caseTbl --think of ?axU, ?axA, (the five nouns) + }; --indeclinables (mamnuu3 mina S-Sarf) indecl : Case => Str = table { - Nom => "ُ"; - _ => "َ" + Gen => "َ" ; + x => caseTbl ! x }; - --declection 2 (ends in yaa') - dec2sg : State => Case => Str = - table { - Indef => - table { - Acc => "ِياً"; - _ => "ٍ" - }; - _ => - table { - Acc => "ِيَ"; - _ => "ِي" - } + --declension 2 (ends in yaa') + dec2sg : State => Case => Str = \\s,c => + case of { + <_, Bare> => [] ; + => "ِياً" ; + => "ٍ" ; + <_, Acc> => "ِيَ" ; + _ => "ِي" }; - --declention 3 (ending in alif) - dec3sg : State => Case => Str = - table { - Indef => - table { - _ => "ً" - }; - _ => - table { - _ => "" - } + --declension 3 (ending in alif) + dec3sg : State => Case => Str = \\s,c => + case of { + => [] ; + => "ً" ; + _ => [] }; @@ -957,12 +958,13 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf -> }; _ => table { - Nom => "َانِ"; - _ => "َيْنِ" + Nom => "َانِ"; + Bare => "َيْن"; + _ => "َيْنِ" } }; - --sound mascualine plural suffixes + --sound masculine plural suffixes m_pl : State => Case => Str = table { Const => @@ -972,6 +974,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf -> }; _ => table { + Bare => "ِين"; Nom => "ُونَ"; _ => "ِينَ" } @@ -982,11 +985,13 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf -> table { Indef => table { + Bare => []; Nom => "ٌ"; _ => "ٍ" }; _ => table { + Bare => []; Nom => "ُ"; _ => "ِ" } @@ -1030,11 +1035,14 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf -> case of { => Def; --kullu l-kutubi, bacDu l-kutubi => Indef; --kullu kitaabin - => Indef; --kitaabun - _ => Def --Lkitaabu + => Indef; --kitaabun + => Poss; + _ => Def --Lkitaabu }; - + possState : State -> State = \s -> + case s of { Poss => Def ; + x => x } ; --FIXME needs testing nounCase : Case -> Size -> State -> Case = \c,size,s -> @@ -1112,14 +1120,24 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf -> oper - Det : Type = { - s : Species => Gender => Case => Str ; + BaseQuant : Type = { d : State; - n : Size; + is1sg : Bool; -- To force no case marker for 1st person poss. suff. isNum : Bool; -- for genitive pronouns (suffixes). if true, then "cn ++ det" --should be used instead of "det ++ cn" when constructing the NP - isPron : Bool + isPron: Bool} ; + + baseQuant = { d = Indef ; + is1sg,isNum,isPron = False } ; + + Quant : Type = BaseQuant ** { + s : ResAra.Number => Species => Gender => Case => Str + } ; + + Det : Type = BaseQuant ** { + s : Species => Gender => Case => Str ; + n : Size } ; Predet : Type = { diff --git a/src/arabic/StructuralAra.gf b/src/arabic/StructuralAra.gf index fb7ae0b12..5c49c6bf7 100644 --- a/src/arabic/StructuralAra.gf +++ b/src/arabic/StructuralAra.gf @@ -98,6 +98,7 @@ concrete StructuralAra of Structural = CatAra ** where_IAdv = ss "أَينَ" ; which_IQuant = { s = \\s,c => case of { + => "أيّ" ; => "أيٌّ" ; => "أيُّ" ; => "أيّاً" ;