1
0
forked from GitHub/gf-rgl

Merge pull request #50 from inariksit/arabic

Arabic
This commit is contained in:
Inari Listenmaa
2018-10-22 17:15:10 +02:00
committed by GitHub
4 changed files with 40 additions and 43 deletions

View File

@@ -5,26 +5,28 @@ flags optimize=noexpand ;
lin lin
DetCN det cn = let { DetCN det cn = let {
number = sizeToNumber det.n; cas : Case -> Case = if_then_else Case det.is1sg Bare ;
state = possState det.d; number = sizeToNumber det.n ;
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 -> noun : Case -> Str = \c ->
let cas = if_then_else Case det.is1sg Bare c -- no case vowel with 1sg poss. suff. cn.s ! number
in nt ! number ! nounState det.d number
! nounState det.d number ! nounCase c det.n det.d ;
! nounCase cas det.n det.d adj : Case -> Str = \c ->
cn.adj ! number
! (definite ! det.d) -- Indef remains Indef, rest become Def
! c
} 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 False => determiner c
++ noun c cn.s -- deal with poss. suffix ++ noun c
++ cn.adj ! number ! state ! c -- normal case+state ++ adj c
++ cn.np ! c ; ++ cn.np ! c ;
True => noun c cn.s -- deal with poss. suffix True => noun (cas c) -- deal with possessive suffix
-- ++ determiner c -- or this? ++ determiner c
++ det.s ! cn.h ! cn.g ! c ++ adj c
++ cn.adj ! number ! state ! c -- normal case+state
++ cn.np ! c ++ cn.np ! c
}; };
a = { pgn = agrP3 cn.h cn.g number; a = { pgn = agrP3 cn.h cn.g number;
@@ -45,23 +47,20 @@ lin
}; };
a = np.a a = np.a
} ; } ;
{-
--should compile.. not working :( wierd error message.. bug? {-
PPartNP np v2 = PPartNP np v2 =
let x = case np.a.pgn of { let x = case np.a.pgn of {
Per3 g n => ( positAdj (v2.s ! VPPart) ) ! g ! n ! Indef ; Per3 g n => positAdj (v2.s ! VPPart) ) ! g ! n ! Indef ; -- doesn't work because trying to glue runtime tokens
_ => \\_ => [] -- not occuring anyway Per2 g n => \\_ => [] ;
} in { _ => \\_ => []
s = \\c => np.s ! c ++ x ! c ; } in np ** {
a = np.a s = \\c => np.s ! c ++ v2.s ! VPPart ---- TODO: agreement
}; };
-} -}
-- FIXME try parsing something like "this house now" and you'll get AdvNP np adv = np ** {
-- an internal compiler error, but it still works.. wierd.. s = \\c => np.s ! c ++ adv.s
AdvNP np adv = {
s = \\c => np.s ! c ++ adv.s;
a = np.a
}; };
{- {-
DetSg quant ord = { DetSg quant ord = {
@@ -104,7 +103,7 @@ lin
PossPron p = { PossPron p = {
s = \\_,_,_,_ => p.s ! Gen; s = \\_,_,_,_ => p.s ! Gen;
d = Poss; d = Poss;
is1sg = case p.a.pgn of { Per1 _ => True ; _ => False } ; is1sg = case p.a.pgn of { Per1 Sing => True ; _ => False } ;
isPron = True; isPron = True;
isNum = False } ; isNum = False } ;

View File

@@ -435,8 +435,8 @@ resource ParadigmsAra = open
mkPron : (_,_,_ : Str) -> PerGenNum -> NP = \ana,nI,I,pgn -> mkPron : (_,_,_ : Str) -> PerGenNum -> NP = \ana,nI,I,pgn ->
{ s = { s =
table { table {
Acc => nI; Acc => BIND ++ nI; -- object suffix
Gen => I; Gen => BIND ++ I; -- possessive suffix
_ => ana _ => ana
}; };
a = {pgn = pgn; isPron = True }; a = {pgn = pgn; isPron = True };

View File

@@ -48,8 +48,6 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
--for roots with 2 consonants (works also for assimilated strs, like fc~, --for roots with 2 consonants (works also for assimilated strs, like fc~,
--because the function discards anything after the first two characters --because the function discards anything after the first two characters
mkRoot2 : Str -> Root2 = \fcl -> mkRoot2 : Str -> Root2 = \fcl ->
-- let { cl = drop 2 fcl} in --drop 1 fcl
-- {f = take 2 fcl; c = take 2 cl}; --take 1
case fcl of { case fcl of {
f@? + c@? + _ => { f = f ; c = c } ; f@? + c@? + _ => { f = f ; c = c } ;
_ => error ("mkRoot2: too short root" ++ fcl) _ => error ("mkRoot2: too short root" ++ fcl)
@@ -138,7 +136,7 @@ resource ResAra = PatternsAra ** open Prelude, Predef, OrthoAra, ParamX in {
VPerf Voice PerGenNum VPerf Voice PerGenNum
| VImpf Mood Voice PerGenNum | VImpf Mood Voice PerGenNum
| VImp Gender Number | VImp Gender Number
| VPPart ; | VPPart ; -- TODO: add gender and number (or check if easy to use BIND)
PerGenNum = PerGenNum =
Per3 Gender Number Per3 Gender Number
@@ -956,7 +954,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
--dual suffixes --dual suffixes
dl : State => Case => Str = dl : State => Case => Str =
table { table {
Const => (Const|Poss) =>
table { table {
Nom => "َا"; Nom => "َا";
_ => "َيْ" _ => "َيْ"
@@ -972,7 +970,7 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
--sound masculine plural suffixes --sound masculine plural suffixes
m_pl : State => Case => Str = m_pl : State => Case => Str =
table { table {
Const => (Const|Poss) =>
table { table {
Nom => "ُو"; Nom => "ُو";
_ => "ِي" _ => "ِي"
@@ -1045,9 +1043,6 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
_ => 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 ->
@@ -1271,7 +1266,10 @@ patHollowImp : (_,_ :Str) -> Gender => Number => Str =\xaf,xAf ->
mkNum : Str -> Str -> Str -> mkNum : Str -> Str -> Str ->
{s : DForm => CardOrd => Gender => State => Case => Str} = {s : DForm => CardOrd => Gender => State => Case => Str} =
\wAhid,awwal,Ula -> \wAhid,awwal,Ula ->
let { wAhida = wAhid + "َة"} in let wAhida : Str = case wAhid of {
x + "ة" => mkAt wAhid ;
_ => wAhid + "َة" }
in
{ s= table { { s= table {
unit => table { unit => table {
NCard => table { NCard => table {

View File

@@ -43,9 +43,9 @@ concrete StructuralAra of Structural = CatAra **
-- how8many_IDet = mkDet "كَمْ" Pl Const ; -- IL: check (was ["هْو مَني"]) ; -- how8many_IDet = mkDet "كَمْ" Pl Const ; -- IL: check (was ["هْو مَني"]) ;
-- if_Subj = ss "ِف" ; -- if_Subj = ss "ِف" ;
in8front_Prep = ss "مُقَابِلَ" ; in8front_Prep = ss "مُقَابِلَ" ;
i_Pron = mkPron "أَنَا" "نِي" "ِي" (Per1 Sing); i_Pron = mkPron "أَنَا" "نِي" "ي" (Per1 Sing);
in_Prep = ss "فِي" ; in_Prep = ss "فِي" ;
it_Pron = mkPron "ِت" "ِت" "ِتس" (Per3 Masc Sg); -- IL: check it_Pron = he_Pron ; -- was: it_Pron = mkPron "ِت" "ِت" "ِتس" (Per3 Masc Sg);
-- less_CAdv = ss "لسّ" ; -- less_CAdv = ss "لسّ" ;
many_Det = mkDet "جَمِيع" Pl Const ; many_Det = mkDet "جَمِيع" Pl Const ;
-- more_CAdv = ss "مْري" ; -- more_CAdv = ss "مْري" ;