1
0
forked from GitHub/gf-rgl

Merge pull request #70 from inariksit/arabic

Arabic
This commit is contained in:
Inari Listenmaa
2018-11-12 17:11:05 +01:00
committed by GitHub
8 changed files with 123 additions and 88 deletions

View File

@@ -49,6 +49,7 @@ oper ReflA2 : A2 -> AP = notYet "ReflA2" ;
oper ReflVP : VPSlash -> VP = notYet "ReflVP" ; oper ReflVP : VPSlash -> VP = notYet "ReflVP" ;
oper SentAP : AP -> SC -> AP = notYet "SentAP" ; oper SentAP : AP -> SC -> AP = notYet "SentAP" ;
oper SentCN : CN -> SC -> CN = notYet "SentCN" ; oper SentCN : CN -> SC -> CN = notYet "SentCN" ;
oper SlashPrep : Cl -> Prep -> ClSlash = notYet "SlashPrep" ;
oper Slash2V3 : V3 -> NP -> VPSlash = notYet "Slash2V3" ; oper Slash2V3 : V3 -> NP -> VPSlash = notYet "Slash2V3" ;
oper SlashV2A : V2A -> AP -> VPSlash = notYet "SlashV2A" ; oper SlashV2A : V2A -> AP -> VPSlash = notYet "SlashV2A" ;
oper SlashV2Q : V2Q -> QS -> VPSlash = notYet "SlashV2Q" ; oper SlashV2Q : V2Q -> QS -> VPSlash = notYet "SlashV2Q" ;

View File

@@ -186,7 +186,7 @@ lin
ComplN3 n3 np = ComplN2 n3 np ** {c2 = n3.c3} ; ComplN3 n3 np = ComplN2 n3 np ** {c2 = n3.c3} ;
AdjCN ap cn = cn ** { AdjCN ap cn = cn ** {
adj = \\n,d,c => ap.s ! cn.h ! cn.g ! n ! (definite ! d) ! c adj = \\n,d,c => cn.adj ! n ! d ! c ++ ap.s ! cn.h ! cn.g ! n ! (definite ! d) ! c
}; };
RelCN cn rs = cn ** {s = \\n,s,c => cn.s ! n ! s ! c ++ rs.s ! {pgn=Per3 cn.g n ; isPron=False} ! c}; RelCN cn rs = cn ** {s = \\n,s,c => cn.s ! n ! s ! c ++ rs.s ! {pgn=Per3 cn.g n ; isPron=False} ! c};

View File

@@ -374,15 +374,15 @@ resource ParadigmsAra = open
v1' : Str -> Vowel -> Vowel -> Verb = v1' : Str -> Vowel -> Vowel -> Verb =
\rootStr,vPerf,vImpf -> \rootStr,vPerf,vImpf ->
let { root = mkRoot3 rootStr } in let root = mkRoot3 rootStr
case <root.l, root.c> of { in case rootStr of {
<"ّ", _> => v1geminate rootStr vPerf vImpf ; _ + "ّ" => v1geminate rootStr vPerf vImpf ;
<"و"|"ي",_> => case vPerf of { ? + #hamza + #weak => v1doubleweak root ;
? + ? + #weak => case vPerf of {
i => v1defective_i root vImpf ; i => v1defective_i root vImpf ;
_ => v1defective_a root vImpf } ; _ => v1defective_a root vImpf } ;
<_,"و"|"ي"> => v1hollow root vImpf ; ? + #weak + ? => v1hollow root vImpf ;
_ => v1sound root vPerf vImpf _ => v1sound root vPerf vImpf } ;
};
v2 = v2 =
\rootStr -> \rootStr ->
@@ -536,6 +536,8 @@ resource ParadigmsAra = open
lock_NP = <> lock_NP = <>
}; };
proDrop : NP -> NP = ResAra.proDrop ; -- Force a NP to lose its string, only contributing with its agreement.
-- e.g. al-jamii3, 2a7ad -- e.g. al-jamii3, 2a7ad
regNP : Str -> Number -> NP = \word,n -> regNP : Str -> Number -> NP = \word,n ->
{ s = \\c => fixShd word (dec1sg ! Def ! c) ; { s = \\c => fixShd word (dec1sg ! Def ! c) ;

View File

@@ -42,10 +42,11 @@ concrete QuestionAra of Question = CatAra ** open ResAra, ParamX, Prelude, VerbA
CompIAdv iadv = { s = \\_ => iadv.s ; a = ResAra.Sg } ; CompIAdv iadv = { s = \\_ => iadv.s ; a = ResAra.Sg } ;
-- QCl = {s : Tense => Polarity => QForm => Str} ; -- QCl = {s : Tense => Polarity => QForm => Str} ;
QuestSlash ip cl = { ----IL just guessing QuestSlash ip cls = { ----IL just guessing
s = \\t,p,qf => s = \\t,p,qf =>
let o = case qf of { QDir => Nominal ; _ => Verbal } ; -- purely guessing let cl : ResAra.Cl = complClSlash cls ; -- dummy conversion to Cl
in cl.c2.s ++ ip.s ! False ! Def ! Nom ++ cl.s ! t ! p ! o o = case qf of { QDir => Nominal ; _ => Verbal } ; -- purely guessing
in cls.c2.s ++ ip.s ! False ! Def ! Nom ++ cl.s ! t ! p ! o
} ; } ;
--IL guessed --IL guessed

View File

@@ -20,12 +20,13 @@ concrete RelativeAra of Relative = CatAra **
} ; } ;
-- : RP -> ClSlash -> RCl ; -- whom John loves -- : RP -> ClSlash -> RCl ; -- whom John loves
RelSlash rp cl = cl ** { RelSlash rp cls = cls ** {
s = \\t,p,agr,c => s = \\t,p,agr,c =>
let obj = case (pgn2gn agr.pgn).g of { let obj = case (pgn2gn agr.pgn).g of {
Fem => St.she_Pron ; Fem => St.she_Pron ; -- head is repeated as a clitic object pronoun
Masc => St.he_Pron } ; Masc => St.he_Pron } ;
in rp.s ! agr2ragr agr c ++ cl.s ! t ! p ! Nominal ++ cl.c2.s ++ obj.s ! cl.c2.c cl : ResAra.Cl = complClSlash obj cls ;
in rp.s ! agr2ragr agr c ++ cl.s ! t ! p ! VOS
} ; } ;
-- --
-- FunRP p np rp = { -- FunRP p np rp = {

View File

@@ -26,7 +26,8 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
-- case vowel retained -- case vowel retained
Mood = Ind | Cnj | Jus ; Mood = Ind | Cnj | Jus ;
Voice = Act | Pas ; Voice = Act | Pas ;
Order = Verbal | Nominal ; Order = Verbal | Nominal
| VOS ; -- Relative clauses with resumptive pronouns
oper oper
@@ -552,6 +553,12 @@ v1defective_i : Root3 -> Vowel -> Verb = \bqy,vowImpf -> -- IL (conjugation 1d4)
x => vforms_a ! x } ; x => vforms_a ! x } ;
in verbDef vforms_i vowImpf ; in verbDef vforms_i vowImpf ;
v1doubleweak : Root3 -> Verb = \r'y ->
let ry = r'y ** {c = ""} ;
vforms : DefForms = \\x => rmSukun (v1DefForms_perfA ry a ! x) ; -- only remove the first sukun
in verbDoubleDef vforms i ; -- sukun in suffixes is removed in verbDoubleDef
patDef1 : Vowel => Pattern = patDef1 : Vowel => Pattern =
table { table {
u => fcu ; u => fcu ;
@@ -641,7 +648,6 @@ v4doubleweak : Root3 -> Verb = \r'y ->
vforms : DefForms = \\x => rmSukun (v4DefForms ry ! x) ; -- only remove the first sukun vforms : DefForms = \\x => rmSukun (v4DefForms ry ! x) ; -- only remove the first sukun
in verbDoubleDef vforms i ; -- sukun in suffixes is removed in verbDoubleDef in verbDoubleDef vforms i ; -- sukun in suffixes is removed in verbDoubleDef
v5sound : Root3 -> Verb = v5sound : Root3 -> Verb =
\nfs -> \nfs ->
let { let {
@@ -1181,6 +1187,8 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
Agr = { pgn : PerGenNum; isPron : Bool} ; Agr = { pgn : PerGenNum; isPron : Bool} ;
AAgr = { g : Gender ; n : Number} ; AAgr = { g : Gender ; n : Number} ;
Comp : Type = { Comp : Type = {
s : AAgr => Case => Str s : AAgr => Case => Str
} ; } ;
@@ -1201,6 +1209,14 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
a : Agr a : Agr
} ; } ;
proDrop : NP -> NP = \np ->
case np.a.isPron of {
True => np ** {s = \\_ => []};
_ => np
} ;
emptyNP : NP = {s = \\_ => [] ; a = {pgn = Per3 Masc Sg ; isPron = False}} ;
IP : Type = { IP : Type = {
s : Bool -- different forms for "what is this" and "what do you do" s : Bool -- different forms for "what is this" and "what do you do"
=> State => Case -- because of PrepIP: e.g. "in which" chooses definite accusative => State => Case -- because of PrepIP: e.g. "in which" chooses definite accusative
@@ -1274,8 +1290,48 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
}; };
predVSlash : Verb2 -> VPSlash = \v -> predVP : NP -> VP -> Cl = \np,vp ->
predV v ** {c2 = v.c2} ; { s =\\t,p,o =>
let {
pgn =
case <o,np.a.isPron> of {
<Verbal, False> => verbalAgr np.a.pgn;
_ => np.a.pgn
};
gn = pgn2gn pgn;
kataba = vp.s ! pgn ! VPPerf ;
yaktubu = vp.s ! pgn ! VPImpf Ind ;
yaktuba = vp.s ! pgn ! VPImpf Cnj ;
yaktub = vp.s ! pgn ! VPImpf Jus ;
vStr : ParamX.Tense -> Polarity -> Str =
\tn,pl -> case <vp.isPred,tn,pl> of {
<False, Pres, Pos> => yaktubu ;
<False, Pres, Neg> => "لَا" ++ yaktubu ;
<True, Pres, Pos> => "" ; --no verb "to be" in present
<True, Pres, Neg> => "لَيسَ" ;--same here, just add negation particle
<_, Past, Pos> => kataba ;
<_, Past, Neg> => "لَمْ" ++ yaktub ;
<_, _Fut, Pos> => "سَ" ++ yaktubu ;
<_, _Fut, Neg> => "لَنْ" ++ yaktuba
};
pred : ParamX.Tense -> Polarity -> Str =
\tn,pl -> case <vp.isPred,tn,pl> of {
<True, Pres, Pos> => vp.pred.s ! gn ! Nom; --xabar marfooc
_ => vp.pred.s ! gn ! Acc --xabar kaana wa laysa manSoob
};
} in
-- If you want prodrop, use proDrop : NP -> NP for your subject. /IL
case o of {
Verbal => vStr t p ++ case vp.obj.a.isPron of {
True => vp.obj.s ++ np.s ! Nom ; -- obj. clitic attaches directly to the verb
False => np.s ! Nom ++ vp.obj.s }
++ vp.s2 ++ pred t p ;
Nominal => np.s ! Nom ++ vStr t p ++ vp.obj.s ++ vp.s2 ++ pred t p ;
VOS => vStr t p ++ vp.obj.s ++ vp.s2 ++ pred t p ++ np.s ! Nom
}
} ;
-- in verbal sentences, the verb agrees with the subject -- in verbal sentences, the verb agrees with the subject
-- in Gender but not in number -- in Gender but not in number
@@ -1297,11 +1353,30 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
{ s2 = vp.s2 ++ str }; { s2 = vp.s2 ++ str };
kaan : {s : AAgr => Case => Str} -> VP = \xabar -> kaan : {s : AAgr => Case => Str} -> VP = \xabar ->
insertPred xabar (predV (v1hollow {f = "ك"; c = "و" ; l = "ن"} u) ); insertPred xabar (predV copula);
copula : Verb = v1hollow {f = "ك"; c = "و" ; l = "ن"} u ;
-- Slash categories -- Slash categories
VPSlash : Type = VP ** {c2 : Preposition} ; VPSlash : Type = VP ** {c2 : Preposition} ;
ClSlash : Type = Cl ** {c2 : Preposition} ; ClSlash : Type = VPSlash ** {subj : NP} ;
slashV2 : Verb2 -> VPSlash = \v ->
predV v ** {c2 = v.c2} ;
-- Add subject string, fix agreement to the subject,
-- but keep the structure as VP, because later on
-- we might need different word orders for the ClSlash.
predVPSlash : NP -> VPSlash -> ClSlash = \np,v -> v ** {
subj = np
} ;
complClSlash = overload {
complClSlash : NP -> ClSlash -> Cl = \obj,cls ->
predVP cls.subj (insertObj obj cls) ;
complClSlash : ClSlash -> Cl = \cls ->
predVP cls.subj (insertObj emptyNP cls) -- Empty subject and object
} ;
Cl : Type = {s : Tense => Polarity => Order => Str} ; Cl : Type = {s : Tense => Polarity => Order => Str} ;
QCl : Type = {s : Tense => Polarity => QForm => Str} ; QCl : Type = {s : Tense => Polarity => QForm => Str} ;
@@ -1315,9 +1390,8 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
agr2ragr : Agr -> Case -> RAgr = \a,c -> agr2ragr : Agr -> Case -> RAgr = \a,c ->
let gn = pgn2gn a.pgn in case <gn.n,gn.g,a> of { let gn = pgn2gn a.pgn in case <gn.n,gn.g,a> of {
<Sg,x> => RSg x ; <Sg,x> => RSg x ;
<Pl,x> => RPl x ;
<Dl,x> => RDl x c ; <Dl,x> => RDl x c ;
_ => Predef.error "agr2ragr"} ; <Pl,x> => RPl x } ;
agr2ragr : Number -> Case -> Gender -> RAgr = \n,c,g -> agr2ragr : Number -> Case -> Gender -> RAgr = \n,c,g ->
case n of { case n of {
Sg => RSg g ; Sg => RSg g ;

View File

@@ -26,58 +26,7 @@ concrete SentenceAra of Sentence = CatAra ** open
} }
}; };
-} -}
PredVP np vp = PredVP = predVP ;
{ s =\\t,p,o =>
let {
pgn =
case <o,np.a.isPron> of {
<Verbal, False> => verbalAgr np.a.pgn;
_ => np.a.pgn
};
gn = pgn2gn pgn;
kataba = vp.s ! pgn ! VPPerf ;
yaktubu = vp.s ! pgn ! VPImpf Ind ;
yaktuba = vp.s ! pgn ! VPImpf Cnj ;
yaktub = vp.s ! pgn ! VPImpf Jus ;
vStr : ParamX.Tense -> Polarity -> Str =
\tn,pl -> case<vp.isPred,tn,pl> of {
<False, Pres, Pos> => yaktubu ;
<False, Pres, Neg> => "لَا" ++ yaktubu ;
<True, Pres, Pos> => "" ; --no verb "to be" in present
<True, Pres, Neg> => "لَيسَ" ;--same here, just add negation particle
<_, Past, Pos> => kataba ;
<_, Past, Neg> => "لَمْ" ++ yaktub ;
<_, _Fut, Pos> => "سَ" ++ yaktubu ;
<_, _Fut, Neg> => "لَنْ" ++ yaktuba
};
pred : ParamX.Tense -> Polarity -> Str =
\tn,pl -> case <vp.isPred,tn,pl> of {
<True, Pres, Pos> => vp.pred.s ! gn ! Nom; --xabar marfooc
_ => vp.pred.s ! gn ! Acc --xabar kaana wa laysa manSoob
};
} in
case o of {
Verbal =>
--case <False, np.a.isPron> of { ---- AR workaround 18/12/2008
case <vp.obj.a.isPron, np.a.isPron> of {
{- IL: I don't think we should do prodrop here. vStr drops the copula in present tense,
so there's hardly anything left for a predicative clause: e.g.
PredVP (UsePron i_Pron) (UseComp (CompCN (UseN car_N))) "I am a car"
would be linearised just as "car", if we have both prodrop and copula drop.
Leaving it up to someone who knows Arabic to decide what is better.
Original here:
<True,True> => (vStr t p) ++ vp.obj.s ++ vp.s2 ++ (pred t p) ;
-- ya2kuluhu
<False,True> => (vStr t p) ++ vp.obj.s ++ vp.s2 ++ (pred t p); -}
-- ya2kuluhu al-waladu, yakuluhu al-2awlaadu
<False> => (vStr t p) ++ np.s ! Nom ++ vp.obj.s ++ vp.s2 ++ (pred t p);
<True> => (vStr t p) ++ vp.obj.s ++ np.s ! Nom ++ vp.s2 ++ (pred t p)
};
Nominal =>
np.s ! Nom ++ (vStr t p) ++ vp.obj.s ++ vp.s2 ++ (pred t p)
}
};
-- PredSCVP sc vp = mkClause sc.s (agrP3 Sg) vp ; -- PredSCVP sc vp = mkClause sc.s (agrP3 Sg) vp ;
@@ -100,9 +49,13 @@ concrete SentenceAra of Sentence = CatAra ** open
-- ClSlash -- ClSlash
SlashVP np vps = PredVP np vps ** { c2 = vps.c2 } ; SlashVP = predVPSlash ;
AdvSlash slash adv = slash ** { s2 = slash.s2 ++ adv.s } ; AdvSlash slash adv = slash ** { s2 = slash.s2 ++ adv.s } ;
SlashPrep cl prep = cl ** {c2 = prep} ;
-- SlashPrep : Cl -> Prep -> ClSlash
-- Will be awkward to implement in the way ClSlash is now.
-- ClSlash is implemented the way it is now for a good reason:
-- we need to support different word orders.
-- SlashVS np vs sslash = TODO -- SlashVS np vs sslash = TODO
@@ -111,8 +64,8 @@ concrete SentenceAra of Sentence = CatAra ** open
-- EmbedQS qs = {s = qs.s ! QIndir} ; -- EmbedQS qs = {s = qs.s ! QIndir} ;
-- EmbedVP vp = {s = infVP False vp (agrP3 Sg)} ; --- agr -- EmbedVP vp = {s = infVP False vp (agrP3 Sg)} ; --- agr
-- --
UseSlash,
UseCl = \t,p,cl -> UseCl t p cl =
{s = t.s ++ p.s ++ {s = t.s ++ p.s ++
case <t.t,t.a> of { --- IL guessed tenses case <t.t,t.a> of { --- IL guessed tenses
<(Pres|Cond),Simul> => cl.s ! Pres ! p.p ! Nominal ; <(Pres|Cond),Simul> => cl.s ! Pres ! p.p ! Nominal ;
@@ -132,4 +85,5 @@ concrete SentenceAra of Sentence = CatAra ** open
UseRCl t p cl = {s = \\agr,c => t.s ++ p.s ++ cl.s ! t.t ! p.p ! agr ! c} ; UseRCl t p cl = {s = \\agr,c => t.s ++ p.s ++ cl.s ! t.t ! p.p ! agr ! c} ;
UseSlash t p cl = UseCl t p (complClSlash cl) ;
} }

View File

@@ -11,8 +11,8 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra in {
--SlashV2V : V2V -> VP -> VPSlash ; -- beg (her) to go --SlashV2V : V2V -> VP -> VPSlash ; -- beg (her) to go
--SlashV2VNP : V2V -> NP -> VPSlash -> VPSlash ; -- beg me to buy --SlashV2VNP : V2V -> NP -> VPSlash -> VPSlash ; -- beg me to buy
SlashV2a v = predVSlash v ; SlashV2a = slashV2 ;
Slash3V3 v np = insertObj np (predVSlash v) ** {c2 = v.c3}; Slash3V3 v np = insertObj np (slashV2 v) ** {c2 = v.c3};
ComplSlash vp np = insertObj np vp ; ComplSlash vp np = insertObj np vp ;
@@ -38,6 +38,8 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra in {
-- --
UseComp xabar = kaan xabar ; UseComp xabar = kaan xabar ;
UseCopula = predV copula ;
AdvVP vp adv = insertStr adv.s vp ; AdvVP vp adv = insertStr adv.s vp ;
-- AdVVP adv vp = insertAdV adv.s vp ; -- AdVVP adv vp = insertAdV adv.s vp ;