1
0
forked from GitHub/gf-rgl

Merge pull request #163 from inariksit/persian-fixes

Persian fixes
This commit is contained in:
Inari Listenmaa
2019-02-07 20:22:14 +01:00
committed by GitHub
8 changed files with 74 additions and 65 deletions

View File

@@ -53,7 +53,7 @@ concrete CatPes of Cat = CommonX - [Adv] ** open ResPes, Prelude in {
---- Noun
CN = ResPes.Noun ;
CN = ResPes.CN ;
NP = ResPes.NP ;
Pron = {s : Str ; ps : Str ; a : Agr};

View File

@@ -12,7 +12,7 @@ concrete ConjunctionPes of Conjunction =
ConjAdv = conjunctDistrSS ;
-- ConjAdv conj advs = conjunctDistrTable Gender conj advs ;
ConjNP conj ss = conjunctDistrTable NPCase conj ss ** {
ConjNP conj ss = ss ** conjunctDistrTable NPCase conj ss ** {
a = conjAgr (agrP3 conj.n) ss.a ;
animacy = ss.animacy ;
} ;
@@ -28,9 +28,9 @@ concrete ConjunctionPes of Conjunction =
-- BaseAdv x y = twoTable Gender x y ;
ConsAdv = consrSS comma ;
-- ConsAdv xs x = consrTable Gender comma xs x ;
BaseNP x y = twoTable NPCase x y ** {a = conjAgr x.a y.a ; animacy = y.animacy } ; -- check animacy
BaseNP x y = y ** twoTable NPCase x y ** {a = conjAgr x.a y.a ; animacy = y.animacy } ; -- check animacy
BaseRS x y = twoTable Agr x y ** {c = x.c};
ConsNP xs x = consrTable NPCase comma xs x ** {a = conjAgr xs.a x.a ; animacy = xs.animacy } ; -- InaandB xs.animacy x.animacy} ;
ConsNP xs x = xs ** consrTable NPCase comma xs x ** {a = conjAgr xs.a x.a ; animacy = xs.animacy } ; -- InaandB xs.animacy x.animacy} ;
ConsRS xs x = consrTable Agr comma xs x ** { c = xs.c};
-- BaseAP x y = twoTable3 Number Gender Case x y ; -- ** {isPre = andB x.isPre y.isPre} ;
BaseAP x y = twoTable Ezafa x y ** {adv = x.adv};
@@ -39,7 +39,7 @@ concrete ConjunctionPes of Conjunction =
lincat
[S] = {s1,s2 : Str} ;
[Adv] = {s1,s2 : Str} ;
[NP] = {s1,s2 : NPCase => Str ; a : Agr ; animacy : Animacy } ;
[NP] = {s1,s2 : NPCase => Str ; a : Agr ; animacy : Animacy ; hasAdj : Bool} ;
[AP] = {s1,s2 : Ezafa => Str ; adv : Str} ;
[RS] = {s1,s2 : Agr => Str };

View File

@@ -55,23 +55,24 @@ oper
oper
mkEzafa : Str -> Str ;
mkEzafa str = case str of {
st + "اه" => str ;
st + "وه" => str ;
mkEzafa str = let kasre = "ِ" in
case str of {
st + "اه" => str + kasre ;
st + "وه" => str + kasre ;
st + "ه" => st + "ۀ" ; -- str ++ "ی" ;
st + "او" => str ;
st + "وو" => str ;
st + "او" => str + kasre ;
st + "وو" => str + kasre ;
st + "و" => str + "ی" ;
st + "ا" => str + "ی" ;
_ => str
};
_ => str + kasre
};
mkEnclic : Str -> Str ;
mkEnclic str = case str of {
st + "ا" => str ++ "یی" ;
st + "و" => str ++ی" ;
st + "ی" => str ++ "یی" ; -- TODO
st + "ه" => str ++ی" ;
_ => str + "ی"
st + ("ا"|"و") => zwnj str "یی" ; -- ی after a long vowel to help pronunciation
st + "اه" => str + "ی" ; -- here ه is a consonant, so single ی
st + ("ی"|"ه") => zwnj str "ای" ; -- after ی or ه as a vowel, add an alif to help pronunciation
_ => str + "ی" -- any other case: just a single ی
} ;
Noun = {s : Ezafa => Number => Str ; animacy : Animacy ; definitness : Bool } ;

View File

@@ -3,19 +3,18 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
flags optimize=all_subs ;
lin
DetCN det cn = { s = \\_ =>
case <det.isNum,det.fromPron> of {
<False,True> => cn.s ! aEzafa ! det.n ++ det.s ;
<False,False> => det.s ++ cn.s ! bEzafa ! det.n ;
<True,True> => cn.s ! aEzafa ! Sg ++ det.s ; -- noun modified by a number is invariably singular
<True,False> => det.s ++ cn.s ! bEzafa ! Sg
};
DetCN det cn = cn ** {s = \\npc =>
case <det.isNum,det.fromPron,npc> of {
<False,False,NPC ez> => det.s ++ cn.s ! ez ! det.n ; -- det is not from Pron, retain NPForm.
<False,True> => cn.s ! aEzafa ! det.n ++ det.s ; -- det is from Pron, cn is in aEzafa.
<True,False,NPC ez> => det.s ++ cn.s ! ez ! Sg ; -- noun modified by a number is invariably singular
<True,True> => cn.s ! aEzafa ! Sg ++ det.s
} ;
a = agrP3 det.n ;
animacy = cn.animacy
} ;
UsePN pn = {s = \\_ => pn.s ; a = agrP3 Sg ; animacy = pn.animacy } ;
UsePron p = {s = \\_ => p.s ; a = p.a ; animacy = Animate} ;
UsePN pn = pn ** {s = \\_ => pn.s ; a = agrP3 Sg ; hasAdj = False} ;
UsePron p = p ** {s = \\_ => p.s ; animacy = Animate ; hasAdj = False} ;
PredetNP pred np = np ** {
s = \\ez => pred.s ++ np.s ! ez
@@ -50,6 +49,7 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
DetNP det = {
s = \\_ => det.s ; ---- case
a = agrP3 det.n ;
hasAdj = False ;
animacy = Inanimate
} ;
@@ -73,47 +73,42 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
DefArt = {s = \\_ => [] ; a = defaultAgr ; fromPron = False} ;
IndefArt = {s = table { Sg => IndefArticle ; Pl => []} ; a =defaultAgr ; fromPron = False} ;
MassNP cn = {s =\\c => case c of {
MassNP cn = cn ** {s =\\c => case c of {
NPC bEzafa => cn.s ! bEzafa ! Sg ;
NPC aEzafa => cn.s ! aEzafa ! Sg ;
NPC enClic => cn.s ! enClic ! Sg
};
a = agrP3 Sg ;
animacy = cn.animacy
} ;
UseN n = n ;
UseN2 n = n ;
UseN n = n ** {hasAdj=False};
UseN2 n = n ** {hasAdj=False};
Use2N3 f = {
s = f.s;
Use2N3 f = f ** {
c = f.c2;
animacy = f.animacy;
definitness = True
} ;
Use3N3 f = {
s = f.s ;
Use3N3 f = f ** {
c = f.c3;
animacy = f.animacy;
definitness = True
} ;
ComplN2 f x = {
ComplN2 f x = f ** {
s = \\ez,n => f.s ! ez ! n ++ f.c ++ x.s ! NPC ez ;
animacy = f.animacy;
definitness = True
definitness = True ;
hasAdj = False ;
};
ComplN3 f x = {
ComplN3 f x = f ** {
s = \\ez,n => f.s ! ez ! n ++ f.c2 ++ x.s ! NPC ez ;
c = f.c3;
animacy = f.animacy;
definitness = True;
} ;
AdjCN ap cn = cn ** {
s = \\ez,n => cn.s ! aEzafa ! n ++ ap.s ! ez -- check the form of adjective and also cn.s!ez!n changed from cn.s!aEzafa!n to have correct enclicitic form other wise it creats wrong enclictic form of old man
} ;
s = \\ez,n => cn.s ! aEzafa ! n ++ ap.s ! ez ; -- check the form of adjective and also cn.s!ez!n changed from cn.s!aEzafa!n to have correct enclicitic form other wise it creats wrong enclictic form of old man
hasAdj = True
} ;
RelCN cn rs = cn ** {
s = \\ez,n => cn.s ! enClic ! n ++ rs.s ! agrP3 n ;

View File

@@ -25,7 +25,8 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
oper
Compl : Type = {s : Str ; ra : Str ; c : VType} ;
NP : Type = {s : NPCase => Str ; a : Agr ; animacy : Animacy } ;
CN : Type = Noun ** {hasAdj : Bool} ; -- for getting the right form when NP/CN is a predicate
NP : Type = {s : NPCase => Str ; a : Agr ; animacy : Animacy ; hasAdj : Bool} ;
VPHSlash : Type = VPH ** {c2 : Compl} ;
oper
@@ -34,6 +35,11 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
Neg => CNeg b
} ;
cpol2pol : CPolarity -> Polarity = \cp -> case cp of {
CPos => Pos ;
_ => Neg
} ;
-----------------------
--- Verb Phrase
-----------------------
@@ -144,7 +150,7 @@ oper
insertVV : (Agr => Str) -> VPH -> VPH = \obj1,vp -> vp ** {
wish = True ;
vComp = \\a => vp.comp ! a ++ obj1 ! a ;
vComp = \\a => vp.comp ! a ++ conjThat ++ obj1 ! a ;
} ;
insertObj2 : (Str) -> VPH -> VPH = \obj1,vp -> vp ** {

View File

@@ -10,12 +10,12 @@ concrete SentencePes of Sentence = CatPes ** open Prelude, ResPes,Predef in {
PredSCVP sc vp = mkSClause ("این" ++ sc.s) (defaultAgr) vp ;
ImpVP vp = {
s = \\pol,n =>
s = \\cpol,n =>
let agr = Ag (numImp n) P2 ;
in case pol of {
CPos => vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.vComp ! agr ++ vp.s ! VPImp Pos (numImp n) ++ vp.embComp;
CNeg _ => vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.vComp ! agr ++ vp.s ! VPImp Neg (numImp n) ++ vp.embComp
} ;
pol = cpol2pol cpol ;
in case vp.wish of {
True => vp.s ! VPImp pol (numImp n) ++ vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.vComp ! agr ++ vp.embComp;
False => vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.vComp ! agr ++ vp.s ! VPImp pol (numImp n) ++ vp.embComp }
} ;

View File

@@ -10,20 +10,17 @@ concrete SymbolPes of Symbol = CatPes ** open Prelude, ResPes in {
IntPN i = {s = i.s ; animacy = Inanimate} ;
FloatPN i = {s = i.s ; animacy = Inanimate} ;
NumPN i = {s = i.s ; animacy = Inanimate} ;
CNIntNP cn i = {
CNIntNP cn i = cn ** {
s = \\ez => cn.s ! aEzafa ! Sg ++ i.s ;
a = agrP3 Sg ;
animacy = cn.animacy
a = agrP3 Sg
} ;
CNSymbNP det cn xs = {
CNSymbNP det cn xs = cn ** {
s = \\ez => det.s ++ cn.s ! aEzafa ! det.n ++ xs.s ;
a = agrP3 det.n ;
animacy = cn.animacy
a = agrP3 det.n
} ;
CNNumNP cn i = {
CNNumNP cn i = cn ** {
s = \\ez => cn.s ! aEzafa ! Sg ++ i.s ;
a = agrP3 Sg ;
animacy = cn.animacy
a = agrP3 Sg
} ;
SymbS sy = sy ;

View File

@@ -1,4 +1,4 @@
concrete VerbPes of Verb = CatPes ** open ResPes in {
concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
flags coding = utf8;
flags optimize=all_subs ;
@@ -42,9 +42,19 @@ concrete VerbPes of Verb = CatPes ** open ResPes in {
PassV2 v = predV v ; -- need to be fixed
CompAP ap ={s = \\_ => ap.s ! bEzafa} ; -- check form of adjective
CompAdv adv = {s = \\_ => adv.s } ;
CompCN cn = {s = \\a => cn.s ! bEzafa ! giveNumber a } ;
-- IL 2019-01-31 changed bEzafa to enClic according to
-- https://sites.la.utexas.edu/persian_online_resources/nouns/noun-in-a-predicative-position/
CompNP np = {s = \\a => np.s ! NPC enClic} ;
-- see https://sites.la.utexas.edu/persian_online_resources/nouns/noun-in-a-predicative-position/
CompCN cn = {
s = \\a => cn.s ! case cn.hasAdj of {
False => bEzafa ;
True => enClic }
! giveNumber a
} ;
CompNP np = {
s = \\a => np.s ! case np.hasAdj of {
False => NPC bEzafa ;
True => NPC enClic }
} ;
}