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 = { AdjOrd ord = {
s = \\_ => ord.s ; s = \\_ => ord.s ;
adv = ord.s ; adv = ord.s ;
isPre = ord.isPre isPre = ord.isPre ;
afterPrefix = False ;
} ; } ;
AdvAP ap adv = ap ** { AdvAP ap adv = ap ** {

View File

@@ -12,7 +12,7 @@ concrete CatPes of Cat = CommonX ** open ResPes, Prelude in {
---- Sentence ---- 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 = { ClSlash = {
subj : Str ; subj : Str ;
vp : ResPes.TAnt => Polarity => Order => 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 Conj = {s : Str ; n : Number} ;
-----b DConj = {s1,s2 : Str ; n : Number} ; -----b DConj = {s1,s2 : Str ; n : Number} ;
Subj = {s : Str ; compl : VVForm} ; -- subjunctive or indicative Subj = {s : Str ; compl : VVForm} ; -- subjunctive or indicative
VS = ResPes.Verb ** {compl : VVForm} ; -- subjunctive or indicative
Prep = Compl ; Prep = Compl ;
---- Open lexical classes, e.g. Lexicon ---- Open lexical classes, e.g. Lexicon
V, VS, VQ = ResPes.Verb ; V, VQ = ResPes.Verb ;
V2, VA, V2A, V2Q, V2S = ResPes.Verb ** {c2 : Compl} ; V2, VA, V2A, V2Q, V2S = ResPes.Verb ** {c2 : Compl} ;
V3 = ResPes.Verb ** {c2, c3 : Compl} ; V3 = ResPes.Verb ** {c2, c3 : Compl} ;

View File

@@ -48,7 +48,7 @@ concrete ConjunctionPes of Conjunction =
isCmpd : CmpdStatus; isCmpd : CmpdStatus;
hasAdj : Bool ; hasAdj : Bool ;
compl : Number => Str} ; 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} ; [RS] = {s1,s2 : Agr => Str ; rp : RelPron => Str} ;
oper oper

View File

@@ -76,7 +76,7 @@ concrete LexiconPes of Lexicon = CatPes **
enemy_N = mkN02 "دشمن" animate; enemy_N = mkN02 "دشمن" animate;
factory_N = mkN01 "کارخانه" inanimate; factory_N = mkN01 "کارخانه" inanimate;
father_N2 = mkN2 (mkN02 "پدر" animate) []; father_N2 = mkN2 (mkN02 "پدر" animate) [];
fear_VS = mkV_1 "ترسیدن"; fear_VS = mkVS (mkV_1 "ترسیدن") ;
find_V2 = mkV2 (compoundV "پیدا" doVerb) "را"; find_V2 = mkV2 (compoundV "پیدا" doVerb) "را";
fish_N = mkN01 "ماهی" animate; fish_N = mkN01 "ماهی" animate;
floor_N = mkN01 "زمین" inanimate; -- Note: floor in persian can have 3 different translations 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; hat_N = mkN01 "کلاه" inanimate;
hear_V2 = mkV2 (mkV "شنیدن" "شنو") "را" ; hear_V2 = mkV2 (mkV "شنیدن" "شنو") "را" ;
hill_N = mkN01 "تپه" inanimate; hill_N = mkN01 "تپه" inanimate;
hope_VS = compoundV "امیدوار" beVerb; hope_VS = mkVS (compoundV "امیدوار" beVerb) ;
horse_N = mkN01 "اسب" animate; horse_N = mkN01 "اسب" animate;
hot_A = mkA "داغ" ["داغ داغ"] ; hot_A = mkA "داغ" ["داغ داغ"] ;
house_N = mkN01 "خانه" inanimate; house_N = mkN01 "خانه" inanimate;
@@ -106,7 +106,7 @@ concrete LexiconPes of Lexicon = CatPes **
iron_N = mkN01 "آهن" inanimate; iron_N = mkN01 "آهن" inanimate;
king_N = mkN "پادشاه" "پادشاهان" animate; king_N = mkN "پادشاه" "پادشاهان" animate;
know_V2 = mkV2 (mkV "شناختن" "شناس") "را"; 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 "دانستن") ; know_VQ = (mkV_1 "دانستن") ;
lake_N = mkN01 "دریاچه" inanimate; lake_N = mkN01 "دریاچه" inanimate;
lamp_N = mkN01 "چراغ" inanimate; -- also "لامپ", but they have different usage 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 "سقف" roof_N = mkN01 "بام" inanimate; -- has variant "سقف"
rubber_N = mkN01 "پاککن" inanimate; -- also "لاستیک" rubber_N = mkN01 "پاککن" inanimate; -- also "لاستیک"
run_V = mkV_1 "دویدن" ; run_V = mkV_1 "دویدن" ;
say_VS = mkV "گفتن" "گوی" ; say_VS = mkVS (mkV "گفتن" "گوی") ;
school_N = mkN "مدرسه" "مدارس" inanimate; school_N = mkN "مدرسه" "مدارس" inanimate;
science_N = mkN "علم" "علوم" inanimate; -- also "دانش" science_N = mkN "علم" "علوم" inanimate; -- also "دانش"
sea_N = mkN01 "دریا" inanimate; sea_N = mkN01 "دریا" inanimate;
@@ -215,7 +215,7 @@ concrete LexiconPes of Lexicon = CatPes **
woman_N = mkN02 "زن" animate; woman_N = mkN02 "زن" animate;
wonder_VQ = compoundV "متعجب" beVerb ; wonder_VQ = compoundV "متعجب" beVerb ;
wood_N = mkN01 "چوب" inanimate; 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 "زرد" ; yellow_A = mkA "زرد" ;
young_A = mkA "جوان""جوانانه" ; young_A = mkA "جوان""جوانانه" ;
do_V2 = mkV2 (compoundV "انجام" giveVerb) "را"; do_V2 = mkV2 (compoundV "انجام" giveVerb) "را";

View File

@@ -150,7 +150,8 @@ oper
Adjective : Type = { Adjective : Type = {
s : Mod => Str ; s : Mod => Str ;
adv : 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 -> { mkAdj : Str -> Str -> Adjective = \adj,adv -> {
@@ -159,7 +160,7 @@ oper
Clitic => mkEnclic adj ; Clitic => mkEnclic adj ;
Poss => mkPossStem 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 : Str -> A ; -- Regular adjective, same form for adjective and adverb.
mkA : (adj,adv : Str) -> A -- Different forms 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. mkA2 : (married,to : Str) -> A2 -- Takes string and complementiser, returns A2.
= \a,c -> lin A2 (mkAdj a a ** {c2 = c}) ; = \a,c -> lin A2 (mkAdj a a ** {c2 = c}) ;
@@ -148,9 +149,9 @@ oper
mkVS = overload { mkVS = overload {
mkVS : Str -> VS -- predictable verb with sentence complement 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 mkVS : V -> VS -- VS out of a verb
= \v -> lin VS v = \v -> lin VS (v ** {compl=subjunctive})
} ; } ;
mkVV = overload { mkVV = overload {
@@ -303,6 +304,8 @@ oper
= \a,c -> lin A2 (mkAdj a a ** {c2 = c}) = \a,c -> lin A2 (mkAdj a a ** {c2 = c})
} ; } ;
prefixA a = a ** {isPre=True};
preA : (adj,adv : Str) -> A = \adj,adv -> preA : (adj,adv : Str) -> A = \adj,adv ->
lin A ((mkAdj adj adv) ** {isPre=True}) ; lin A ((mkAdj adj adv) ** {isPre=True}) ;

View File

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

View File

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

View File

@@ -24,8 +24,8 @@ concrete SymbolPes of Symbol = CatPes ** open Prelude, ResPes in {
} ; } ;
SymbS sy = {s = \\_ => sy.s} ; SymbS sy = {s = \\_ => sy.s} ;
SymbNum sy = { s = sy.s ; n = Pl } ; 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 lincat

View File

@@ -13,9 +13,13 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
ComplSlash = complSlash ; ComplSlash = complSlash ;
ComplVV = insertVV ; 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) ; 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 ; SlashVV vv vps = vps ** ComplVV vv vps ;
SlashV2S v s = predVc v ** embComp (conjThat ++ s.s ! Indic) (predV v) ; SlashV2S v s = predVc v ** embComp (conjThat ++ s.s ! Indic) (predV v) ;