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 ---- Noun
CN = ResPes.Noun ; CN = ResPes.CN ;
NP = ResPes.NP ; NP = ResPes.NP ;
Pron = {s : Str ; ps : Str ; a : Agr}; Pron = {s : Str ; ps : Str ; a : Agr};

View File

@@ -12,7 +12,7 @@ concrete ConjunctionPes of Conjunction =
ConjAdv = conjunctDistrSS ; ConjAdv = conjunctDistrSS ;
-- ConjAdv conj advs = conjunctDistrTable Gender conj advs ; -- 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 ; a = conjAgr (agrP3 conj.n) ss.a ;
animacy = ss.animacy ; animacy = ss.animacy ;
} ; } ;
@@ -28,9 +28,9 @@ concrete ConjunctionPes of Conjunction =
-- BaseAdv x y = twoTable Gender x y ; -- BaseAdv x y = twoTable Gender x y ;
ConsAdv = consrSS comma ; ConsAdv = consrSS comma ;
-- ConsAdv xs x = consrTable Gender comma xs x ; -- 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}; 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}; 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 = twoTable3 Number Gender Case x y ; -- ** {isPre = andB x.isPre y.isPre} ;
BaseAP x y = twoTable Ezafa x y ** {adv = x.adv}; BaseAP x y = twoTable Ezafa x y ** {adv = x.adv};
@@ -39,7 +39,7 @@ concrete ConjunctionPes of Conjunction =
lincat lincat
[S] = {s1,s2 : Str} ; [S] = {s1,s2 : Str} ;
[Adv] = {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} ; [AP] = {s1,s2 : Ezafa => Str ; adv : Str} ;
[RS] = {s1,s2 : Agr => Str }; [RS] = {s1,s2 : Agr => Str };

View File

@@ -55,23 +55,24 @@ oper
oper oper
mkEzafa : Str -> Str ; mkEzafa : Str -> Str ;
mkEzafa str = case str of { mkEzafa str = let kasre = "ِ" in
st + "اه" => str ; case str of {
st + "وه" => str ; st + "اه" => str + kasre ;
st + "وه" => str + kasre ;
st + "ه" => st + "ۀ" ; -- str ++ "ی" ; st + "ه" => st + "ۀ" ; -- str ++ "ی" ;
st + "او" => str ; st + "او" => str + kasre ;
st + "وو" => str ; st + "وو" => str + kasre ;
st + "و" => str + "ی" ; st + "و" => str + "ی" ;
st + "ا" => str + "ی" ; st + "ا" => str + "ی" ;
_ => str _ => str + kasre
}; };
mkEnclic : Str -> Str ; mkEnclic : Str -> Str ;
mkEnclic str = case str of { mkEnclic str = case str of {
st + "ا" => str ++ "یی" ; st + ("ا"|"و") => zwnj str "یی" ; -- ی after a long vowel to help pronunciation
st + "و" => str ++ی" ; st + "اه" => str + "ی" ; -- here ه is a consonant, so single ی
st + "ی" => str ++ "یی" ; -- TODO st + ("ی"|"ه") => zwnj str "ای" ; -- after ی or ه as a vowel, add an alif to help pronunciation
st + "ه" => str ++ی" ; _ => str + "ی" -- any other case: just a single ی
_ => str + "ی"
} ; } ;
Noun = {s : Ezafa => Number => Str ; animacy : Animacy ; definitness : Bool } ; 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 ; flags optimize=all_subs ;
lin lin
DetCN det cn = { s = \\_ => DetCN det cn = cn ** {s = \\npc =>
case <det.isNum,det.fromPron> of { case <det.isNum,det.fromPron,npc> of {
<False,True> => cn.s ! aEzafa ! det.n ++ det.s ; <False,False,NPC ez> => det.s ++ cn.s ! ez ! det.n ; -- det is not from Pron, retain NPForm.
<False,False> => det.s ++ cn.s ! bEzafa ! det.n ; <False,True> => cn.s ! aEzafa ! det.n ++ det.s ; -- det is from Pron, cn is in aEzafa.
<True,True> => cn.s ! aEzafa ! Sg ++ det.s ; -- noun modified by a number is invariably singular <True,False,NPC ez> => det.s ++ cn.s ! ez ! Sg ; -- noun modified by a number is invariably singular
<True,False> => det.s ++ cn.s ! bEzafa ! Sg <True,True> => cn.s ! aEzafa ! Sg ++ det.s
} ; } ;
a = agrP3 det.n ; a = agrP3 det.n ;
animacy = cn.animacy
} ; } ;
UsePN pn = {s = \\_ => pn.s ; a = agrP3 Sg ; animacy = pn.animacy } ; UsePN pn = pn ** {s = \\_ => pn.s ; a = agrP3 Sg ; hasAdj = False} ;
UsePron p = {s = \\_ => p.s ; a = p.a ; animacy = Animate} ; UsePron p = p ** {s = \\_ => p.s ; animacy = Animate ; hasAdj = False} ;
PredetNP pred np = np ** { PredetNP pred np = np ** {
s = \\ez => pred.s ++ np.s ! ez s = \\ez => pred.s ++ np.s ! ez
@@ -50,6 +49,7 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
DetNP det = { DetNP det = {
s = \\_ => det.s ; ---- case s = \\_ => det.s ; ---- case
a = agrP3 det.n ; a = agrP3 det.n ;
hasAdj = False ;
animacy = Inanimate animacy = Inanimate
} ; } ;
@@ -73,46 +73,41 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
DefArt = {s = \\_ => [] ; a = defaultAgr ; fromPron = False} ; DefArt = {s = \\_ => [] ; a = defaultAgr ; fromPron = False} ;
IndefArt = {s = table { Sg => IndefArticle ; Pl => []} ; 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 bEzafa => cn.s ! bEzafa ! Sg ;
NPC aEzafa => cn.s ! aEzafa ! Sg ; NPC aEzafa => cn.s ! aEzafa ! Sg ;
NPC enClic => cn.s ! enClic ! Sg NPC enClic => cn.s ! enClic ! Sg
}; };
a = agrP3 Sg ; a = agrP3 Sg ;
animacy = cn.animacy
} ; } ;
UseN n = n ; UseN n = n ** {hasAdj=False};
UseN2 n = n ; UseN2 n = n ** {hasAdj=False};
Use2N3 f = { Use2N3 f = f ** {
s = f.s;
c = f.c2; c = f.c2;
animacy = f.animacy;
definitness = True definitness = True
} ; } ;
Use3N3 f = { Use3N3 f = f ** {
s = f.s ;
c = f.c3; c = f.c3;
animacy = f.animacy;
definitness = True definitness = True
} ; } ;
ComplN2 f x = { ComplN2 f x = f ** {
s = \\ez,n => f.s ! ez ! n ++ f.c ++ x.s ! NPC ez ; 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 ; s = \\ez,n => f.s ! ez ! n ++ f.c2 ++ x.s ! NPC ez ;
c = f.c3; c = f.c3;
animacy = f.animacy;
definitness = True; definitness = True;
} ; } ;
AdjCN ap cn = cn ** { 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 ** { RelCN cn rs = cn ** {

View File

@@ -25,7 +25,8 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
oper oper
Compl : Type = {s : Str ; ra : Str ; c : VType} ; 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} ; VPHSlash : Type = VPH ** {c2 : Compl} ;
oper oper
@@ -34,6 +35,11 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
Neg => CNeg b Neg => CNeg b
} ; } ;
cpol2pol : CPolarity -> Polarity = \cp -> case cp of {
CPos => Pos ;
_ => Neg
} ;
----------------------- -----------------------
--- Verb Phrase --- Verb Phrase
----------------------- -----------------------
@@ -144,7 +150,7 @@ oper
insertVV : (Agr => Str) -> VPH -> VPH = \obj1,vp -> vp ** { insertVV : (Agr => Str) -> VPH -> VPH = \obj1,vp -> vp ** {
wish = True ; wish = True ;
vComp = \\a => vp.comp ! a ++ obj1 ! a ; vComp = \\a => vp.comp ! a ++ conjThat ++ obj1 ! a ;
} ; } ;
insertObj2 : (Str) -> VPH -> VPH = \obj1,vp -> vp ** { 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 ; PredSCVP sc vp = mkSClause ("این" ++ sc.s) (defaultAgr) vp ;
ImpVP vp = { ImpVP vp = {
s = \\pol,n => s = \\cpol,n =>
let agr = Ag (numImp n) P2 ; let agr = Ag (numImp n) P2 ;
in case pol of { pol = cpol2pol cpol ;
CPos => vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.vComp ! agr ++ vp.s ! VPImp Pos (numImp n) ++ vp.embComp; in case vp.wish of {
CNeg _ => vp.ad ++ vp.comp ! agr ++ vp.obj.s ++ vp.vComp ! agr ++ vp.s ! VPImp Neg (numImp n) ++ vp.embComp 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} ; IntPN i = {s = i.s ; animacy = Inanimate} ;
FloatPN i = {s = i.s ; animacy = Inanimate} ; FloatPN i = {s = i.s ; animacy = Inanimate} ;
NumPN 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 ; s = \\ez => cn.s ! aEzafa ! Sg ++ i.s ;
a = agrP3 Sg ; a = agrP3 Sg
animacy = cn.animacy
} ; } ;
CNSymbNP det cn xs = { CNSymbNP det cn xs = cn ** {
s = \\ez => det.s ++ cn.s ! aEzafa ! det.n ++ xs.s ; s = \\ez => det.s ++ cn.s ! aEzafa ! det.n ++ xs.s ;
a = agrP3 det.n ; a = agrP3 det.n
animacy = cn.animacy
} ; } ;
CNNumNP cn i = { CNNumNP cn i = cn ** {
s = \\ez => cn.s ! aEzafa ! Sg ++ i.s ; s = \\ez => cn.s ! aEzafa ! Sg ++ i.s ;
a = agrP3 Sg ; a = agrP3 Sg
animacy = cn.animacy
} ; } ;
SymbS sy = sy ; 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 coding = utf8;
flags optimize=all_subs ; flags optimize=all_subs ;
@@ -42,9 +42,19 @@ concrete VerbPes of Verb = CatPes ** open ResPes in {
PassV2 v = predV v ; -- need to be fixed PassV2 v = predV v ; -- need to be fixed
CompAP ap ={s = \\_ => ap.s ! bEzafa} ; -- check form of adjective CompAP ap ={s = \\_ => ap.s ! bEzafa} ; -- check form of adjective
CompAdv adv = {s = \\_ => adv.s } ; CompAdv adv = {s = \\_ => adv.s } ;
CompCN cn = {s = \\a => cn.s ! bEzafa ! giveNumber a } ;
-- IL 2019-01-31 changed bEzafa to enClic according to -- see https://sites.la.utexas.edu/persian_online_resources/nouns/noun-in-a-predicative-position/
-- https://sites.la.utexas.edu/persian_online_resources/nouns/noun-in-a-predicative-position/ CompCN cn = {
CompNP np = {s = \\a => np.s ! NPC enClic} ; 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 }
} ;
} }