1
0
forked from GitHub/gf-rgl

Merge pull request #44 from inariksit/arabic

Arabic: nouns and stuff
This commit is contained in:
Inari Listenmaa
2018-10-16 17:52:03 +02:00
committed by GitHub
7 changed files with 120 additions and 113 deletions

View File

@@ -47,7 +47,7 @@ concrete CatAra of Cat = CommonX - [Utt] ** open ResAra, Prelude, ParamX in {
-- Noun -- Noun
CN = ResAra.Noun ** {adj : NTable}; CN = ResAra.Noun ** {adj : NTable ; np : Case => Str};
NP, Pron = ResAra.NP; --{s : Case => Str ; a : Agr } ; NP, Pron = ResAra.NP; --{s : Case => Str ; a : Agr } ;
Num, Num,
Ord, Ord,
@@ -57,10 +57,7 @@ concrete CatAra of Cat = CommonX - [Utt] ** open ResAra, Prelude, ParamX in {
Det = ResAra.Det ; Det = ResAra.Det ;
-- {s : Species => Gender => Case => Str ; -- {s : Species => Gender => Case => Str ;
-- d : State; n : Size; isNum : Bool } ; -- d : State; n : Size; isNum : Bool } ;
Quant = {s : ResAra.Number => Species => Gender => Case => Str; Quant = ResAra.Quant ;
d : State;
isNum : Bool;
isPron: Bool} ;
Art = {s : ResAra.Number => Species => Gender => Case => Str; Art = {s : ResAra.Number => Species => Gender => Case => Str;
d : State} ; d : State} ;

View File

@@ -234,7 +234,7 @@ flags
write_V2 = dirV2 (regV "يَكتُب") ; write_V2 = dirV2 (regV "يَكتُب") ;
-- write_V2 = dirV2 (v1 "كتب" a u) ; -- write_V2 = dirV2 (v1 "كتب" a u) ;
yellow_A = clrA "صفر" ; yellow_A = clrA "صفر" ;
young_A = sndA "شبّ" "فاعّ" ; young_A = sndA "شبب" "فاعّ" ;
do_V2 = dirV2 (regV "يَفعَل") ; do_V2 = dirV2 (regV "يَفعَل") ;
-- do_V2 = dirV2 (v1 "فعل" a a ) ; -- do_V2 = dirV2 (v1 "فعل" a a ) ;
@@ -287,7 +287,7 @@ flags
fingernail_N = brkN "ظفر" "فُعل" "أَفاعِل" Masc NoHum; fingernail_N = brkN "ظفر" "فُعل" "أَفاعِل" Masc NoHum;
fire_N = brkN "نور" "فاع" "فِيعان" Fem NoHum; fire_N = brkN "نور" "فاع" "فِيعان" Fem NoHum;
flower_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; foot_N = brkN "قدم" "فَعَل" "أَفعال" Fem NoHum;
forest_N = sdfN "غيب" "فاعة" Fem NoHum; forest_N = sdfN "غيب" "فاعة" Fem NoHum;
grass_N = brkN "عشب" "فُعلة" "أَفعال" Fem NoHum; grass_N = brkN "عشب" "فُعلة" "أَفعال" Fem NoHum;
@@ -305,7 +305,7 @@ flags
liver_N = brkN "كبد" "فَعِل" "أَفعال" Masc NoHum ; liver_N = brkN "كبد" "فَعِل" "أَفعال" Masc NoHum ;
louse_N = sdfN "قمل" "فَعلة" Fem NoHum; louse_N = sdfN "قمل" "فَعلة" Fem NoHum;
mouth_N = brkN "فوه" "فُعل" "أَفعال" Masc NoHum ; mouth_N = brkN "فوه" "فُعل" "أَفعال" Masc NoHum ;
name_N = brkN "؟سم" "فِعل" "فَعالِي" Masc NoHum; name_N = brkN "ءسم" "فِعل" "فَعالِي" Masc NoHum;
neck_N = brkN "رقب" "فَعَلة" "فِعال" Fem NoHum; neck_N = brkN "رقب" "فَعَلة" "فِعال" Fem NoHum;
night_N = brkN "ليل" "فَعلة" "فَعالِي" Fem NoHum; --plural? night_N = brkN "ليل" "فَعلة" "فَعالِي" Fem NoHum; --plural?
nose_N = brkN "؟نف" "فَعل" "فُعُول" Masc NoHum; nose_N = brkN "؟نف" "فَعل" "فُعُول" Masc NoHum;

View File

@@ -7,9 +7,10 @@ flags optimize = all ;--noexpand;
mkDet : Str -> Number -> State -> Det mkDet : Str -> Number -> State -> Det
= \word,num,state -> = \word,num,state ->
{ s = \\_,_,c => word + vowel ! c ; { s = \\_,_,c => word + caseTbl ! c ;
n = numberToSize num; n = numberToSize num;
d = state; --only Const is used now. check StructuralAra d = state; --only Const is used now. check StructuralAra
is1sg = False;
isNum = False; isNum = False;
isPron = False isPron = False
}; };
@@ -18,7 +19,7 @@ flags optimize = all ;--noexpand;
= \word,decl -> = \word,decl ->
{ s = \\c => { s = \\c =>
case decl of { case decl of {
True => word + vowel!c; True => word + caseTbl!c;
False => word False => word
}; };
isDecl = decl isDecl = decl
@@ -40,11 +41,4 @@ flags optimize = all ;--noexpand;
isNum = True isNum = True
}; };
vowel : Case => Str =
table {
Nom => "ُ";
Acc => "َ";
Gen => "ِ"
};
} }

View File

@@ -6,18 +6,26 @@ lin
DetCN det cn = let { DetCN det cn = let {
number = sizeToNumber det.n; number = sizeToNumber det.n;
state = possState det.d;
determiner : Case -> Str = \c -> determiner : Case -> Str = \c ->
det.s ! cn.h ! (detGender cn.g det.n) ! c; det.s ! cn.h ! (detGender cn.g det.n) ! c;
noun : Case -> NTable -> Str = \c,nt -> nt ! noun : Case -> NTable -> Str = \c,nt ->
number ! (nounState det.d number) ! (nounCase c det.n det.d) 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 { } in {
s = \\c => s = \\c =>
case cnB4det det.isPron det.isNum det.n det.d of { case cnB4det det.isPron det.isNum det.n det.d of {
False => determiner c ++ noun c cn.s ++ noun c cn.adj ; False => determiner c
--FIXME use the adj -> cn -> cn rule from below instead of ++ noun c cn.s -- deal with poss. suffix
--repeating code ++ cn.adj ! number ! state ! c -- normal case+state
True => cn.s ! number ! det.d ! c ++ det.s ! cn.h ! cn.g ! c ++ cn.np ! c ;
++ cn.adj ! number ! det.d ! 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; a = { pgn = agrP3 cn.h cn.g number;
isPron = False } 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 s = \\h,g,c => quant.s ! Pl ! h ! g ! c
++ num.s ! g ! (toDef quant.d num.n) ! c ++ num.s ! g ! (toDef quant.d num.n) ! c
--FIXME check this: --FIXME check this:
++ ord.s ! g ! (toDef quant.d num.n) ! c ; ++ ord.s ! g ! (toDef quant.d num.n) ! c ;
n = num.n; n = num.n;
d = quant.d; isNum = orB num.isNum ord.isNum ;
isPron = quant.isPron; -- ord may come from OrdDigits or OrdNumeral
isNum = case num.n of { -- num may come from NumCard : Card -> Num
None => ord.isNum ; -- ord may come from OrdDigits or OrdNumeral
_ => True
}
} ; } ;
DetQuant quant num = { DetQuant quant num = quant ** {
s = \\h,g,c => quant.s ! Pl ! h ! g ! c s = \\h,g,c => quant.s ! Pl ! h ! g ! c
++ num.s ! g ! (toDef quant.d num.n) ! c ; ++ num.s ! g ! (toDef quant.d num.n) ! c ;
n = num.n; n = num.n;
d = quant.d;
isPron = quant.isPron;
isNum = -- Num may come from NumCard : Card -> Num isNum = -- Num may come from NumCard : Card -> Num
case num.n of { case num.n of {
None => False; None => False;
_ => True _ => num.isNum
} }
} ; } ;
PossPron p = { PossPron p = {
s = \\_,_,_,_ => p.s ! Gen; s = \\_,_,_,_ => p.s ! Gen;
d = Const; d = Poss;
is1sg = case p.a.pgn of { Per1 _ => True ; _ => False } ;
isPron = True; isPron = True;
isNum = False } ; isNum = False } ;
@@ -152,13 +157,13 @@ lin
DefArt = { DefArt = {
s = \\_,_,_,_ => []; s = \\_,_,_,_ => [];
d = Def ; d = Def ;
isNum,isPron = False isNum,isPron,is1sg = False
} ; } ;
IndefArt = { IndefArt = {
s = \\_,_,_,_ => []; s = \\_,_,_,_ => [];
d = Indef ; d = Indef ;
isNum,isPron = False isNum,isPron,is1sg = False
} ; } ;
MassNP cn = ---- AR MassNP cn = ---- AR
@@ -169,7 +174,9 @@ lin
-- isNum = False; isPron = False} ; -- isNum = False; isPron = False} ;
UseN, UseN,
UseN2 = \n -> n ** {adj = \\_,_,_ => []}; UseN2 = \n -> n ** {
adj = \\_,_,_ => [];
np = \\_ => []};
Use2N3 n3 = n3 ; Use2N3 n3 = n3 ;
Use3N3 n3 = n3 ** {c2 = n3.c3} ; Use3N3 n3 = n3 ** {c2 = n3.c3} ;
@@ -179,16 +186,12 @@ lin
ComplN3 n3 np = ComplN2 n3 np ** {c2 = n3.c3} ; ComplN3 n3 np = ComplN2 n3 np ** {c2 = n3.c3} ;
AdjCN ap cn = { AdjCN ap cn = cn ** {
s = \\n,d,c => cn.s ! n ! d ! c; adj = \\n,d,c => ap.s ! cn.h ! cn.g ! n ! (definite ! d) ! c
adj = \\n,d,c => ap.s ! cn.h ! cn.g ! n ! (definite ! d) ! c ;
g = cn.g;
h = cn.h
}; };
-- RelCN cn rs = {s = \\n,c => cn.s ! n ! c ++ rs.s ! {n = n ; p = P3}} ; -- 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} ; -- AdvCN cn ad = {s = \\n,c => cn.s ! n ! c ++ ad.s} ;
-- --
-- SentCN cn sc = {s = \\n,c => cn.s ! n ! c ++ sc.s} ; -- SentCN cn sc = {s = \\n,c => cn.s ! n ! c ++ sc.s} ;
ApposCN cn np = cn ** { ApposCN cn np = cn ** { np = np.s } ;
s = \\n,d,c => cn.s ! n ! d ! c ++ np.s ! c } ;
} }

View File

@@ -428,9 +428,9 @@ resource ParadigmsAra = open
mkPron : (_,_,_ : Str) -> PerGenNum -> NP = \ana,nI,I,pgn -> mkPron : (_,_,_ : Str) -> PerGenNum -> NP = \ana,nI,I,pgn ->
{ s = { s =
table { table {
Nom => ana;
Acc => nI; Acc => nI;
Gen => I Gen => I;
_ => ana
}; };
a = {pgn = pgn; isPron = True }; a = {pgn = pgn; isPron = True };
lock_NP = <> lock_NP = <>
@@ -451,7 +451,7 @@ resource ParadigmsAra = open
}; };
mkQuant7 : (_,_,_,_,_,_,_ : Str) -> State -> Quant = 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 => { s = \\n,s,g,c =>
case <s,g,c,n> of { case <s,g,c,n> of {
<_,Masc,_,Sg> => hava; <_,Masc,_,Sg> => hava;
@@ -463,14 +463,11 @@ resource ParadigmsAra = open
<Hum,_,_,Pl> => hA'ulA; <Hum,_,_,Pl> => hA'ulA;
_ => havihi _ => havihi
}; };
d = Def; d = det
isPron = False; });
isNum = False;
lock_Quant = <>
};
mkQuant3 : (_,_,_ : Str) -> State -> Quant = mkQuant3 : (_,_,_ : Str) -> State -> Quant =
\dalika,tilka,ula'ika,det -> \dalika,tilka,ula'ika,det -> lin Quant (baseQuant **
{ s = \\n,s,g,c => { s = \\n,s,g,c =>
case <s,g,c,n> of { case <s,g,c,n> of {
<_,Masc,_,Sg> => dalika; <_,Masc,_,Sg> => dalika;
@@ -478,11 +475,8 @@ resource ParadigmsAra = open
<Hum,_,_,_> => ula'ika; <Hum,_,_,_> => ula'ika;
_ => tilka _ => tilka
}; };
d = det; d = det
isPron = False; });
isNum = False;
lock_Quant = <>
};
degrA : (posit,compar,plur : Str) -> A degrA : (posit,compar,plur : Str) -> A
= \posit,compar,plur -> lin A {s = clr posit compar plur} ; = \posit,compar,plur -> lin A {s = clr posit compar plur} ;

View File

@@ -17,10 +17,14 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
Vowel = u | a | i ; Vowel = u | a | i ;
Number = Sg | Dl | Pl; Number = Sg | Dl | Pl;
Gender = Masc | Fem ; Gender = Masc | Fem ;
Case = Nom | Acc | Gen ; Case = Nom | Acc | Gen
| Bare ; -- 1st person poss. suff. overrides case
Person = P1 | P2 | P3 ; Person = P1 | P2 | P3 ;
Species = NoHum | Hum ; 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 ; Mood = Ind | Cnj | Jus ;
Voice = Act | Pas ; Voice = Act | Pas ;
Tense = Pres | Past | Fut ; Tense = Pres | Past | Fut ;
@@ -783,6 +787,14 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
--Nominal Morphology --Nominal Morphology
caseTbl : Case => Str =
table {
Bare => [] ;
Nom => "ُ";
Acc => "َ";
Gen => "ِ"
};
--takes the adjective lemma and gives the Posit table --takes the adjective lemma and gives the Posit table
positAdj : Str -> Gender => NTable = positAdj : Str -> Gender => NTable =
\kabIr -> \kabIr ->
@@ -848,20 +860,22 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
\\s,c => defArt s (case word of { \\s,c => defArt s (case word of {
lemma + "ِي" => fixShd lemma (dec2sg ! s ! c) ; lemma + "ِي" => fixShd lemma (dec2sg ! s ! c) ;
_ + ("ا"|"ى") => fixShd word (dec3sg ! 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) _ => fixShd word (dec1sg ! s ! c)
}) ; }) ;
-- takes a singular word and tests the ending to -- takes a singular word and tests the ending to
-- determine the declension and gives the corresponding dual inf table -- determine the declension and gives the corresponding dual inf table
dual : Str -> State => Case => Str = dual : Str -> State => Case => Str = \caSaA ->
\caSaA -> \\s,c => defArt s (case caSaA of {
case caSaA of { lemma + ("ا"|"ى") => lemma + "ي" + dl ! s ! c ;
lemma + ("ا"|"ى") => \\s,c => defArt s lemma + "ي" + dl ! s ! c ; lemma + "ة" => lemma + "ت" + dl ! s ! c ;
lemma + "ة" => _ => fixShd caSaA (dl ! s ! c)
\\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 -- takes a singular word and gives the corresponding sound
--plural feminine table --plural feminine table
@@ -898,52 +912,39 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
table { table {
Indef => Indef =>
table { table {
Bare => [];
Nom => "ٌ"; Nom => "ٌ";
Acc => "ً"; Acc => "ً";
Gen => "ٍ" Gen => "ٍ"
}; };
_ => _ => caseTbl --think of ?axU, ?axA, (the five nouns)
table { --think of ?axU, ?axA, (the five nouns)
Nom => "ُ";
Acc => "َ";
Gen => "ِ"
}
}; };
--indeclinables (mamnuu3 mina S-Sarf) --indeclinables (mamnuu3 mina S-Sarf)
indecl : Case => Str = indecl : Case => Str =
table { table {
Nom => "ُ"; Gen => "َ" ;
_ => "َ" x => caseTbl ! x
}; };
--declection 2 (ends in yaa') --declension 2 (ends in yaa')
dec2sg : State => Case => Str = dec2sg : State => Case => Str = \\s,c =>
table { case <s,c> of {
Indef => <_, Bare> => [] ;
table { <Indef,Acc> => "ِياً" ;
Acc => "ِياً"; <Indef> => "ٍ" ;
_ => "ٍ" <_, Acc> => "ِيَ" ;
};
_ =>
table {
Acc => "ِيَ";
_ => "ِي" _ => "ِي"
}
}; };
--declention 3 (ending in alif) --declension 3 (ending in alif)
dec3sg : State => Case => Str = dec3sg : State => Case => Str = \\s,c =>
table { case <s,c> of {
Indef => <Indef,Bare> => [] ;
table { <Indef> => "ً" ;
_ => "ً" _ => []
};
_ =>
table {
_ => ""
}
}; };
@@ -958,11 +959,12 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
_ => _ =>
table { table {
Nom => "َانِ"; Nom => "َانِ";
Bare => "َيْن";
_ => "َيْنِ" _ => "َيْنِ"
} }
}; };
--sound mascualine plural suffixes --sound masculine plural suffixes
m_pl : State => Case => Str = m_pl : State => Case => Str =
table { table {
Const => Const =>
@@ -972,6 +974,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
}; };
_ => _ =>
table { table {
Bare => "ِين";
Nom => "ُونَ"; Nom => "ُونَ";
_ => "ِينَ" _ => "ِينَ"
} }
@@ -982,11 +985,13 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
table { table {
Indef => Indef =>
table { table {
Bare => [];
Nom => "ٌ"; Nom => "ٌ";
_ => "ٍ" _ => "ٍ"
}; };
_ => _ =>
table { table {
Bare => [];
Nom => "ُ"; Nom => "ُ";
_ => "ِ" _ => "ِ"
} }
@@ -1030,11 +1035,14 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
case <s,n> of { case <s,n> of {
<Const,Pl> => Def; --kullu l-kutubi, bacDu l-kutubi <Const,Pl> => Def; --kullu l-kutubi, bacDu l-kutubi
<Const,Sg> => Indef; --kullu kitaabin <Const,Sg> => Indef; --kullu kitaabin
<Indef,_> => Indef; --kitaabun <Indef> => Indef; --kitaabun
<Poss> => Poss;
_ => Def --Lkitaabu _ => Def --Lkitaabu
}; };
possState : State -> State = \s ->
case s of { Poss => Def ;
x => x } ;
--FIXME needs testing --FIXME needs testing
nounCase : Case -> Size -> State -> Case = nounCase : Case -> Size -> State -> Case =
\c,size,s -> \c,size,s ->
@@ -1112,14 +1120,24 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
oper oper
Det : Type = { BaseQuant : Type = {
s : Species => Gender => Case => Str ;
d : State; d : State;
n : Size; is1sg : Bool; -- To force no case marker for 1st person poss. suff.
isNum : Bool; isNum : Bool;
-- for genitive pronouns (suffixes). if true, then "cn ++ det" -- for genitive pronouns (suffixes). if true, then "cn ++ det"
--should be used instead of "det ++ cn" when constructing the NP --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 = { Predet : Type = {

View File

@@ -98,6 +98,7 @@ concrete StructuralAra of Structural = CatAra **
where_IAdv = ss "أَينَ" ; where_IAdv = ss "أَينَ" ;
which_IQuant = { which_IQuant = {
s = \\s,c => case <c,s> of { s = \\s,c => case <c,s> of {
<Bare,_> => "أيّ" ;
<Nom,Indef> => "أيٌّ" ; <Nom,Indef> => "أيٌّ" ;
<Nom,_> => "أيُّ" ; <Nom,_> => "أيُّ" ;
<Acc,Indef> => "أيّاً" ; <Acc,Indef> => "أيّاً" ;