1
0
forked from GitHub/gf-rgl

Merge pull request #226 from inariksit/persian

Persian
This commit is contained in:
Inari Listenmaa
2019-04-18 20:02:10 +02:00
committed by GitHub
10 changed files with 71 additions and 62 deletions

View File

@@ -43,7 +43,8 @@ concrete AdjectivePes of Adjective = CatPes ** open ResPes, Prelude in {
AdjOrd ord = {
s = \\_ => ord.s ;
adv = ord.s ;
isPre = ord.isPre
isPre = ord.isPre ;
afterPrefix = False ;
} ;
AdvAP ap adv = ap ** {

View File

@@ -12,7 +12,7 @@ concrete CatPes of Cat = CommonX ** open ResPes, Prelude in {
---- Sentence
Cl = ResPes.Clause ;
Cl = ResPes.Clause ; -- TODO: like romance does "no tiene ningún", i.e. negative quant/det/NP forces negation in Cl and S
ClSlash = {
subj : Str ;
vp : ResPes.TAnt => Polarity => Order => Str ;
@@ -72,9 +72,10 @@ concrete CatPes of Cat = CommonX ** open ResPes, Prelude in {
-----b Conj = {s : Str ; n : Number} ;
-----b DConj = {s1,s2 : Str ; n : Number} ;
Subj = {s : Str ; compl : VVForm} ; -- subjunctive or indicative
VS = ResPes.Verb ** {compl : VVForm} ; -- subjunctive or indicative
Prep = Compl ;
---- Open lexical classes, e.g. Lexicon
V, VS, VQ = ResPes.Verb ;
V, VQ = ResPes.Verb ;
V2, VA, V2A, V2Q, V2S = ResPes.Verb ** {c2 : Compl} ;
V3 = ResPes.Verb ** {c2, c3 : Compl} ;

View File

@@ -48,7 +48,7 @@ concrete ConjunctionPes of Conjunction =
isCmpd : CmpdStatus;
hasAdj : Bool ;
compl : Number => Str} ;
[AP] = {s1,s2 : Mod => Str ; adv : Str ; isPre : Bool} ;
[AP] = {s1,s2 : Mod => Str ; adv : Str ; isPre,afterPrefix : Bool} ;
[RS] = {s1,s2 : Agr => Str ; rp : RelPron => Str} ;
oper

View File

@@ -76,7 +76,7 @@ concrete LexiconPes of Lexicon = CatPes **
enemy_N = mkN02 "دشمن" animate;
factory_N = mkN01 "کارخانه" inanimate;
father_N2 = mkN2 (mkN02 "پدر" animate) [];
fear_VS = mkV_1 "ترسیدن";
fear_VS = mkVS (mkV_1 "ترسیدن") ;
find_V2 = mkV2 (compoundV "پیدا" doVerb) "را";
fish_N = mkN01 "ماهی" animate;
floor_N = mkN01 "زمین" inanimate; -- Note: floor in persian can have 3 different translations
@@ -97,7 +97,7 @@ concrete LexiconPes of Lexicon = CatPes **
hat_N = mkN01 "کلاه" inanimate;
hear_V2 = mkV2 (mkV "شنیدن" "شنو") "را" ;
hill_N = mkN01 "تپه" inanimate;
hope_VS = compoundV "امیدوار" beVerb;
hope_VS = mkVS (compoundV "امیدوار" beVerb) ;
horse_N = mkN01 "اسب" animate;
hot_A = mkA "داغ" ["داغ داغ"] ;
house_N = mkN01 "خانه" inanimate;
@@ -106,7 +106,7 @@ concrete LexiconPes of Lexicon = CatPes **
iron_N = mkN01 "آهن" inanimate;
king_N = mkN "پادشاه" "پادشاهان" animate;
know_V2 = mkV2 (mkV "شناختن" "شناس") "را";
know_VS = (mkV_1 "دانستن") ; -- danestan -> dan ; needs explicit mkV_1
know_VS = mkVS (mkV_1 "دانستن") ; -- danestan -> dan ; needs explicit mkV_1
know_VQ = (mkV_1 "دانستن") ;
lake_N = mkN01 "دریاچه" inanimate;
lamp_N = mkN01 "چراغ" inanimate; -- also "لامپ", but they have different usage
@@ -157,7 +157,7 @@ concrete LexiconPes of Lexicon = CatPes **
roof_N = mkN01 "بام" inanimate; -- has variant "سقف"
rubber_N = mkN01 "پاککن" inanimate; -- also "لاستیک"
run_V = mkV_1 "دویدن" ;
say_VS = mkV "گفتن" "گوی" ;
say_VS = mkVS (mkV "گفتن" "گوی") ;
school_N = mkN "مدرسه" "مدارس" inanimate;
science_N = mkN "علم" "علوم" inanimate; -- also "دانش"
sea_N = mkN01 "دریا" inanimate;
@@ -215,7 +215,7 @@ concrete LexiconPes of Lexicon = CatPes **
woman_N = mkN02 "زن" animate;
wonder_VQ = compoundV "متعجب" beVerb ;
wood_N = mkN01 "چوب" inanimate;
write_V2 = mkV2 (mkV "نوشتن" "نویس") "را" ;
write_V2 = mkV2 (mkV "نوشتن" "نویس") ; -- would need ra with a definite object, but better rule of thumb to go without ra /NM
yellow_A = mkA "زرد" ;
young_A = mkA "جوان""جوانانه" ;
do_V2 = mkV2 (compoundV "انجام" giveVerb) "را";

View File

@@ -150,7 +150,8 @@ oper
Adjective : Type = {
s : Mod => Str ;
adv : Str ;
isPre : Bool
isPre : Bool ; -- as attributive
afterPrefix : Bool ; -- as predicative, does it go between the prefix and the light verb
} ;
mkAdj : Str -> Str -> Adjective = \adj,adv -> {
@@ -159,7 +160,7 @@ oper
Clitic => mkEnclic adj ;
Poss => mkPossStem adj
} ;
adv = adv ; isPre = False
adv = adv ; isPre = False ; afterPrefix = True ;
};
------------------------------------------------------------------

View File

@@ -88,6 +88,7 @@ oper
mkA : Str -> A ; -- Regular adjective, same form for adjective and adverb.
mkA : (adj,adv : Str) -> A -- Different forms for adjective and adverb.
} ;
prefixA : A -> A ; -- Adjective that comes before the noun
mkA2 : (married,to : Str) -> A2 -- Takes string and complementiser, returns A2.
= \a,c -> lin A2 (mkAdj a a ** {c2 = c}) ;
@@ -148,9 +149,9 @@ oper
mkVS = overload {
mkVS : Str -> VS -- predictable verb with sentence complement
= \s -> lin VS (regV s) ;
= \s -> lin VS (regV s ** {compl=subjunctive}) ;
mkVS : V -> VS -- VS out of a verb
= \v -> lin VS v
= \v -> lin VS (v ** {compl=subjunctive})
} ;
mkVV = overload {
@@ -303,6 +304,8 @@ oper
= \a,c -> lin A2 (mkAdj a a ** {c2 = c})
} ;
prefixA a = a ** {isPre=True};
preA : (adj,adv : Str) -> A = \adj,adv ->
lin A ((mkAdj adj adv) ** {isPre=True}) ;

View File

@@ -67,16 +67,23 @@ resource ResPes = MorphoPes ** open Prelude,Predef in {
-----------------------
param
VVType = NoVV | FullVV | DefVV ;
VVForm = Indic | Subj ;
VVTense = VVPres | VVPerf | VVPast ; -- VVPast Anteriority ???
VVForm = Indic | Subj ; ---| SubjPast ; -- TODO extend this to VV, VS and Subj
VVTense = VVPres | VVPast VVForm ;
TAnt = TA Tense Anteriority ;
oper
-- TODO: all forms
ta2vvt : TAnt -> VVTense = \ta -> case ta of {
TA Pres Anter => VVPerf ;
TA Past _ => VVPast ;
-- VVPast Subj is another possibility, used in constructions such as
-- قاتل نمی توانسته آنجا بوده باشد، چون او آن زمان در پاریس بوده
-- The form is created in complVV, but not currently used in other functions. /IL
ta2vvt : TAnt -> VVType -> VVTense = \ta,vvtype -> case ta of {
TA Pres Anter |
TA Past _ => VVPast Indic ;
TA Cond Simul => VVPres ;
TA Cond Anter =>
case vvtype of {
DefVV => VVPast Indic ;
_ => VVPres } ;
_ => VVPres } ;
VV : Type = Verb ** {
@@ -95,21 +102,19 @@ oper
} ;
showVPH = overload {
showVPH : VerbForm -> Agr -> VPH -> Str = showVPH' VVPres ;
showVPH : VVTense -> VerbForm -> Agr -> VPH -> Str = showVPH'
showVPH : VerbForm -> Agr -> VPH -> Str = showVPH' False VVPres ;
showVPH : VVTense -> VerbForm -> Agr -> VPH -> Str = showVPH' False
} ;
showVPH' : VVTense -> VerbForm -> Agr -> VPH -> Str =
\ant,vf,agr,vp -> vp.ad ++ vp.comp ! agr ++ vp.obj
++ vp.prefix ++ vp.s ! vf
showVPH' : Bool -> VVTense -> VerbForm -> Agr -> VPH -> Str =
\showImpPref,ant,vf,agr,vp ->
let impPref = case showImpPref of {
True => vp.s ! ImpPrefix Pos ;
False => [] }
in vp.ad ++ vp.comp ! agr ++ vp.obj
++ vp.prefix ++ impPref ++ vp.s ! vf
++ vp.vComp ! agr ! ant ++ vp.embComp ;
-- A hack: we reuse the obj field for the VP complement in
-- SlashV2V and this is needed to get the right word order for complVV.
showVPHvv : VerbForm -> Agr -> VPH -> Str = \vf,agr,vp ->
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 ; mod : Mod} ;
VPHSlash : Type = VPH ** {
@@ -131,11 +136,13 @@ oper
predVc : (Verb ** {c2 : Compl}) -> VPHSlash = \verb ->
predV verb ** vs verb.c2 ;
passV : Verb -> VPH = \v -> predV v ** {
passV : Verb -> VPH = \v -> passVP (predV v) ;
passVP : VPH -> VPH = \vp -> vp ** {
s = becomeVerb.s ;
prefix = case v.passive of {
Add => v.s ! PerfStem ++ v.prefix ;
Replace => v.prefix
prefix = case vp.passive of {
Add => vp.s ! PerfStem ++ vp.prefix ;
Replace => vp.prefix
} ;
} ;
-- ---------------------
@@ -159,7 +166,6 @@ oper
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} ;
ad = vp.ad -- because complVV doesn't include ad! for word order.
} ;
embComp : Str -> VPH -> VPH = \str,vp -> vp ** {
@@ -181,15 +187,15 @@ oper
\\agr,ant => if_then_Str vv.isAux conjThat [] ++
case <ant,vv.isDef,vv.compl> of {
-- Auxiliaries with defective inflection: complement inflects in tense
<VVPast,True,_> => showVPHvv (VPast Pos agr) agr vp ;
-- <VVPast Anter> => showVPH PerfStem agr vp ++ pluperfAux Pos agr ; -- TODO do we need this?
<VVPerf,True,_> => showVPHvv PerfStem agr vp ++ subjAux Pos agr ;
<VVPast Indic,True,> => showVPH' True VVPres (VPast Pos agr) agr vp ;
<VVPast Indic,_,_> => showVPH (VPast Pos agr) agr vp ;
<VVPast Subj> => showVPH PerfStem agr vp ++ subjAux Pos agr ;
-- Auxiliaries that take indicative (full or defective inflection)
<VVPres,_,Indic> => showVPHvv (VAor Pos agr) agr vp ;
<VVPres,_,Indic> => showVPH (VAor Pos agr) agr vp ;
-- Default: complement in subjunctive
_ => showVPHvv (VSubj Pos agr) agr vp ---- TODO more forms ?
_ => showVPH (VSubj Pos agr) agr vp
} ;
insertAdV : Str -> VPH -> VPH = \ad,vp -> vp ** {
@@ -205,16 +211,15 @@ oper
SlClause : Type = {quest : Order => Str ; subj : Str ; vp : TAnt => Polarity => Order => Str} ;
---- AR 18/9/2017 intermediate SClause to preserve SOV in e.g. QuestionPes.QuestSlash
-- TODO: check the VV forms with defective verbs
clTable : VPH -> (Agr => TAnt => Polarity => Str) = \vp ->
\\agr,vt,pol => vp.prefix ++ case vt of {
TA Pres Simul => vp.s ! ImpPrefix pol ++ vp.s ! VAor pol agr ; -- for reg. verbs, VAor pol is invariant and negation comes in ImpPrefix.
TA Pres Anter => vp.s ! VPerf pol agr ;
TA Past Simul => vp.s ! VPast pol agr ;
TA Past Anter =>
TA Past Simul => vp.s ! VPast pol agr ; -- Past Simul: simple past
TA Past Anter | TA Cond _ => -- Past Anter & Cond _: continuous past
case vp.vvtype of {
DefVV => vp.s ! ImpPrefix pol ++ vp.s ! VAor pol agr ;
_ => vp.s ! PerfStem ++ pluperfAux pol agr } ;
DefVV => vp.s ! VPast pol agr ;
_ => vp.s ! ImpPrefix pol ++ vp.s ! VPast Pos agr } ;
TA Fut Simul =>
case vp.vvtype of {
DefVV => vp.s ! ImpPrefix pol ++ vp.s ! VAor pol agr ;
@@ -223,13 +228,8 @@ oper
TA Fut Anter =>
case vp.vvtype of {
DefVV => vp.s ! VPerf pol agr ;
_ => "خواسته" ++ pluperfAux pol agr ++ vp.s ! PastStem
} ; -- verb form need to be confirmed
TA Cond Simul => vp.s ! VSubj pol agr ;
TA Cond Anter =>
case vp.vvtype of {
DefVV => vp.s ! VSubj pol agr ;
_ => vp.s ! PerfStem ++ subjAux pol agr } -- verb form to be confirmed
_ => futAux pol agr ++ vp.s ! PastStem
}
} ;
mkClause : NP -> VPH -> Clause = \np,vp ->
@@ -243,7 +243,7 @@ oper
subj = np2str np ;
vp = \\ta,p,ord =>
let vps = clTable vp ! np.a ! ta ! p ;
vvt = ta2vvt ta ;
vvt = ta2vvt ta vp.vvtype ;
in case vp.vvtype of {
DefVV
=> vps ++ vp.ad ++ vp.comp ! np.a ++ vp.obj
@@ -257,9 +257,8 @@ oper
s = \\ta,p,ord =>
let vps = clTable vp ! agr ! ta ! p ;
quest = case ord of { ODir => [] ; OQuest => "آیا" } ;
vvt = ta2vvt ta ;
vvt = ta2vvt ta vp.vvtype ;
in quest ++ subj ++ vp.ad ++ vp.comp ! agr ++ vp.obj
-- in quest ++ vp.ad ++ subj ++ vp.comp ! agr ++ vp.obj -- TODO check which word order is better /IL
++ vps ++ vp.vComp ! agr ! vvt ++ vp.embComp
};

View File

@@ -26,7 +26,7 @@ concrete StructuralPes of Structural = CatPes **
either7or_DConj = sd2 "یا" "یا" ** {n = Sg} ;
-- everybody_NP = R.indeclNP "هر کwی";
every_Det = mkDet "هر" Sg ;
-- everything_NP = R.indeclNP ["هر XE"]));
everything_NP = DetCN (mkDet "همه" Sg) (UseN (mkN "چیز")) ;
everywhere_Adv = ss ["هر جا"] ;
few_Det = mkDet ["تعداد کمی"] Pl True; -- check
for_Prep = mkPrep "برای" Ezafe ;

View File

@@ -25,7 +25,7 @@ concrete SymbolPes of Symbol = CatPes ** open Prelude, ResPes in {
SymbS sy = {s = \\_ => sy.s} ;
SymbNum sy = {s = sy.s ; n = Pl} ;
SymbOrd sy = { s = sy.s ++ "wN" ; n = Pl; isNum,isPre=False} ;
SymbOrd sy = {s = sy.s ; n = Sg ; isNum,isPre=False} ;
lincat

View File

@@ -13,9 +13,13 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
ComplSlash = complSlash ;
ComplVV = insertVV ;
ComplVS v s = embComp (conjThat ++ s.s ! Indic) (predV v) ;
ComplVS v s = embComp (conjThat ++ s.s ! v.compl) (predV v) ;
ComplVQ v q = embComp (conjThat ++ q.s) (predV v) ;
ComplVA v ap = insertObj (appComp v.c2 ap.s) (predV v) ; -- check form of adjective
ComplVA v ap = let adjStr = appComp v.c2 ap.s in
case ap.afterPrefix of {
True => predV (v ** {prefix = v.prefix ++ adjStr}) ;
False => insertObj adjStr (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) ;