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 SentAP : AP -> SC -> AP = notYet "SentAP" ;
oper SentCN : CN -> SC -> CN = notYet "SentCN" ;
oper SlashPrep : Cl -> Prep -> ClSlash = notYet "SlashPrep" ;
oper Slash2V3 : V3 -> NP -> VPSlash = notYet "Slash2V3" ;
oper SlashV2A : V2A -> AP -> VPSlash = notYet "SlashV2A" ;
oper SlashV2Q : V2Q -> QS -> VPSlash = notYet "SlashV2Q" ;

View File

@@ -186,7 +186,7 @@ lin
ComplN3 n3 np = ComplN2 n3 np ** {c2 = n3.c3} ;
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};

View File

@@ -374,15 +374,15 @@ resource ParadigmsAra = open
v1' : Str -> Vowel -> Vowel -> Verb =
\rootStr,vPerf,vImpf ->
let { root = mkRoot3 rootStr } in
case <root.l, root.c> of {
<"ّ", _> => v1geminate rootStr vPerf vImpf ;
<"و"|"ي",_> => case vPerf of {
i => v1defective_i root vImpf ;
_ => v1defective_a root vImpf } ;
<_,"و"|"ي"> => v1hollow root vImpf ;
_ => v1sound root vPerf vImpf
};
let root = mkRoot3 rootStr
in case rootStr of {
_ + "ّ" => v1geminate rootStr vPerf vImpf ;
? + #hamza + #weak => v1doubleweak root ;
? + ? + #weak => case vPerf of {
i => v1defective_i root vImpf ;
_ => v1defective_a root vImpf } ;
? + #weak + ? => v1hollow root vImpf ;
_ => v1sound root vPerf vImpf } ;
v2 =
\rootStr ->
@@ -536,6 +536,8 @@ resource ParadigmsAra = open
lock_NP = <>
};
proDrop : NP -> NP = ResAra.proDrop ; -- Force a NP to lose its string, only contributing with its agreement.
-- e.g. al-jamii3, 2a7ad
regNP : Str -> Number -> NP = \word,n ->
{ 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 } ;
-- QCl = {s : Tense => Polarity => QForm => Str} ;
QuestSlash ip cl = { ----IL just guessing
QuestSlash ip cls = { ----IL just guessing
s = \\t,p,qf =>
let o = case qf of { QDir => Nominal ; _ => Verbal } ; -- purely guessing
in cl.c2.s ++ ip.s ! False ! Def ! Nom ++ cl.s ! t ! p ! o
let cl : ResAra.Cl = complClSlash cls ; -- dummy conversion to Cl
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

View File

@@ -20,12 +20,13 @@ concrete RelativeAra of Relative = CatAra **
} ;
-- : RP -> ClSlash -> RCl ; -- whom John loves
RelSlash rp cl = cl ** {
RelSlash rp cls = cls ** {
s = \\t,p,agr,c =>
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 } ;
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 = {

View File

@@ -26,7 +26,8 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
-- case vowel retained
Mood = Ind | Cnj | Jus ;
Voice = Act | Pas ;
Order = Verbal | Nominal ;
Order = Verbal | Nominal
| VOS ; -- Relative clauses with resumptive pronouns
oper
@@ -552,6 +553,12 @@ v1defective_i : Root3 -> Vowel -> Verb = \bqy,vowImpf -> -- IL (conjugation 1d4)
x => vforms_a ! x } ;
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 =
table {
u => fcu ;
@@ -641,7 +648,6 @@ v4doubleweak : Root3 -> Verb = \r'y ->
vforms : DefForms = \\x => rmSukun (v4DefForms ry ! x) ; -- only remove the first sukun
in verbDoubleDef vforms i ; -- sukun in suffixes is removed in verbDoubleDef
v5sound : Root3 -> Verb =
\nfs ->
let {
@@ -1181,6 +1187,8 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
Agr = { pgn : PerGenNum; isPron : Bool} ;
AAgr = { g : Gender ; n : Number} ;
Comp : Type = {
s : AAgr => Case => Str
} ;
@@ -1201,6 +1209,14 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
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 = {
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
@@ -1220,7 +1236,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
s : State => Case => Str
} ;
param VPForm =
param VPForm =
VPPerf
| VPImpf Mood
| VPImp ;
@@ -1228,7 +1244,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
oper
VP : Type = {
s : PerGenNum => VPForm => Str;
s : PerGenNum => VPForm => Str ;
obj : Obj;
pred : Comp;
isPred : Bool; --indicates if there is a predicate (xabar)
@@ -1274,8 +1290,48 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
};
predVSlash : Verb2 -> VPSlash = \v ->
predV v ** {c2 = v.c2} ;
predVP : NP -> VP -> Cl = \np,vp ->
{ 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 Gender but not in number
@@ -1297,17 +1353,36 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
{ s2 = vp.s2 ++ str };
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
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} ;
QCl : Type = {s : Tense => Polarity => QForm => Str} ;
-- Relative
param
-- Relative
param
RAgr = RSg Gender | RPl Gender | RDl Gender Case ;
oper
@@ -1315,9 +1390,8 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
agr2ragr : Agr -> Case -> RAgr = \a,c ->
let gn = pgn2gn a.pgn in case <gn.n,gn.g,a> of {
<Sg,x> => RSg x ;
<Pl,x> => RPl x ;
<Dl,x> => RDl x c ;
_ => Predef.error "agr2ragr"} ;
<Pl,x> => RPl x } ;
agr2ragr : Number -> Case -> Gender -> RAgr = \n,c,g ->
case n of {
Sg => RSg g ;

View File

@@ -26,58 +26,7 @@ concrete SentenceAra of Sentence = CatAra ** open
}
};
-}
PredVP np vp =
{ 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)
}
};
PredVP = predVP ;
-- PredSCVP sc vp = mkClause sc.s (agrP3 Sg) vp ;
@@ -100,9 +49,13 @@ concrete SentenceAra of Sentence = CatAra ** open
-- ClSlash
SlashVP np vps = PredVP np vps ** { c2 = vps.c2 } ;
SlashVP = predVPSlash ;
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
@@ -111,9 +64,9 @@ concrete SentenceAra of Sentence = CatAra ** open
-- EmbedQS qs = {s = qs.s ! QIndir} ;
-- EmbedVP vp = {s = infVP False vp (agrP3 Sg)} ; --- agr
--
UseSlash,
UseCl = \t,p,cl ->
{s = t.s ++ p.s ++
UseCl t p cl =
{s = t.s ++ p.s ++
case <t.t,t.a> of { --- IL guessed tenses
<(Pres|Cond),Simul> => cl.s ! Pres ! p.p ! Nominal ;
<Fut ,_ > => cl.s ! Fut ! p.p ! Nominal ;
@@ -122,7 +75,7 @@ concrete SentenceAra of Sentence = CatAra ** open
};
UseQCl t p qcl =
{s = \\q => t.s ++ p.s ++
{s = \\q => t.s ++ p.s ++
case <t.t,t.a> of { --- IL guessed tenses
<(Pres|Cond),Simul> => qcl.s ! Pres ! p.p ! q ;
<Fut ,_ > => qcl.s ! Fut ! p.p ! q ;
@@ -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} ;
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
--SlashV2VNP : V2V -> NP -> VPSlash -> VPSlash ; -- beg me to buy
SlashV2a v = predVSlash v ;
Slash3V3 v np = insertObj np (predVSlash v) ** {c2 = v.c3};
SlashV2a = slashV2 ;
Slash3V3 v np = insertObj np (slashV2 v) ** {c2 = v.c3};
ComplSlash vp np = insertObj np vp ;
@@ -38,6 +38,8 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra in {
--
UseComp xabar = kaan xabar ;
UseCopula = predV copula ;
AdvVP vp adv = insertStr adv.s vp ;
-- AdVVP adv vp = insertAdV adv.s vp ;