1
0
forked from GitHub/gf-rgl

Merge pull request #102 from inariksit/arabic

Arabic
This commit is contained in:
Inari Listenmaa
2018-12-18 16:55:35 +01:00
committed by GitHub
9 changed files with 132 additions and 98 deletions

View File

@@ -1,4 +1,4 @@
concrete ConstructionAra of Construction = CatAra ** open
concrete ConstructionAra of Construction = CatAra ** open
Prelude,
ParadigmsAra,
SyntaxAra,
@@ -7,7 +7,7 @@ concrete ConstructionAra of Construction = CatAra ** open
(E=ExtendAra),
(R=ResAra),
(L=LexiconAra) in {
lincat
Timeunit = N ;
Weekday = N ;
@@ -17,18 +17,25 @@ lincat
lin
timeunitAdv n time =
timeunitAdv n time =
let n_card : Card = n ;
n_hours_NP : NP = mkNP n_card time ;
in SyntaxAra.mkAdv during_Prep n_hours_NP | ParadigmsAra.mkAdv (n_hours_NP.s ! R.Nom) ;
-- random guesses
weekdayPunctualAdv w = SyntaxAra.mkAdv on_Prep (mkNP w) ; -- on Sunday
weekdayHabitualAdv w = SyntaxAra.mkAdv on_Prep (mkNP w) ; -- on Sundays
weekdayNextAdv w = SyntaxAra.mkAdv on_Prep (mkNP w) ; -- next Sunday
weekdayLastAdv w = SyntaxAra.mkAdv on_Prep (mkNP w) ; -- last Sunday
weekdayPunctualAdv w = ParadigmsAra.mkAdv ((mkNP w).s ! R.Nom) ; -- on Sunday
-- weekdayPunctualAdv w = SyntaxAra.mkAdv noPrep (mkNP w) ; -- on Sunday
-- TODO
weekdayHabitualAdv, -- on Sundays
weekdayNextAdv, -- next Sunday
weekdayLastAdv = weekdayPunctualAdv ; -- last Sunday
monthAdv january =
let january_CN : CN = mkCN month_Timeunit (mkNP (mkPN january)) ;
january_NP : NP = R.emptyNP **
{s = \\c => R.cn2str january_CN R.Sg R.Const c ;
a = {pgn = R.Per3 january_CN.g R.Sg ; isPron = False}} ;
in SyntaxAra.mkAdv R.biPrep january_NP ;
monthAdv m = SyntaxAra.mkAdv in_Prep (mkNP m) ;
yearAdv y = SyntaxAra.mkAdv in_Prep y ;
-- dummy
@@ -48,14 +55,14 @@ oper
lin
-- : NP -> NP -> Cl
have_name_Cl np nm =
have_name_Cl np nm =
let subjPron : Pron = R.np2pron np ;
me : NP = toNP np.a.isPron np ;
myName : NP = E.ApposNP me (mkNP (mkDet subjPron) L.name_N) ;
in mkCl myName nm ;
-- : NP -> QCl
what_name_QCl np =
what_name_QCl np =
let subjPron : Pron = R.np2pron np ;
me : R.NP = toNP np.a.isPron np ;
myName : NP = E.ApposNP me (mkNP (mkDet subjPron) L.name_N) ;
@@ -91,31 +98,31 @@ oper mkLanguage : Str -> N = mkN ;
lin second_Timeunit = mkN "second" ;
lin minute_Timeunit = mkN "minute" ;
lin hour_Timeunit = mkN "hour" ;
lin day_Timeunit = mkN "day" ;
lin day_Timeunit = mkN "يَوْم" ;
lin week_Timeunit = mkN "week" ;
lin month_Timeunit = mkN "month" ;
lin month_Timeunit = mkN "شَهْر" "أَشْهُر" masc nohum ;
lin year_Timeunit = mkN "year" ;
lin monday_Weekday = mkN "Monday" ;
lin tuesday_Weekday = mkN "Tuesday" ;
lin wednesday_Weekday = mkN "Wednesday" ;
lin thursday_Weekday = mkN "Thursday" ;
lin friday_Weekday = mkN "Friday" ;
lin saturday_Weekday = mkN "Saturday" ;
lin sunday_Weekday = mkN "Sunday" ;
lin monday_Weekday = mkN day_Timeunit (mkN "إثْنَيْن") ;
lin tuesday_Weekday = mkN day_Timeunit (mkN "ثُلَاثَاء") ;
lin wednesday_Weekday = mkN day_Timeunit (mkN "أَرْبَعَاء") ;
lin thursday_Weekday = mkN day_Timeunit (mkN "خَمِيس") ;
lin friday_Weekday = mkN day_Timeunit (mkN "جُمْعَة") ;
lin saturday_Weekday = mkN day_Timeunit (mkN "سَبْت") ;
lin sunday_Weekday = mkN day_Timeunit (mkN "أَحَد") ;
lin january_Month = mkN "January" ;
lin february_Month = mkN "February" ;
lin march_Month = mkN "March" ;
lin april_Month = mkN "April" ;
lin may_Month = mkN "May" ;
lin june_Month = mkN "June" ;
lin july_Month = mkN "July" ;
lin august_Month = mkN "August" ;
lin september_Month = mkN "September" ;
lin october_Month = mkN "October" ;
lin november_Month = mkN "November" ;
lin december_Month = mkN "December" ;
lin january_Month = mkN (mkN "كَانُون") (mkAP (mkOrd (mkNumeral n2_Unit))) ;
lin february_Month = mkN "شُبَاط" ;
lin march_Month = mkN "آذَار" ;
lin april_Month = mkN "نَيْسَان" ;
lin may_Month = mkN "أَيَّار" ;
lin june_Month = mkN "حَزِيرَان" ;
lin july_Month = mkN "تَمُّوز" ;
lin august_Month = mkN "آب" ;
lin september_Month = mkN "أَيْلُول" ;
lin october_Month = mkN (mkN "تِشْرِين") (mkAP (mkOrd (mkNumeral n1_Unit))) ;
lin november_Month = mkN (mkN "تِشْرِين") (mkAP (mkOrd (mkNumeral n2_Unit))) ;
lin december_Month = mkN (mkN "كَانُون") (mkAP (mkOrd (mkNumeral n1_Unit))) ;
-- lin afrikaans_Language = mkLanguage "Afrikaans" ;
-- lin amharic_Language = mkLanguage "Amharic" ;
@@ -140,7 +147,7 @@ lin finnish_Language = mkLanguage "فِنْلَنْدِيّة" ;
-- lin maltese_Language = mkLanguage "Maltese" ;
-- lin nepali_Language = mkLanguage "Nepali" ;
-- lin norwegian_Language = mkLanguage "Norwegian" ;
lin nprsian_Language = mkLanguage "فَارِسيّة" ;
lin persian_Language = mkLanguage "فَارِسيّة" ;
-- lin polish_Language = mkLanguage "Polish" ;
-- lin punjabi_Language = mkLanguage "Punjabi" ;
-- lin romanian_Language = mkLanguage "Romanian" ;

View File

@@ -20,7 +20,7 @@ concrete ExtendAra of Extend =
in {
lin
GenNP np = {s = \\_,_,_,_ => np.s ! Gen ; d = Const ; isNum,isPron,is1sg = False} ;
GenNP np = baseQuant ** {s = \\_,_,_,_ => np.s ! Gen ; d = Const} ;
-- : NP -> NP -> NP
ApposNP np1 np2 = np2 ** {s = \\c => np1.s ! c ++ np2.s ! c} ;

View File

@@ -11,8 +11,8 @@ concrete IdiomAra of Idiom = CatAra ** open
-- : VP -> Cl ; -- it is hot
ImpersCl vp =
let it : ResAra.NP = case vp.isPred of {
True => pron2np (pgn2pron vp.obj.a.pgn) ;
False => pgn2pron vp.obj.a.pgn } ; -- if no obj, Per3 Masc Sg chosen by default
True => pron2np (gn2pron vp.obj.a.gn) ;
False => gn2pron vp.obj.a.gn } ; -- if no obj, Per3 Masc Sg chosen by default
in predVP it vp ;
-- : VP -> Cl ; -- one sleeps

View File

@@ -6,14 +6,11 @@ flags optimize = all ;--noexpand;
oper
mkDet : Str -> Number -> State -> Det
= \word,num,state ->
= \word,num,state -> baseQuant **
{ s = \\_,_,c => word + caseTbl ! c ;
n = numberToSize num;
d = state; --only Const is used now. check StructuralAra
is1sg = False;
isNum = False;
isPron = False
};
} ;
mkPredet : Str -> Bool -> Predet
= \word,decl ->

View File

@@ -13,7 +13,7 @@ lin
_ => Dl } ;
False => sizeToNumber det.n } ;
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 -> Str = \c ->
cn.s ! number
! nounState det.d number
@@ -23,16 +23,17 @@ lin
! (definite ! det.d) -- Indef remains Indef, rest become Def
! c
} in {
s = \\c =>
case cnB4det det.isPron det.isNum det.n det.d of {
False => determiner c
++ noun c
++ adj c
++ cn.np ! c ;
s = \\c => -- Dat is just a hack for liPrep
let c' = case c of {Dat => Gen ; x => x} in
case cnB4det det of {
False => determiner c'
++ noun c'
++ adj c'
++ cn.np ! c' ;
True => noun (cas c) -- deal with possessive suffix
++ determiner c -- (nounCase c det.n det.d) --??
++ adj c
++ cn.np ! c
++ determiner c'
++ adj c'
++ cn.np ! c'
};
a = { pgn = agrP3 cn.h cn.g number;
isPron = False } ;
@@ -81,10 +82,10 @@ lin
! case d of {Poss => Def ; _ => d}
! c ;
n = num.n;
isNum = orB num.isNum ord.isNum ;
isNum = orB num.isNum ord.isNum ;
-- ord may come from OrdDigits or OrdNumeral
-- num may come from NumCard : Card -> Num
isEmpty = False
} ;
DetQuant quant num = quant ** {
@@ -95,15 +96,18 @@ lin
case num.n of {
None => False;
_ => num.isNum
}
} ;
isEmpty =
case quant.isEmpty of {
True => notB num.isNum ;
_ => False }
} ;
PossPron p = {
PossPron p = baseQuant ** {
s = \\_,_,_,_ => BIND ++ p.s ! Gen;
d = Poss;
is1sg = case p.a.pgn of { Per1 Sing => True ; _ => False } ;
isPron = True;
isNum = False } ;
isPron = True} ;
NumSg = {
s = \\_,_,_ => [] ;
@@ -154,13 +158,15 @@ lin
DefArt = {
s = \\_,_,_,_ => [];
d = Def ;
isNum,isPron,is1sg = False
isNum,isPron,is1sg = False ;
isEmpty = True
} ;
IndefArt = {
s = \\_,_,_,_ => [];
d = Indef ;
isNum,isPron,is1sg = False
isNum,isPron,is1sg = False ;
isEmpty = True
} ;
MassNP cn =
@@ -168,7 +174,6 @@ lin
a = {pgn = Per3 cn.g Sg ; isPron = False} ;
empty = []} ;
UseN,
UseN2 = useN ;
Use2N3 n3 = n3 ;

View File

@@ -27,7 +27,9 @@ resource ParadigmsAra = open
Predef,
Prelude,
MorphoAra,
OrthoAra,(ResAra=ResAra),
OrthoAra,
(ResAra=ResAra),
(A=AdjectiveAra),
CatAra
in {
@@ -75,8 +77,10 @@ resource ParadigmsAra = open
mkN : NTable -> Gender -> Species -> N ; -- loan words, irregular
mkN : (root,sgPatt,brokenPlPatt : Str) -> Gender -> Species -> N ; -- broken plural
mkN : N -> (attr : Str) -> N ; -- Compound noun with invariant attribute
mkN : N -> N -> N ; -- Compound noun where attribute inflects in state and case. Attribute in singular.
mkN : Number -> N -> N -> N ; -- Compound noun where attribute inflects in state and case. Attribute's number specified by 1st arg.
mkN : N -> N -> N ; -- Compound noun with singular genitive attribute, but inflects in state.
mkN : Number -> N -> N -> N ; -- Compound noun with genitive attribute, but inflects in state. Attribute's number specified by 1st arg.
mkN : N -> A -> N ; -- Force adjective modifier into the noun. Adjective inflects in state, case and number.
mkN : N -> AP -> N ; -- Force AP modifier into the noun. AP inflects in state, case and number.
--- mkN : (root,sgPatt : Str) -> Gender -> Species -> N -- sound feminine plural
--- = sdfN ;
} ;
@@ -106,7 +110,7 @@ resource ParadigmsAra = open
mkPN : Str -> PN -- Fem Hum if ends with ة, otherwise Masc Hum
= smartPN ;
mkPN : N -> PN
= \n -> lin PN (n ** {s = \\c => n.s ! Sg ! Const ! c ++ n.s2 ! Sg ! Const ! c }) ; -- no idea /IL
= \n -> lin PN (n ** {s = \\c => n.s ! Sg ! Const ! c ++ n.s2 ! Sg ! Def ! c }) ; -- no idea /IL
mkPN : Str -> Gender -> Species -> PN
= mkFullPN ;
} ;
@@ -360,6 +364,11 @@ resource ParadigmsAra = open
= attrN Sg ;
mkN : Number -> N -> N -> N -- Compound nouns where attribute inflects in state, case and number
= attrN ;
mkN : N -> A -> N
= mkAN ;
mkN : N -> AP -> N
= mkAPN
} ;
attrN : Number -> N -> N -> N = \num,n1,n2 -> n1 ** {
@@ -368,6 +377,13 @@ resource ParadigmsAra = open
++ n2.s ! num ! s ! Gen
++ n2.s2 ! num ! s ! Gen} ;
mkAN : N -> A -> N = \n,a -> mkAPN n (A.PositA a) ;
mkAPN : N -> AP -> N = \n,ap -> n ** {
s2 = \\num,s,c => n.s2 ! num ! s ! c
++ ap.s ! n.h ! n.g ! num ! s ! c
} ;
dualN : N -> N = \n -> n ** {isDual=True} ;
proDrop : NP -> NP ; -- Force a NP to lose its string, only contributing with its agreement.

View File

@@ -162,7 +162,7 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
AP : Type = {s : Species => Gender => NTable } ;
uttAP : AP -> (Gender => Str) ;
uttAP ap = \\g => ap.s ! NoHum ! g ! Sg ! Def ! Nom ; ----IL
uttAP ap = \\g => ap.s ! NoHum ! g ! Sg ! Indef ! Bare ; ----IL
CN : Type = Noun ** {np : Case => Str};
@@ -184,7 +184,7 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
} ;
uttNum : NumOrdCard -> (Gender => Str) ;
uttNum n = \\g => n.s ! g ! Def ! Nom ; ----IL
uttNum n = \\g => n.s ! g ! Def ! Bare ; ----IL
param
VForm =
@@ -1155,7 +1155,6 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
--declension 2 (ends in yaa')
dec2sg : State => Case => Str = \\s,c =>
case <s,c> of {
<_, Bare> => [] ;
<Indef,Acc> => "ِياً" ;
<Indef> => "ٍ" ;
<_, Acc> => "ِيَ" ;
@@ -1311,13 +1310,14 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
-- e.g. some determiners act as adjectives modifying the noun they count
-- 'the three children, two children'
-- e.g. possesive pronouns: his book ('kitaabuhu'
cnB4det : Bool -> Bool -> Size -> State -> Bool = \isPron,isNum,s,d ->
case <isPron,isNum,s,d> of {
<True,_,_,_> => True;
<_,False,_,_> => False; --non-numerals
<_,True,_,Def> => True; --definite numbers act as adjectives
<_,True,Two,_> => True; --numerals one and two always adjectives
<_,True,One,_> => True; --numerals one and two always adjectives
cnB4det : Det -> Bool = \det ->
case <det.isEmpty,det.isPron,det.isNum,det.n,det.d> of {
<True,_,_,_,_> => True; -- hack to make liPrep work
<_,True,_,_,_> => True;
<_,_,False,_,_> => False; --non-numerals
<_,_,True,_,Def> => True; --definite numbers act as adjectives
<_,_,True,Two,_> => True; --numerals one and two always adjectives
<_,_,True,One,_> => True; --numerals one and two always adjectives
_ => False
};
@@ -1369,10 +1369,11 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
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;
isEmpty: Bool} ; -- to know if liPrep should attach to the noun
baseQuant = { d = Indef ;
is1sg,isNum,isPron = False } ;
is1sg,isNum,isPron,isEmpty = False } ;
Quant : Type = BaseQuant ** {
s : ResAra.Number => Species => Gender => Case => Str
@@ -1388,9 +1389,11 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
isDecl : Bool
};
Agr = { pgn : PerGenNum; isPron : Bool} ;
AAgr = { g : Gender ; n : Number} ;
Agr = {pgn : PerGenNum; isPron : Bool} ;
AgrLite = {gn : AAgr ; isPron : Bool} ; --used in ImpersCl
AAgr = {g : Gender ; n : Number} ;
agrLite : Agr -> AgrLite = \a -> a ** {gn = pgn2gn a.pgn} ;
-----------------------------------------------------------------------------
-- NP, Pron
@@ -1481,6 +1484,9 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
Per3 Masc Pl => theyMasc_Pron
} ;
gn2pron : AAgr -> NP = \gn ->
pgn2pron (gn2pgn gn) ;
pron2np : NP -> NP = \np -> np ** {
a = np.a ** {isPron=False} -- hack, sometimes we *don't* want prodrop
} ;
@@ -1572,9 +1578,9 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
{ s = \\pgn,vf =>
let gn = pgn2gn pgn in
case vf of {
VPPerf => v.s ! (VPerf Act pgn);
VPImpf m => v.s ! (VImpf m Act pgn);
VPImp => v.s ! (VImp gn.g gn.n)
VPPerf => v.s ! VPerf Act pgn ;
VPImpf m => v.s ! VImpf m Act pgn ;
VPImp => v.s ! VImp gn.g gn.n
};
sc = noPrep ;
obj = emptyObj ;
@@ -1587,8 +1593,8 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
let actVP = predV v in actVP ** {
s = \\pgn,vf =>
case vf of {
VPPerf => v.s ! (VPerf Pas pgn) ;
VPImpf m => v.s ! (VImpf m Pas pgn) ;
VPPerf => v.s ! VPerf Pas pgn ;
VPImpf m => v.s ! VImpf m Pas pgn ;
_ => actVP.s ! pgn ! vf
}
};
@@ -1609,7 +1615,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
True => noPrep ; -- to prevent weird stuff with VVs, might be overly specific
_ => vp.sc }
} ;
subj = np.empty ++ sc.s
subj = np.empty ++ sc.s ++ bindIf sc.binds
++ case vp.isPred of {
False => (proDrop np).s ! sc.c ; -- prodrop if it's not predicative
True => np.s ! sc.c
@@ -1694,20 +1700,20 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
Obj : Type = {
s : Str ;
a : Agr -- default Agr in a VP without real Obj is Per3 Masc Sg.
a : AgrLite -- default Agr in a VP without real Obj is Per3 Masc Sg.
}; -- need isPron for word order in predVP, and pgn for ImpersCl
Subj : Type = {s : Case => Str ; isPron : Bool} ;
np2subj : NP -> Subj = \np -> np ** {isPron = np.a.isPron} ;
subj2np : Subj -> NP = \su -> su ** {a = {pgn = emptyNP.a.pgn ; isPron = su.isPron} ; empty=[]} ;
emptyObj : Obj = emptyNP ** {s=[]} ;
emptyObj : Obj = {a = {gn = {g=Masc ; n=Sg} ; isPron = False}; s = []} ;
insertObj : NP -> VPSlash -> VP = \np,vp -> vp ** {
obj = {s = vp.obj.s -- old object, if there was one
++ bindIfPron np vp -- new object, bind if pronoun and not pred
++ vp.agrObj ! np.a.pgn ; -- only used for SlashV2V
a = np.a}
a = agrLite np.a}
} ;
bindIf : Bool -> Str = \b -> if_then_Str b BIND [] ;
@@ -1844,29 +1850,30 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
{ s = table {
unit => table {
NCard => table {
Masc => \\s,c => Al ! s + "ٱِثن" + dl ! s ! c ;
Fem => \\s,c => Al ! s + "ٱِثنَت" + dl ! s ! c
Masc => \\s,c => defArt s c "ٱِثن" + dl ! s ! c ;
Fem => \\s,c => defArt s c "ٱِثنَت" + dl ! s ! c
};
NOrd => table {
Masc => \\s,c => Al ! s + "ثان" + dec2sg ! s ! c ;
Fem => \\s,c => Al ! s + "ثانِيَة" + dec1sg ! s ! c
Masc => \\s,c => defArt s cَان" + dec2sg ! s ! c ;
Fem => \\s,c => defArt s cَانِيَة" + dec1sg ! s ! c
}
};
ten => \\_,_,s,c => Al ! s + "عِشر" + m_pl ! Indef ! c
ten => \\_,_,s,c => defArt s c "عِشر" + m_pl ! Indef ! c
}
};
num100 : State => Case => Str =
\\s,c => Al ! s + "مِٱَة" + dec1sg ! s ! c;
\\s,c => defArt s c "مِٱَة" + dec1sg ! s ! c;
num200 : State => Case => Str =
\\s,c => Al ! s + "مِٱَة" + dl ! s ! c ;
\\s,c => defArt s c "مِٱَة" + dl ! s ! c ;
num1000 : State => Case => Str =
\\s,c => Al ! s + "أَلف" + dec1sg ! s ! c;
\\s,c => defArt s c "أَلف" + dec1sg ! s ! c;
num2000 : State => Case => Str =
\\s,c => Al ! s + "أَلف" + dl ! s ! c ;
\\s,c => defArt s c "أَلف" + dl ! s ! c ;
teen : Gender => Str =
table {

View File

@@ -64,7 +64,7 @@ concrete StructuralAra of Structural = CatAra **
no_Utt = {s = \\_ => "لا"} ;
on_Prep = mkPrep "عَلَى" ;
only_Predet = mkPredet "فَقَط" False;
-- or_Conj = ss "ْر" ** {n = Sg} ;
or_Conj = ss "أَوْ" ** {n = Sg} ;
-- otherwise_PConj = ss "ْتهروِسي" ;
part_Prep = mkPrep "مِنَ" ;
-- please_Voc = ss "ةلَسي" ;

View File

@@ -97,7 +97,9 @@ concrete VerbAra of Verb = CatAra ** open Prelude, ResAra, ParamX in {
CompCN cn = {s = \\agr,c => cn2str cn agr.n Indef Nom ;
obj = emptyObj ; isNP = False} ;
CompNP np = {s = \\_,_ => [] ; obj = np ** {s = np.s ! Nom} ; isNP = True} ;
CompNP np = {s = \\_,_ => [] ;
obj = {s = np.s ! Nom ; a = agrLite np.a} ;
isNP = True} ;
--
--
}