Merge pull request #198 from inariksit/persian

Persian
This commit is contained in:
Inari Listenmaa
2019-03-16 16:29:58 +01:00
committed by GitHub
12 changed files with 106 additions and 90 deletions

View File

@@ -7,20 +7,20 @@ concrete AdjectivePes of Adjective = CatPes ** open ResPes, Prelude in {
UseComparA a = a ;
ComparA a np = a ** {
s = \\m => a.s ! m ++ "تر" ++ "از" ++ np.s ! Bare ;
adv = a.adv ++ "تر" ++ "از" ++ np.s ! Bare ;
s = \\m => a.s ! m ++ "تر" ++ "از" ++ np2str np ;
adv = a.adv ++ "تر" ++ "از" ++ np2str np ;
} ;
---- $SuperlA$ belongs to determiner syntax in $Noun$.
ComplA2 a np = a ** {
s = \\m => np.s ! Bare ++ a.c2 ++ a.s ! m ;
adv = np.s ! Bare ++ a.c2 ++ a.adv
s = \\m => np2str np ++ a.c2 ++ a.s ! m ;
adv = np2str np ++ a.c2 ++ a.adv
} ;
ReflA2 a = a ** {
s = \\m => a.s ! m ++ reflPron ! defaultAgr ; ---- need to be fixed
adv = a.adv ++ reflPron ! defaultAgr
s = \\m => a.s ! m ++ reflPron ! defaultAgr ! Bare ; ---- need to be fixed
adv = a.adv ++ reflPron ! defaultAgr ! Bare
} ;
SentAP ap sc = ap ** {
@@ -36,7 +36,7 @@ concrete AdjectivePes of Adjective = CatPes ** open ResPes, Prelude in {
UseA2 a = a ;
CAdvAP cadv ap np = ap ** {
s = \\m => cadv.s ++ np.s ! Bare ++ ap.s ! m ;
s = \\m => cadv.s ++ np2str np ++ ap.s ! m ;
adv = cadv.s ++ ap.adv
} ;

View File

@@ -38,7 +38,7 @@ concrete ConjunctionPes of Conjunction =
lincat
[S] = {s1,s2 : VVForm => Str} ;
[Adv] = {s1,s2 : Str} ;
[NP] = {s1,s2 : Mod => Str ; a : Agr ; animacy : Animacy ; hasAdj : Bool; compl:Str} ;
[NP] = {s1,s2 : Mod => Str ; a : Agr ; animacy : Animacy ; hasAdj : Bool} ;
[AP] = {s1,s2 : Mod => Str ; adv : Str ; isPre : Bool} ;
[RS] = {s1,s2 : Agr => Str };

View File

@@ -12,7 +12,7 @@ lin
-- NP -> Quant ; -- this man's
GenNP np = np ** {
mod = Ezafe ; -- the possessed will get Ezafe
s = \\num,cmpd => np.s ! Bare -- possesser is unmarked; https://sites.la.utexas.edu/persian_online_resources/language-specific-grammar/ezfe/
s = \\num,cmpd => np2str np -- possesser is unmarked; https://sites.la.utexas.edu/persian_online_resources/language-specific-grammar/ezfe/
} ;
-- : NP -> NP -> NP

View File

@@ -1,4 +1,4 @@
concrete IdiomPes of Idiom = CatPes ** open Prelude,Predef, ResPes in {
concrete IdiomPes of Idiom = CatPes ** open Prelude,ParadigmsPes,ResPes in {
flags optimize=all_subs ;
flags coding = utf8;
@@ -9,7 +9,7 @@ lin
GenericCl vp = mkSClause "آدم" (agrP3 Sg) vp ;
CleftNP np rs =
let cl = mkSClause (np.s ! Bare) (np.a) (predV beVerb);
let cl = mkSClause (np2str np) (np.a) (predV beVerb);
in
{s = \\t,p,o => cl.s ! t ! p ! o ++ rs.s ! np.a };
@@ -17,7 +17,14 @@ lin
ExistNP np =
mkSClause [] (agrP3 (fromAgr np.a).n)
(insertComp (\\_ => np.s ! Bare) (predV beVerb)) ;
(insertComp (\\_ => np2str np) (predV existVerb)) ;
ExistNPAdv np adv =
mkSClause [] (agrP3 (fromAgr np.a).n)
(insertComp (\\_ => np2str np ++ adv.s)
(predV existVerb)
) ;
ExistIP ip =
let cl = mkSClause ip.s (agrP3 ip.n) (predV beVerb);
@@ -29,7 +36,9 @@ lin
ImpPl1 vp = let a = agrP1 Pl in
{s = "بیایید" ++ showVPH (VSubj Pos a) a vp } ;
ImpP3 np vp =
{s = "بگذارید" ++ np.s ! Bare ++ showVPH (VSubj Pos np.a) np.a vp};
{s = "بگذارید" ++ np2str np ++ showVPH (VSubj Pos np.a) np.a vp};
oper
existVerb = mkV "وجود" haveVerb ;
}

View File

@@ -91,22 +91,20 @@ oper
_ => str + "ی" -- any other case: just a single ی
} ;
modTable : Str -> Mod => Str = \str ->
table {Bare => str ;
Ezafe => mkEzafe str ;
Clitic => mkEnclic str ;
Poss => mkPossStem str } ;
Noun = {
s : Number => Mod => Str ;
animacy : Animacy ;
isCmpd : CmpdStatus -- Affects possession: awkward to use poss. suff. with compound nouns
isCmpd : CmpdStatus -- Affects possession: awkward to use poss. suff. with compound nouns
} ;
mkN : (x1,x2 : Str) -> Animacy -> Noun = \sg,pl,ani -> indeclN sg ** {
s = table {
Sg => table {Bare => sg ;
Ezafe => mkEzafe sg ;
Clitic => mkEnclic sg ;
Poss => mkPossStem sg } ;
Pl => table {Bare => pl ;
Ezafe => mkEzafe pl ;
Clitic => mkEnclic pl ;
Poss => mkPossStem pl }}
s = table {Sg => modTable sg ; Pl => modTable pl}
} ;
indeclN : Str -> Noun = \s -> {

View File

@@ -15,10 +15,9 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
NotCmpd => det.s ; -- possessive suffix
IsCmpd => det.sp } ; -- full form
in case mod of {
Bare => detStr ++ cn.s ! num ! m ; -- det doesn't require a special form, keep the Mod=>Str table
x => cn.s ! num ! x ++ detStr } ; -- det requires a special form
a = agrP3 det.n ;
compl = cn.compl ! det.n
Bare => detStr ++ cn.s ! num ! m ++ cn.compl ! det.n ; -- det doesn't require a special form, keep the Mod=>Str table
x => cn.s ! num ! x ++ detStr ++ cn.compl ! det.n } ; -- det requires a special form
a = agrP3 det.n
} ;
UsePN pn = emptyNP ** pn ** {s = \\_ => pn.s} ;
@@ -33,7 +32,7 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
} ;
RelNP np rs = np ** {
s = \\ez => np.s ! ez ++ rs.s ! np.a
s = \\m => np.s ! Clitic ++ rs.s ! np.a
} ;
AdvNP np adv = np ** {
@@ -61,7 +60,6 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
a = agrP3 det.n ;
hasAdj = False ;
animacy = Inanimate ;
compl = []
} ;
PossPron p = {
@@ -69,7 +67,7 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
NotCmpd => BIND ++ p.ps ;
IsCmpd => p.s } ; -- is a compound
a = p.a ;
mod = Poss} ; -- make into Ezafe if DetCN if N is compound
mod = Poss} ; -- is changed into Ezafe in DetCN, if the CN is compound
NumSg = {s = [] ; n = Sg ; isNum = False} ;
NumPl = {s = [] ; n = Pl ; isNum = False} ;
@@ -90,9 +88,8 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
IndefArt = {s = table {Sg => \\_ => IndefArticle ; Pl => \\_ => []} ; mod = Bare} ;
MassNP cn = cn ** {
s = cn.s ! Sg ;
s = \\m => cn.s ! Sg ! m ++ cn.compl ! Sg ;
a = agrP3 Sg ;
compl = cn.compl ! Sg
} ;
UseN,
@@ -110,13 +107,13 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
ComplN2 n2 np = n2 ** {
s = \\n,m => n2.s ! n ! Ezafe ;
compl = \\_ => n2.compl ++ n2.c2 ++ np.s ! Bare ;
compl = \\_ => n2.compl ++ n2.c2 ++ np2str np ;
hasAdj = False
};
ComplN3 n3 np = n3 ** {
s = \\n,m => n3.s ! n ! Ezafe ;
compl = n3.c2 ++ np.s ! Bare ;
compl = n3.c2 ++ np2str np ;
c = n3.c3;
} ;
@@ -129,15 +126,21 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
RelCN cn rs = cn ** {
s = \\n,ez => cn.s ! n ! Clitic ;
compl = \\n => rs.s ! agrP3 n ;
compl = \\n => cn.compl ! n ++ rs.s ! agrP3 n ;
} ;
AdvCN cn ad = cn ** {s = \\n,m => cn.s ! n ! Ezafe ++ ad.s} ;
AdvCN cn ad = cn ** {
s = \\n,m => cn.s ! n ! Ezafe ;
compl = \\n => cn.compl ! n ++ ad.s} ;
SentCN cn sc = cn ** {compl = \\n => sc.s} ;
SentCN cn sc = cn ** {compl = \\n => cn.compl ! n ++ sc.s} ;
-- correct for /city Paris/, incorrect for /king John/
-- ApposNP in ExtendPes works for /king John/ (no ezafe).
ApposCN cn np = cn ** {s = \\n,m => cn.s ! n ! Ezafe ++ np.s ! m} ;
-- : CN -> NP -> CN ; -- house of Paris, house of mine
PossNP cn np = cn ** {
s = \\n,m => cn.s ! n ! Ezafe ; -- TODO or here for "<house of mine> <on the hill>"
compl = \\n => cn.compl ! n ++ np2str np } ; -- "<house> <on the hill of mine>"
}

View File

@@ -28,6 +28,10 @@ oper
subjunctive : VVForm ; -- The verbal complement of VV is in subjunctive
indicative : VVForm ; -- The verbal complement of VV is in indicative
Mod : Type ; -- Argument to mkDet and mkPrep
ezafe : Mod ; -- e.g. mkPrep "برای" ezafe
-- poss : Mod ; -- TODO is this needed?
--clitic : Mod ; -- TODO is this needed?
--2 Nouns
mkN : overload {
@@ -66,9 +70,11 @@ oper
mkDet = overload {
mkDet : Str -> Number -> Det -- Takes a string, number (sg/pl) and returns a det which is not a numeral
= \s1,n -> lin Det (makeDet s1 n False);
mkDet : Str -> Number -> Bool -> Det -- Takes a string, number (sg/pl) and a Boolean for whether the det is a numeral
= \s1,n,b -> lin Det (makeDet s1 n b)
= \s,n -> lin Det (makeDet s n False);
mkDet : Str -> Number -> Bool -> Det -- As above + a Boolean for whether the det is a numeral
= \s,n,b -> lin Det (makeDet s n b) ;
mkDet : Str -> Number -> Bool -> Mod -> Det -- As above + Mod for which form the determiner expects its argument to be (default bare)
= \s,n,b,m -> lin Det (makeDet s n b ** {mod=m})
};
{-
@@ -173,8 +179,13 @@ oper
----2 Prepositions
mkPrep : Str -> Prep ; -- Takes a string, returns a preposition.
mkPrep str = lin Prep {s = str ; ra = []} ;
mkPrep = overload {
mkPrep : Str -> Prep -- Takes a string, returns a preposition.
= \str -> lin Prep {s = str ; ra = [] ; mod = Bare} ;
mkPrep : Str -> Mod -> Prep -- Takes a string and Mod (so far only option is ezafe), returns a preposition.
= \str,m -> lin Prep {s = str ; ra = [] ; mod=m}
} ;
{-
--3 Determiners and quantifiers
@@ -224,6 +235,9 @@ oper
subjunctive = ResPes.Subj ;
indicative = Indic ;
Mod = ResPes.Mod ;
ezafe = ResPes.Ezafe ;
-- Removed mkV_1, mkV_2, mkN01 and mkN02 from public API, still available for
-- any applications that open ParadigmsPes. /IL 2019-02-08
mkV_1 : Str -> V
@@ -329,15 +343,15 @@ oper
mkV2 : V -> Str -> V2
= \v,ra -> lin V2 (v ** {c2 = prepOrRa ra}) ;
mkV2 : V -> Str -> Bool -> V2
= \v,p,b -> lin V2 (v ** {c2 = {ra = [] ; s = p}}) ;
= \v,p,b -> lin V2 (v ** {c2 = {ra = [] ; s = p ; mod=Bare}}) ;
} ;
prepOrRa : Str -> Compl = \s -> case s of {
"را" => {s = [] ; ra = "را"} ;
prep => {s = prep ; ra = []}
"را" => {s = [] ; ra = "را" ; mod=Bare} ;
prep => {s = prep ; ra = []; mod=Bare}
} ;
mkPost : Str -> Prep = \s -> lin Prep {s=[] ; ra=s} ;
mkPost : Str -> Prep = \s -> lin Prep {s=[] ; ra=s ; mod=Bare} ;
mkN2 = overload {
mkN2 : Str -> N2 -- Predictable N2 without complement

View File

@@ -22,7 +22,7 @@ concrete QuestionPes of Question = CatPes ** open ResPes, Prelude in {
};
QuestIComp icomp np =
let cl = mkSClause (np.s ! Bare ++ icomp.s) np.a (predV beVerb)
let cl = mkSClause (np2str np ++ icomp.s) np.a (predV beVerb)
in {s = \\t,p => cl.s ! t ! p ! ODir};
PrepIP p ip = {s = p.s ++ ip.s } ;

View File

@@ -28,7 +28,6 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
s : Mod => Str ; -- NP can appear with a clitic, need to keep Mod open
a : Agr ;
hasAdj : Bool ; -- to get the right form when NP is a predicate
compl : Str ; -- to make possessive suffix attach to the right word
animacy : Animacy -- to get the right relative pronoun
} ;
@@ -38,7 +37,6 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
a = defaultAgr ;
hasAdj = False ;
animacy = Inanimate ;
compl = []
} ;
indeclNP : Str -> NP = \s ->
emptyNP ** {s = \\m => s} ;
@@ -49,7 +47,7 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
} ;
np2str : NP -> Str = \np ->
np.s ! Bare ++ np.compl ;
np.s ! Bare ;
cn2str : CN -> Str = \cn ->
cn.s ! Sg ! Bare ++ cn.compl ! Sg ;
@@ -102,7 +100,7 @@ oper
vp.comp ! agr ++ vp.prefix ++ vp.s ! vf -- vp.ad is missing on purpose! we add it in insertVV.
++ vp.obj ++ vp.vComp ! agr ! VVPres ++ vp.embComp ;
Compl : Type = {s : Str ; ra : Str} ;
Compl : Type = {s : Str ; ra : Str ; mod : Mod} ;
VPHSlash : Type = VPH ** {
c2 : Compl ; -- prep or ra for the complement
@@ -126,17 +124,21 @@ oper
---------------------
-- VP complementation
---------------------
appComp : Compl -> Str -> Str = \c2,obj ->
c2.s ++ obj ++ c2.ra ;
appComp : Compl -> (Mod=>Str) -> Str = \c2,obj ->
c2.s ++ obj ! c2.mod ++ c2.ra ;
insertComp : (Agr => Str) -> VPH -> VPH = \obj,vp -> vp ** {
comp = \\a => vp.comp ! a ++ obj ! a
} ;
insertCompPre : (Agr=>Str) -> VPHSlash -> VPH = \obj,vp -> vp ** {
insertCompPre : (Agr=>Mod=>Str) -> VPHSlash -> VPH = \obj,vp -> vp ** {
comp = \\a => appComp vp.c2 (obj ! a) ++ vp.comp ! a
} ;
insertCompPost : (Agr=>Mod=>Str) -> VPHSlash -> VPH = \obj,vp -> vp ** {
comp = \\a => vp.comp ! a ++ appComp vp.c2 (obj ! a)
} ;
insertVV : VV -> VPH -> VPH = \vv,vp -> predV vv ** {
vComp = \\a,t => vp.vComp ! a ! t ++ complVV vv vp ! a ! t ;
vvType = case vv.isDef of {True => DefVV ; _ => FullVV} ;
@@ -152,8 +154,7 @@ oper
} ;
complSlash : VPHSlash -> NP -> VPH = \vp,np -> vp ** {
comp = \\a => appComp vp.c2 (np.s ! Bare)
++ np.compl ++ vp.comp ! a ;
comp = \\a => appComp vp.c2 np.s ++ vp.comp ! a ;
obj = vp.obj ++ vp.agrObj ! np.a -- "beg her to buy", buy agrees with her
} ;
@@ -264,14 +265,13 @@ oper
-- Reflexive pronouns
-----------------------------------
reflPron : Agr => Str = table {
Ag Sg P1 => "خودم" ;
Ag Sg P2 => "خودت" ;
Ag Sg P3 => "خودش" ;
Ag Pl P1 => "خودمان" ;
Ag Pl P2 => "خودتان" ;
Ag Pl P3 => "خودشان"
reflPron : Agr => Mod => Str = table {
Ag Sg P1 => modTable "خودم" ;
Ag Sg P2 => modTable "خودت" ;
Ag Sg P3 => modTable "خودش" ;
Ag Pl P1 => modTable "خودمان" ;
Ag Pl P2 => modTable "خودتان" ;
Ag Pl P3 => modTable "خودشان"
} ;
getPron : Animacy -> Number -> Str = \ani,number ->

View File

@@ -29,7 +29,7 @@ concrete StructuralPes of Structural = CatPes **
-- everything_NP = R.indeclNP ["هر XE"]));
everywhere_Adv = ss ["هر جا"] ;
few_Det = mkDet ["تعداد کمی"] Pl True; -- check
for_Prep = mkPrep "برای" ;
for_Prep = mkPrep "برای" Ezafe ;
from_Prep = mkPrep "از" ;
he_Pron = R.agr2pron ! Ag Sg P3 ;
here_Adv = ss "اینجا" ;
@@ -44,7 +44,7 @@ concrete StructuralPes of Structural = CatPes **
in_Prep = mkPrep "در" ;
it_Pron = R.agr2pron ! Ag Sg P3;
less_CAdv = {s = "کمتر" ; p = ""} ;
many_Det = mkDet ["تعداد زیادی"] Pl True; -- check
many_Det = mkDet "بسیار" Pl False Ezafe ;
more_CAdv = {s = "بیشتر" ; p = "" } ;
most_Predet = ss "اکثر";
much_Det = mkDet ["مقدار زیادی"] Pl ;
@@ -133,9 +133,6 @@ have_V2 = haveVerb ** {
VSubj _ (Ag Pl P2) => "داشته باشید" ;
VSubj _ (Ag Pl P3) => "داشته باشند" ;
x => haveVerb.s ! x } ;
c2 = {
s = [] ;
ra = [] --- "را" ; ---- AR 18/9/2017: usually no ra acc. to Nasrin, but this is tricky
}
c2 = prepOrRa [] -- "را" ; ---- AR 18/9/2017: usually no ra acc. to Nasrin, but this is tricky
} ;
}

View File

@@ -11,19 +11,16 @@ concrete SymbolPes of Symbol = CatPes ** open Prelude, ResPes in {
FloatPN i = {s = i.s ; animacy = Inanimate} ;
NumPN i = {s = i.s ; animacy = Inanimate} ;
CNIntNP cn i = cn ** {
s = \\ez => cn.s ! Sg ! Ezafe ++ i.s ;
a = agrP3 Sg ;
compl = cn.compl ! Sg
s = \\ez => cn.s ! Sg ! Ezafe ++ i.s ++ cn.compl ! Sg ;
a = agrP3 Sg
} ;
CNSymbNP det cn xs = cn ** {
s = \\ez => det.s ++ cn.s ! det.n ! Ezafe ++ xs.s ;
a = agrP3 det.n ;
compl = cn.compl ! det.n
s = \\ez => det.s ++ cn.s ! det.n ! Ezafe ++ xs.s ++ cn.compl ! det.n ;
a = agrP3 det.n
} ;
CNNumNP cn i = cn ** {
s = \\ez => cn.s ! Sg ! Ezafe ++ i.s ;
s = \\ez => cn.s ! Sg ! Ezafe ++ i.s ++ cn.compl ! Sg ;
a = agrP3 Sg ;
compl = cn.compl ! Sg
} ;
SymbS sy = {s = \\_ => sy.s} ;
@@ -40,12 +37,6 @@ lin
BaseSymb = infixSS "تE" ;
ConsSymb = infixSS "" ;
--oper
-- Note: this results in a space before 's, but there's
-- not mauch we can do about that.
-- addGenitiveS : Str ;
-- addGenitiveS s =
-- s ++ "از" ;
-- TODO: what are wN and تE? /IL
}

View File

@@ -15,12 +15,12 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
ComplVV = insertVV ;
ComplVS v s = embComp (conjThat ++ s.s ! Indic) (predV v) ;
ComplVQ v q = embComp (conjThat ++ q.s) (predV v) ;
ComplVA v ap = insertObj (appComp v.c2 (ap.s ! Bare)) (predV v) ; -- check form of adjective
ComplVA v ap = insertObj (appComp v.c2 ap.s) (predV v) ; -- check form of adjective
SlashVV vv vps = vps ** ComplVV vv vps ;
SlashV2S v s = predVc v ** embComp (conjThat ++ s.s ! Indic) (predV v) ;
SlashV2Q v q = predVc v ** embComp q.s (predV v) ;
SlashV2A v ap = predVc v ** insertObj (appComp v.c2 (ap.s ! Bare)) (predV v) ; ---- paint it red , check form of adjective
SlashV2A v ap = predVc v ** insertObj (appComp v.c2 ap.s) (predV v) ; ---- paint it red , check form of adjective
-- : V2V -> VP -> VPSlash ; -- beg (her) to go
SlashV2V v2v vp = predVc v2v ** {
@@ -36,9 +36,9 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
-- : V2V -> NP -> VPSlash -> VPSlash ; -- beg me to buy
SlashV2VNP v2v np vps = predVc v2v ** {
comp = \\a => if_then_Str v2v.isAux conjThat [] -- that
++ appComp v2v.c2 (np.s ! Bare) ; -- I
-- ∅ is placed in comp
vComp = \\_,_ => showVPH (case v2v.compl of { -- buy
++ appComp v2v.c2 np.s ; -- I
-- ∅ is placed in comp
vComp = \\_,_ => showVPH (case v2v.compl of { -- buy
Subj => VSubj Pos np.a ;
Indic => VAor Pos np.a })
np.a -- agreement fixed to np.a
@@ -46,6 +46,10 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
c2 = vps.c2 -- preposition for the direct object comes from VPSlash
} ;
-- : VP -> Prep -> VPSlash ;
VPSlashPrep vp prep = vp ** vs prep ;
AdvVP vp adv = insertAdV adv.s vp ;
AdVVP adv vp = insertAdV adv.s vp ;
ReflVP v = insertCompPre reflPron v ;