1
0
forked from GitHub/gf-rgl

Merge pull request #195 from inariksit/persian

Persian
This commit is contained in:
Inari Listenmaa
2019-03-13 12:36:47 +01:00
committed by GitHub
6 changed files with 72 additions and 45 deletions

View File

@@ -62,8 +62,7 @@ concrete CatPes of Cat = CommonX - [Adv] ** open ResPes, Prelude in {
Num = {s : Str ; n : Number ; isNum : Bool} ;
Card = {s : Str; n : Number} ;
Ord = {s : Str; n : Number ; isNum : Bool} ;
Quant = {s: Number => Str ; a:Agr ; mod : Mod};
Art = {s : Str} ;
Quant = ResPes.Quant ;
---- Numeral

View File

@@ -2,7 +2,7 @@
concrete ExtendPes of Extend =
CatPes ** ExtendFunctor - [
GenNP, ApposNP
GenNP, ApposNP, ICompAP
]
with (Grammar=GrammarPes)
** open Prelude, ResPes in {
@@ -11,11 +11,13 @@ lin
-- NP -> Quant ; -- this man's
GenNP np = np ** {
mod = Ezafe ; -- the possessed will get Ezafe
s = \\num => np.s ! Bare -- possesser is unmarked; https://sites.la.utexas.edu/persian_online_resources/language-specific-grammar/ezfe/
s = \\num,cmpd => np.s ! Bare -- possesser is unmarked; https://sites.la.utexas.edu/persian_online_resources/language-specific-grammar/ezfe/
} ;
-- : NP -> NP -> NP
ApposNP np1 np2 = np1 ** {
s = \\m => np1.s ! m ++ np2.s ! m
} ;
ICompAP ap = {s = "چقدر" ++ ap.s ! Bare} ;
}

View File

@@ -1,19 +1,10 @@
concrete ExtraPes of ExtraPesAbs = CatPes **
open ResPes, Coordination, Prelude, MorphoPes, ParadigmsPes in {
open ResPes, ExtendPes, Coordination, Prelude, MorphoPes, ParadigmsPes in {
flags coding = utf8;
lin
GenNP np = {s = \\_ => np.s ! Ezafe ; a = np.a ; mod = Ezafe} ; -- changed from mod=False for Phrasebook
GenNP = ExtendPes.GenNP ;
-- each_Det = mkDet "هر کwی" "هر کwی" "هر کwی" "هر کwی" Sg ;
-- have_V = mkV "رکh-ن";
IAdvAdv adv = {s = "تا چه" ++ adv.s} ;
-- ICompAP ap = {s = "کتنE" ++ ap.s ! Sg ! Masc ! Dir ! Posit} ;
-- cost_V = mkV "قیمت" ;
-- added for causitives
-- make_CV = mkVerb "نْتهنگ" ** {c2 = "" };
-- for VP conjunction
}

View File

@@ -31,6 +31,7 @@ param
Animacy = Animate | Inanimate ;
Mod = Bare | Ezafe | Clitic | Poss ;
Agr = Ag Number Person ;
CmpdStatus = IsCmpd | NotCmpd ;
------------------------------------------
-- Agreement transformations
@@ -90,9 +91,14 @@ oper
_ => str + "ی" -- any other case: just a single ی
} ;
Noun = {s : Number => Mod => Str ; animacy : Animacy} ;
mkN : (x1,x2 : Str) -> Animacy -> Noun = \sg,pl,ani -> {
s = table {
Noun = {
s : Number => Mod => Str ;
animacy : Animacy ;
isCmpd : CmpdStatus -- Affects possession: awkward to use poss. suff. with compound nouns
} ;
mkN : (x1,x2 : Str) -> Animacy -> Noun = \sg,pl,ani -> {
s = table {
Sg => table {Bare => sg ;
Ezafe => mkEzafe sg ;
Clitic => mkEnclic sg ;
@@ -102,7 +108,7 @@ oper
Clitic => mkEnclic pl ;
Poss => mkPossStem pl }
} ;
animacy = ani
animacy = ani ; isCmpd = NotCmpd
} ;
-- masculine nouns end with alif, choTi_hay, ain Translitration: (a, h, e)
@@ -111,20 +117,30 @@ oper
---------------------
--Determiners
--------------------
Determiner : Type = {s : Str ; n :Number ; isNum : Bool ; mod : Mod} ;
BaseQuant : Type = {
mod : Mod } ;
makeDet : Str -> Number -> Bool -> Determiner = \str,n,b -> {
s = str;
isNum = b;
mod = Bare ;
n = n
};
Determiner : Type = BaseQuant ** {
s : Str ;
sp : Str ; -- stand-alone form for DetNP and possessive pronouns with compound nouns
n : Number ;
isNum : Bool
} ;
makeQuant : Str -> Str -> {s : Number => Str ; a : Agr; mod : Mod } = \sg,pl -> {
s = table {Sg => sg ; Pl => pl} ;
mod = Bare ;
a = agrP3 Sg
};
Quant : Type = BaseQuant ** {
s : Number => CmpdStatus => Str} ;
makeDet : Str -> Number -> Bool -> Determiner = \str,n,b -> {
s,sp = str;
isNum = b;
mod = Bare ;
n = n
};
makeQuant : Str -> Str -> Quant = \sg,pl -> {
s = table {Sg => \\_ => sg ; Pl => \\_ => pl} ;
mod = Bare ;
};
---------------------------
-- Adjectives
--------------------------

View File

@@ -8,9 +8,15 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
let num : Number = case det.isNum of {
True => Sg ; -- noun modified by a number is invariably singular
False => det.n } ;
in case det.mod of {
Bare => det.s ++ cn.s ! num ! m ; -- det doesn't require a special form, keep the Mod=>Str table
x => cn.s ! num ! x ++ det.s } ; -- det requires a special form
mod : Mod = case <cn.isCmpd,det.mod> of {
<IsCmpd,Poss> => Ezafe ; -- If CN is compound and Det is poss.pron, don't use poss.suff but Ezafe and full form of pronoun
_ => det.mod } ;
detStr : Str = case cn.isCmpd of {
IsCmpd => det.sp ;
NotCmpd => det.sp } ;
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
} ;
@@ -35,28 +41,35 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
} ;
DetQuantOrd quant num ord = {
s = quant.s ! num.n ++ num.s ++ ord.s ;
s = quant.s ! num.n ! NotCmpd ++ num.s ++ ord.s ;
sp = quant.s ! num.n ! IsCmpd ; -- only matters for PossPron
isNum = orB num.isNum ord.isNum ;
mod = quant.mod ;
n = num.n
} ;
DetQuant quant num = {
s = quant.s ! num.n ++ num.s;
s = quant.s ! num.n ! NotCmpd ++ num.s ;
sp = quant.s ! num.n ! IsCmpd ; -- only matters for PossPron
isNum = num.isNum;
mod = quant.mod ;
n = num.n
} ;
DetNP det = {
s = \\_ => det.s ; ---- case
s = \\_ => det.sp ;
a = agrP3 det.n ;
hasAdj = False ;
animacy = Inanimate ;
compl = []
} ;
PossPron p = {s = \\_ => BIND ++ p.ps ; a = p.a ; mod = Poss} ;
PossPron p = {
s = \\_ => table {
NotCmpd => BIND ++ p.ps ;
IsCmpd => p.s } ; -- is a compound
a = p.a ;
mod = Poss} ; -- make into Ezafe if DetCN if N is compound
NumSg = {s = [] ; n = Sg ; isNum = False} ;
NumPl = {s = [] ; n = Pl ; isNum = False} ;
@@ -73,8 +86,8 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
OrdSuperl a = {s = a.s ! Bare ++ taryn; n = Sg ; isNum=False} ; -- check the form of adjective
DefArt = {s = \\_ => [] ; a = defaultAgr ; mod = Bare} ;
IndefArt = {s = table {Sg => IndefArticle ; Pl => []} ; a = defaultAgr ; mod = Bare} ;
DefArt = {s = \\_,_ => [] ; mod = Bare} ;
IndefArt = {s = table {Sg => \\_ => IndefArticle ; Pl => \\_ => []} ; mod = Bare} ;
MassNP cn = cn ** {
s = cn.s ! Sg ;

View File

@@ -53,7 +53,9 @@ oper
cmpdN : N -> Str -> N -- Compound noun with an invariable modifier /after/ the head. NB. no ezāfe.
= mkCmpdNoun2 ; -- e.g. مأمور پلیس '/officer/ police'.
cmpdN : N -> N -> N -- Compound noun with ezafe (Nی N)
= \n1,n2 -> n1 ** {s = \\n,m => n1.s ! n ! Ezafe ++ n2.s ! n ! m} ;
= \n1,n2 -> n1 ** {
s = \\n,m => n1.s ! n ! Ezafe ++ n2.s ! n ! m ;
isCmpd = IsCmpd} ;
} ;
-- Proper names
@@ -290,10 +292,14 @@ oper
\s1,s2,s3,s4,n,g -> let p = mkIntPronForm s1 s2 s3 s4 in { s = p.s ; n = n ; g = g ; lock_IP = <>};
-}
mkCmpdNoun1 : Str -> N -> N
= \s,noun -> noun ** {s =\\ez,n => s ++ noun.s ! ez ! n};
mkCmpdNoun2 : N -> Str -> N
= \noun,s -> noun ** {s =\\ez,n => noun.s ! ez ! n ++ s};
mkCmpdNoun1 : Str -> N -> N = \s,noun ->
noun ** {
s = \\ez,n => s ++ noun.s ! ez ! n ;
isCmpd = IsCmpd} ;
mkCmpdNoun2 : N -> Str -> N = \noun,s ->
noun ** {
s = \\ez,n => noun.s ! ez ! n ++ s ;
isCmpd = IsCmpd};
-- hidden from public API
compoundV = overload {