1
0
forked from GitHub/gf-rgl

Merge pull request #26 from inariksit/arabic

Arabic: compound nouns, verb paradigms, assimilations, whitespace
This commit is contained in:
Inari Listenmaa
2018-09-26 11:50:04 +02:00
committed by GitHub
18 changed files with 848 additions and 772 deletions

View File

@@ -85,7 +85,6 @@ concrete CatAra of Cat = CommonX - [Utt] ** open ResAra, Prelude, ParamX in {
V2V, V2S, V2Q = ResAra.Verb ** {c2 : Str} ; --- AR
V3 = ResAra.Verb ** {c2, c3 : Str} ;
VV = ResAra.Verb ** {c2 : Str ; isAux : Bool} ; --- IL
-- VV = {s : VVForm => Str ; isAux : Bool} ;
A = ResAra.Adj ;
A2 = ResAra.Adj ** {c2 : Str} ;

View File

@@ -16,5 +16,4 @@ concrete ExtendAra of Extend =
lin
GenNP np = { s = \\_,_,_,_ => np.s ! Gen ; d = Const ; isNum, isPron = False } ;
} ;

View File

@@ -33,7 +33,7 @@ flags optimize = all ;--noexpand;
case g of {
Masc => waHid;
Fem => waHida
} in Al ! state + word + dec1sg ! state ! c;
} in defArt state waHid + word + dec1sg ! state ! c;
n = num;
d = state;
isPron = False;

View File

@@ -54,6 +54,8 @@ resource ParadigmsAra = open
= mkFullN ;
mkN : (root,sgPatt,brokenPlPatt : Str) -> Gender -> Species -> N -- broken plural
= brkN ;
mkN : N -> (attr : Str) -> N -- Compound nouns
= \n,attr -> n ** { s = \\num,s,c => n.s ! num ! s ! c ++ attr } ; --- IL (TODO: all kinds of compounds)
--- mkN : (root,sgPatt : Str) -> Gender -> Species -> N -- sound feminine plural
--- = sdfN ;
} ;
@@ -278,7 +280,7 @@ resource ParadigmsAra = open
l = dp 2 rootStr } in --last rootStr
case <l, root.c> of {
<"ّ",_> => v1geminate rootStr vPerf vImpf ;
<"و"|"ي",_> => v1defective root vImpf ;
<"و"|"ي",_> => v1defective root vPerf vImpf ;
<_,"و"|"ي"> => v1hollow root vImpf ;
_ => v1sound root vPerf vImpf
};
@@ -351,10 +353,10 @@ resource ParadigmsAra = open
\rootStr ->
let {
rbT = mkRoot3 rootStr ;
} in {
s = (v8sound rbT).s ;
lock_V = <>
};
v8fun = case rbT.f of {
("و"|"ي"|"ّ") => v8assimilated ;
_ => v8sound }
} in lin V (v8fun rbT) ;
Preposition = Str ;
@@ -560,6 +562,6 @@ formV : (root : Str) -> VerbForm -> V = \s,f -> case f of {
} ;
param VerbForm =
FormI | FormIII | FormIII | FormIV | FormV | FormVI | FormVIII ;
FormI | FormII | FormIII | FormIV | FormV | FormVI | FormVIII ;
} ;

View File

@@ -48,6 +48,7 @@ flags coding=utf8 ;
eiftacal = { h = "إِ"; m1 = "ْتَ" ; m2 = "َ" ; t = "" } ;
eufcil = { h = "أُ"; m1 = "ْ" ; m2 = "ِ" ; t = "" } ;
euftucil = { h = "أُ"; m1 = "ْتُ" ; m2 = "ِ" ; t = "" } ;
euttucil = euftucil ** { h = "تُّأُ" ; m1 = "" } ; ---- IL assimilated VIII
afcul = { h = "َ" ; m1 = "ْ" ; m2 = "ُ" ; t = "" } ;
faccalo = { h = "" ; m1 = "َ" ; m2 = "َّ" ; t = "ْ" } ;
facal = { h = "" ; m1 = "َ" ; m2 = "َ" ; t = "" } ;
@@ -77,6 +78,8 @@ flags coding=utf8 ;
ficlp = { h = "" ; m1 = "ِ" ; m2 = "ْ" ; t = "َة" } ;
ftacal = { h = "" ; m1 = "ْتَ" ; m2 = "َ" ; t = "" } ;
ftacil = { h = "" ; m1 = "ْتَ" ; m2 = "ِ" ; t = "" } ;
ttacal = ftacal ** { m1 = "" ; h = "تَّ" } ; ---- IL assimilated VIII
ttacil = ftacil ** { m1 = "" ; h = "تَّ" } ; ---- IL assimilated VIII
fuccAl = { h = "" ; m1 = "ُ" ; m2 = "َّا" ; t = "" } ;
fuccil = { h = "" ; m1 = "ُ" ; m2 = "ِّ" ; t = "" } ;
fuccilo = { h = "" ; m1 = "ُ" ; m2 = "ِّ" ; t = "ْ" } ;

View File

@@ -76,12 +76,11 @@ resource ResAra = PatternsAra ** open Prelude, Predef, ParamX in {
-- takes a weak pattern and a triliteral root and makes
-- a word, deducing which root consonant is weak
mkWeak : Pattern -> Str -> Str = \pat,root ->
let fcl = mkRoot3 root in
case root of {
_ + ("و"|"ي"|"ّ") => mkDefective pat fcl;
_ + ("و"|"ي") + _ => mkHollow pat fcl;
("و"|"ي") + _ => mkAssimilated pat fcl
mkWeak : Pattern -> Root3 -> Str = \pat,fcl ->
case <fcl.f,fcl.c,fcl.l> of {
<_,_,("و"|"ي"|"ّ")> => mkDefective pat fcl;
<_,("و"|"ي"),_> => mkHollow pat fcl;
<("و"|"ي"),_,_> => mkAssimilated pat fcl
};
mkBilit : Pattern -> Root2 -> Str = \p,fcl ->
@@ -95,7 +94,7 @@ resource ResAra = PatternsAra ** open Prelude, Predef, ParamX in {
w@_ + "ف" + x@_ + "ع" + y@_ =>
let pat = { h = w ; m1 = x; m2 = ""; t = y} in
case <length rS : Ints 100> of {
6 | 5 => mkWeak pat rS ; --3=>
6 | 5 => mkWeak pat (mkRoot3 rS) ; --3=>
4 | 3 => mkBilit pat (mkRoot2 rS) ; --2=>
_ => rS ---- AR error "expected 3--6"
}
@@ -247,18 +246,30 @@ oper
} ;
--macro for defective verbs:
verbDef: (_,_,_,_,_,_,_,_,_,_,_ : Str) -> Vowel -> Verb =
\rama,ramay,rumi,rumu,rumiy,armi,armu,urma,Irmi,Irmu,ppart,vowel ->
verbDef : DefForms -> Vowel -> Verb =
\vforms,vImpf ->
let {
rama = vforms ! 0 ; -- VPerf Act (Per3 Masc Sg)
ramay = vforms ! 1 ; -- VPerf Act (Per3 Fem Pl)
rumi = vforms ! 2 ; -- VPerf Pas (Per3 _ Sg)
rumu = vforms ! 3 ; -- VPerf Pas (Per3 Masc Pl)
rumiy = vforms ! 4 ; -- VPerf Pas (Per3 Fem Pl)
armi = vforms ! 5 ; -- VImpf _ Act (Per1 _ _ | Per2/3 Fem _ | Per2/3 Masc Sg)
armu = vforms ! 6 ; -- VImpf _ Act (Per2/3 Masc Pl)
urma = vforms ! 7 ; -- VImpf _ Pas
Irmi = vforms ! 8 ; -- VImp Masc Sg | VImp Fem _
Irmu = vforms ! 9 ; -- VImp Masc Pl
ppart = vforms ! 10 ; -- VPPart
patPerf = patDefPerf rama ramay rumi rumu rumiy ;
patImpfAct = patDefImpfAct armi armu ;
patImp = patDefImp Irmi Irmu
} in
{ s = table {
VPerf v pgn => patPerf ! v ! pgn + (suffixPerfDef v) ! pgn ;
VImpf m Act pgn => prefixImpf ! pgn + patImpfAct ! pgn + (suffixImpfDef Act vowel) ! m ! pgn ;
VImpf m Pas pgn => prefixImpf ! pgn + urma + (suffixImpfDef Pas vowel) ! m ! pgn ;
VImp g n => patImp ! g ! n + (suffixImpfDef Act vowel) ! Jus ! (Per2 g n) ;
VImpf m Act pgn => prefixImpf ! pgn + patImpfAct ! pgn + (suffixImpfDef Act vImpf) ! m ! pgn ;
VImpf m Pas pgn => prefixImpf ! pgn + urma + (suffixImpfDef Pas vImpf) ! m ! pgn ;
VImp g n => patImp ! g ! n + (suffixImpfDef Act vImpf) ! Jus ! (Per2 g n) ;
VPPart => ppart
}
} ;
@@ -464,23 +475,59 @@ patGem3 : Vowel => Pattern =
i => fcil --no such verb probably exists
} ;
v1defective : Root3 -> Vowel -> Verb =
\rmy,vowel ->
DefForms : Type = Predef.Ints 10 => Str ;
toDefForms : (x1,_,_,_,_,_,_,_,_,_,x11 : Str) -> DefForms =
\rama,ramay,rumi,rumu,rumiy,armi,armu,urma,eirmi,eirmu,marmiy ->
table {
0 => rama ;
1 => ramay ;
2 => rumi ;
3 => rumu ;
4 => rumiy ;
5 => armi ;
6 => armu ;
7 => urma ;
8 => eirmi ;
9 => eirmu ;
10 => marmiy
} ;
def1Forms_vPerfA : Root3 -> Vowel -> DefForms = \rmy,vImpf ->
let {
rama = mkDefective faca rmy ;
ramay = mkStrong facalo rmy ;
rumi = mkDefective fuci rmy ;
rumu = mkDefective fucu rmy ;
rumiy = mkStrong fucilo rmy ;
rmi = mkDefective (patDef1 ! vowel) rmy ;
rmi = mkDefective (patDef1 ! vImpf) rmy ;
armi = "َ" + rmi ;
rmu = mkDefective (patDef2 ! vowel) rmy ;
rmu = mkDefective (patDef2 ! vImpf) rmy ;
armu = "َ" + rmu ;
urma = mkDefective ufca rmy ;
eirmi = prefixImp ! vowel + rmi;
eirmu = prefixImp ! vowel + rmu;
eirmi = prefixImp ! vImpf + rmi;
eirmu = prefixImp ! vImpf + rmu;
marmiy = mkStrong mafcil rmy
} in verbDef rama ramay rumi rumu rumiy armi armu urma eirmi eirmu marmiy vowel ;
} in toDefForms rama ramay rumi rumu rumiy armi armu urma eirmi eirmu marmiy ;
v1defective : Root3 -> Vowel -> Vowel -> Verb = \rmy,vPerf,vImpf ->
case vPerf of {
i => v1defective_i rmy vImpf ;
_ => v1defective_a rmy vImpf
} ;
v1defective_a : Root3 -> Vowel -> Verb = \rmy,vImpf ->
let vforms = def1Forms_vPerfA rmy vImpf
in verbDef vforms vImpf ;
v1defective_i : Root3 -> Vowel -> Verb = \bqy,vImpf -> -- IL (conjugation 1d4)
let vforms_a = def1Forms_vPerfA bqy vImpf ;
baqI = mkDefective facIl bqy ;
baqiy = mkDefective facil bqy ;
vforms_i = table { 0 => baqI ;
1 => baqiy ;
x => vforms_a ! x } ;
in verbDef vforms_i vImpf ;
patDef1 : Vowel => Pattern =
table {
@@ -519,7 +566,7 @@ v2defective : Root3 -> Verb = \gny ->
ugannu = "ُ" + gannu;
uganna = "ُ" + ganna;
mugannaY = "مُ" + ganna + "ى"
} in verbDef ganna gannay gunni gunnu gunniy uganni ugannu uganna ganni gannu mugannaY i;
} in verbDef (toDefForms ganna gannay gunni gunnu gunniy uganni ugannu uganna ganni gannu mugannaY) i;
v3sound : Root3 -> Verb =
\tbc ->
@@ -561,7 +608,7 @@ v4defective : Root3 -> Verb = \cTy ->
eacTi = "أَ" + cTi;
eacTu = "أَ" + cTu;
mucTaY = "م" + ucTa +"ى"
} in verbDef eacTa eacTay eucTi eucTu eucTiy ucTi ucTu ucTa eacTi eacTu mucTaY i;
} in verbDef (toDefForms eacTa eacTay eucTi eucTu eucTiy ucTi ucTu ucTa eacTi eacTu mucTaY) i;
v5sound : Root3 -> Verb =
\nfs ->
@@ -596,6 +643,20 @@ v8sound : Root3 -> Verb =
murtabaT = "م" + urtabaT
} in verb eirtabaT eurtubiT artabiT urtabaT eirtabiT murtabaT;
v8assimilated : Root3 -> Verb = --- IL 8a1
\wfq ->
let {
ttafiq = mkWeak ttacil wfq ;
ttafaq = mkWeak ttacal wfq ;
eittafaq = "إِ" + ttafaq ;
euttufiq = mkWeak euttucil wfq ;
attafiq = "َ" + ttafiq ;
uttafaq = "ُ" + ttafaq ;
eittafiq = "إِ" + ttafiq ;
muttafaq = "م" + uttafaq
} in verb eittafaq euttufiq attafiq uttafaq eittafiq muttafaq;
patV1Perf : Vowel => Pattern =
table {
a => facal ; --katab
@@ -715,7 +776,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
-- indeclinable nominal word (mamnuu3 mina S-Sarf)
indeclN : Str -> State => Case => Str =
\aHmar -> \\s,c => Al!s + aHmar + indecl!c;
\aHmar -> \\s,c => defArt s aHmar + indecl!c;
-- takes 2 words, singular and broken plural, and gives the
-- complete noun inflection table
@@ -752,41 +813,62 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
sing : Str -> State => Case => Str =
\word ->
case word of {
lemma + "ِي" => \\s,c => Al ! s + lemma + dec2sg ! s ! c ;
_ + ("ا"|"ى") => \\s,c => Al ! s + word + dec3sg ! s ! c ;
_ => \\s,c => Al ! s + word + dec1sg ! s ! c
lemma + "ِي" => \\s,c => defArt s lemma + dec2sg ! s ! c ;
_ + ("ا"|"ى") => \\s,c => defArt s word + dec3sg ! s ! c ;
_ => \\s,c => defArt s 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 => Al ! s + lemma + "ي" + dl ! s ! c ;
_ => \\s,c => Al ! s + caSaA + dl ! s ! c
lemma + ("ا"|"ى") => \\s,c => defArt s lemma + "ي" + dl ! s ! c ;
_ => \\s,c => defArt s caSaA + dl ! s ! c
};
-- takes a singular word and gives the corresponding sound
--plural feminine table
plurF : Str -> State => Case => Str =
\kalima ->
\\s,c => Al ! s + (mkAt kalima) + f_pl ! s ! c ;
\\s,c => defArt s (mkAt kalima) + f_pl ! s ! c ;
-- takes a singular word and gives the corresponding sound
--plural masculine table. FIXME: consider declension 3
plurM : Str -> State => Case => Str =
\mucallim ->
\\s,c => Al ! s + mucallim + m_pl ! s ! c ;
\\s,c => defArt s mucallim + m_pl ! s ! c ;
-- to add the Al prefix for Definite words
Al : State => Str =
table {
Def => "ال";
Def => "ال" ;
_ => ""
};
--declection 1 (strong ending) of the singular or broken plural words
defArt : State -> Str -> Str = \st,stem ->
let arra = "الرَّ" ;
arri = "الرِّ" ;
arr = "الرِّ" ;
atta = "التَ" ;
atti = "التِّ";
att = "التّ" ;
al = "ال" ;
in case st of { -- TODO rest of the assimilations
Def => case stem of {
ra@"رَ" + x => arra + x ;
ri@"رِ" + x => arri + x ;
r@"ر" + x => arr + x ; -- no vowel specified
ta@"تَ" + x => atta + x ;
ti@"تِ" + x => atti + x ;
t@"ت" + x => att + x ; -- no vowel specified
_ => al + stem
} ;
_ => "" + stem
};
--declension 1 (strong ending) of the singular or broken plural words
dec1sg : State => Case => Str =
table {
Indef =>
@@ -1140,16 +1222,16 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
NCard => table {
Masc => \\s,c => (sing wAhid) ! s ! c ;
--all fem are first declension:
Fem => \\s,c => Al ! s + wAhida + dec1sg ! s ! c
Fem => \\s,c => defArt s wAhida + dec1sg ! s ! c
};
NOrd => table {
Masc => \\s,c => Al ! s + awwal + dec1sg ! s ! c;
Masc => \\s,c => defArt s awwal + dec1sg ! s ! c;
Fem => \\s,c => (sing Ula) ! s ! c
}
};
ten => table {
NCard => \\_,s,c => Al ! s + wAhid + m_pl ! Indef ! c;
NOrd => \\_,s,c => Al ! s + awwal + m_pl ! Indef ! c
NCard => \\_,s,c => defArt s wAhid + m_pl ! Indef ! c;
NOrd => \\_,s,c => defArt s awwal + m_pl ! Indef ! c
}
}
};

View File

@@ -4,6 +4,7 @@ concrete SentenceAra of Sentence = CatAra ** open
ResAra,
Prelude,
ResAra,
TenseX,
ParamX,
CommonX in {
@@ -111,31 +112,22 @@ concrete SentenceAra of Sentence = CatAra ** open
-- EmbedVP vp = {s = infVP False vp (agrP3 Sg)} ; --- agr
--
--FIXME, all tenses
UseCl t ap cl =
{s = cl.s ! ResAra.Pres ! ap.p ! Verbal
{- case t of {
TPres => cl.s ! ResAra.Pres ! p.p ! Verbal ;
TCond => cl.s ! ResAra.Pres ! p.p ! Verbal ;
TPast => cl.s ! ResAra.Past ! p.p ! Verbal ;
TFut => cl.s ! ResAra.Fut ! p.p ! Verbal
UseCl t p cl =
{s = case <t.t,t.a> of { --- IL guessed tenses
<(Pres|Cond),Simul> => cl.s ! ResAra.Pres ! p.p ! Verbal ;
<Fut ,_ > => cl.s ! ResAra.Fut ! p.p ! Verbal ;
<_ ,_ > => cl.s ! ResAra.Past ! p.p ! Verbal
}
-} };
};
--FIXME, all tenses
UseQCl t ap qcl = --{s = cl.s ! t ! p ! Verbal } ;
{s =
table {
QDir => qcl.s ! ResAra.Pres ! ap.p ! QDir;
QIndir => qcl.s ! ResAra.Pres ! ap.p ! QIndir
UseQCl t p qcl =
{s = \\q =>
case <t.t,t.a> of { --- IL guessed tenses
<(Pres|Cond),Simul> => qcl.s ! ResAra.Pres ! p.p ! q ;
<Fut ,_ > => qcl.s ! ResAra.Fut ! p.p ! q ;
<_ ,_ > => qcl.s ! ResAra.Past ! p.p ! q
}
{- case t of {
TPres => "هَل" ++ qcl.s ! ResAra.Pres ! p.p ! q ;
TCond => "هَل" ++ qcl.s ! ResAra.Pres ! p.p ! q ;
TPast => "هَل" ++ qcl.s ! ResAra.Past ! p.p ! q ;
TFut => "هَل" ++ qcl.s ! ResAra.Fut ! p.p ! q
}
-} };
};
-- UseRCl t a p cl = {s = \\r => t.s ++ a.s ++ p.s ++ cl.s ! t.t ! a.a ! p.p ! r} ;

View File

@@ -46,4 +46,3 @@ oper
{ pgn = Per3 Masc n ; isPron = False } ;
}