mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-05-27 17:08:54 -06:00
@@ -59,9 +59,9 @@ concrete CatPes of Cat = CommonX - [Adv] ** open ResPes, Prelude in {
|
||||
Pron = {s : Str ; ps : Str ; a : AgrPes};
|
||||
Det = ResPes.Determiner ;
|
||||
Predet = {s : Str} ;
|
||||
Num = {s : Str ; n : Number} ;
|
||||
Num = {s : Str ; n : Number ; isNum : Bool} ;
|
||||
Card = {s : Str; n : Number} ;
|
||||
Ord = {s : Str; n : Number} ;
|
||||
Ord = {s : Str; n : Number ; isNum : Bool} ;
|
||||
Quant = {s: Number => Str ; a:AgrPes ; fromPron : Bool};
|
||||
Art = {s : Str} ;
|
||||
|
||||
@@ -87,10 +87,10 @@ concrete CatPes of Cat = CommonX - [Adv] ** open ResPes, Prelude in {
|
||||
A = ResPes.Adjective ; --- {s : Gender => Number => Case => Str} ;
|
||||
A2 = ResPes.Adjective ** { c2 : Str} ;
|
||||
|
||||
N = {s : Ezafa => Number => Str ; animacy : Animacy ; definitness : Bool} ;
|
||||
N = ResPes.Noun ;
|
||||
|
||||
N2 = {s : Ezafa => Number => Str ; animacy : Animacy ; definitness : Bool} ** {c : Str};
|
||||
N3 = {s : Ezafa => Number => Str ; animacy : Animacy ; definitness : Bool} ** {c2 : Str ; c3 : Str } ;
|
||||
N2 = ResPes.Noun ** {c : Str};
|
||||
N3 = ResPes.Noun ** {c2 : Str ; c3 : Str} ;
|
||||
PN = {s : Str ; animacy : Animacy} ;
|
||||
|
||||
}
|
||||
|
||||
17
src/persian/ExtendPes.gf
Normal file
17
src/persian/ExtendPes.gf
Normal file
@@ -0,0 +1,17 @@
|
||||
--# -path=.:../common:../abstract:../prelude
|
||||
|
||||
concrete ExtendPes of Extend =
|
||||
CatPes ** ExtendFunctor - [
|
||||
GenNP
|
||||
]
|
||||
with (Grammar=GrammarPes)
|
||||
** open Prelude, ResPes in {
|
||||
|
||||
lin
|
||||
-- NP -> Quant ; -- this man's
|
||||
GenNP np = np ** {
|
||||
s = \\num => np.s ! NPC bEzafa ; -- the possessed will get aEzafa, possesser is just unmarked; https://sites.la.utexas.edu/persian_online_resources/language-specific-grammar/ezfe/
|
||||
fromPron = True -- not necessarily from Pron, but it should come after the noun, and if fromPron=True, then DetCN places determiner after cn.
|
||||
} ;
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
--# -path=.:../abstract:../common:../hindustani
|
||||
--# -path=.:../abstract:../common
|
||||
|
||||
concrete LangPes of Lang =
|
||||
GrammarPes,
|
||||
LexiconPes
|
||||
GrammarPes
|
||||
,LexiconPes
|
||||
** {
|
||||
|
||||
flags startcat = Phr ; unlexer=unwords ; lexer=words ;
|
||||
|
||||
@@ -3,11 +3,11 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
|
||||
flags optimize=all_subs ;
|
||||
|
||||
lin
|
||||
DetCN det cn = {
|
||||
s = \\_ => case <det.isNum,det.fromPron> of {
|
||||
<False,True> => cn.s ! aEzafa ! det.n ++ det.s ; -- det.n ;
|
||||
<False,False> => det.s ++ cn.s ! bEzafa ! det.n ; -- det.n ;
|
||||
<True,True> => cn.s ! aEzafa ! Sg ++ det.s ;
|
||||
DetCN det cn = { s = \\_ =>
|
||||
case <det.isNum,det.fromPron> of {
|
||||
<False,True> => cn.s ! aEzafa ! det.n ++ det.s ;
|
||||
<False,False> => det.s ++ cn.s ! bEzafa ! det.n ;
|
||||
<True,True> => cn.s ! aEzafa ! Sg ++ det.s ; -- noun modified by a number is invariably singular
|
||||
<True,False> => det.s ++ cn.s ! bEzafa ! Sg
|
||||
};
|
||||
a = agrPesP3 det.n ;
|
||||
@@ -17,40 +17,32 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
|
||||
UsePN pn = {s = \\_ => pn.s ; a = agrPesP3 Sg ; animacy = pn.animacy } ;
|
||||
UsePron p = {s = \\_ => p.s ; a = p.a ; animacy = Animate} ;
|
||||
|
||||
PredetNP pred np = {
|
||||
s = \\ez => pred.s ++ np.s ! ez ;
|
||||
a = np.a;
|
||||
animacy = np.animacy
|
||||
PredetNP pred np = np ** {
|
||||
s = \\ez => pred.s ++ np.s ! ez
|
||||
} ;
|
||||
|
||||
PPartNP np v2 = {
|
||||
s = \\ez => np.s ! ez ++ partNP (v2.s ! Root1) ;
|
||||
a = np.a ;
|
||||
animacy = np.animacy
|
||||
PPartNP np v2 = np ** {
|
||||
s = \\ez => np.s ! ez ++ partNP (v2.s ! Root1)
|
||||
} ;
|
||||
|
||||
RelNP np rs = {
|
||||
s = \\ez => np.s ! ez ++ rs.s ! np.a ;
|
||||
a = np.a ;
|
||||
animacy = np.animacy
|
||||
RelNP np rs = np ** {
|
||||
s = \\ez => np.s ! ez ++ rs.s ! np.a
|
||||
} ;
|
||||
|
||||
AdvNP np adv = {
|
||||
s = \\ez => np.s ! NPC aEzafa ++ adv.s ;
|
||||
a = np.a ;
|
||||
animacy = np.animacy
|
||||
AdvNP np adv = np ** {
|
||||
s = \\ez => np.s ! NPC aEzafa ++ adv.s
|
||||
} ;
|
||||
|
||||
DetQuantOrd quant num ord = {
|
||||
s = quant.s ! num.n ++ num.s ++ ord.s ;
|
||||
isNum = True;
|
||||
isNum = orB num.isNum ord.isNum ;
|
||||
fromPron = quant.fromPron ;
|
||||
n = num.n
|
||||
} ;
|
||||
|
||||
DetQuant quant num = {
|
||||
s = quant.s ! num.n ++ num.s;
|
||||
isNum = True ; -- this does not work in case of 'these women' but works in case of 'five women'
|
||||
isNum = num.isNum;
|
||||
fromPron = quant.fromPron ;
|
||||
n = num.n
|
||||
} ;
|
||||
@@ -63,20 +55,20 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
|
||||
|
||||
PossPron p = {s = \\_ => p.ps ; a = p.a ; fromPron = True} ;
|
||||
|
||||
NumSg = {s = [] ; n = Sg} ;
|
||||
NumPl = {s = [] ; n = Pl} ;
|
||||
NumSg = {s = [] ; n = Sg ; isNum = False} ;
|
||||
NumPl = {s = [] ; n = Pl ; isNum = False} ;
|
||||
-- from here
|
||||
NumCard n = n ** {hasCard = True} ;
|
||||
NumCard n = n ** {isNum = True} ;
|
||||
|
||||
NumDigits n = {s = n.s ! NCard ; n = n.n} ;
|
||||
OrdDigits n = {s = n.s ! NOrd; n = n.n} ;
|
||||
NumDigits n = n ** {s = n.s ! NCard; isNum = True} ;
|
||||
OrdDigits n = n ** {s = n.s ! NOrd ; isNum = True} ;
|
||||
|
||||
NumNumeral numeral = {s = numeral.s ! NCard; n = numeral.n} ;
|
||||
OrdNumeral numeral = {s = numeral.s ! NOrd ; n = numeral.n} ;
|
||||
NumNumeral n = n ** {s = n.s ! NCard; isNum = True} ;
|
||||
OrdNumeral n = n ** {s = n.s ! NOrd ; isNum = True} ;
|
||||
-- to here
|
||||
AdNum adn num = {s = adn.s ++ num.s ; n = num.n} ;
|
||||
AdNum adn num = num ** {s = adn.s ++ num.s} ;
|
||||
|
||||
OrdSuperl a = {s = a.s ! bEzafa ++ taryn; n = Sg} ; -- check the form of adjective
|
||||
OrdSuperl a = {s = a.s ! bEzafa ++ taryn; n = Sg ; isNum=False} ; -- check the form of adjective
|
||||
|
||||
DefArt = {s = \\_ => [] ; a = defaultAgrPes ; fromPron = False} ;
|
||||
IndefArt = {s = table { Sg => IndefArticle ; Pl => []} ; a =defaultAgrPes ; fromPron = False} ;
|
||||
@@ -119,22 +111,18 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
|
||||
definitness = True;
|
||||
} ;
|
||||
|
||||
AdjCN ap 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
|
||||
animacy = cn.animacy ;
|
||||
definitness = cn.definitness
|
||||
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
|
||||
} ;
|
||||
|
||||
RelCN cn rs = {
|
||||
RelCN cn rs = cn ** {
|
||||
s = \\ez,n => cn.s ! enClic ! n ++ rs.s ! agrPesP3 n ;
|
||||
animacy = cn.animacy ;
|
||||
definitness = cn.definitness
|
||||
} ;
|
||||
|
||||
AdvCN cn ad = {s = \\ez,n => cn.s ! aEzafa ! n ++ ad.s ; animacy = cn.animacy ; definitness = cn.definitness} ;
|
||||
AdvCN cn ad = cn ** {s = \\ez,n => cn.s ! aEzafa ! n ++ ad.s} ;
|
||||
|
||||
SentCN cn sc = {s = \\ez,n => cn.s ! ez ! n ++ sc.s ; animacy = cn.animacy ; definitness = cn.definitness} ;
|
||||
SentCN cn sc = cn ** {s = \\ez,n => cn.s ! ez ! n ++ sc.s} ;
|
||||
|
||||
ApposCN cn np = {s = \\ez,n => cn.s ! ez ! n ++ np.s ! NPC aEzafa ; animacy = cn.animacy ; definitness = True} ; -- ezafa form of city to be used
|
||||
ApposCN cn np = cn ** {s = \\ez,n => cn.s ! ez ! n ++ np.s ! NPC aEzafa ; definitness = True} ; -- ezafa form of city to be used
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--# -path=.:../abstract:../../prelude:../common
|
||||
--# -path=.:../abstract:../prelude:../common
|
||||
--
|
||||
----1 Pnbu Lexical Paradigms
|
||||
----1 Persian Lexical Paradigms
|
||||
|
||||
resource ParadigmsPes = open
|
||||
Predef,
|
||||
@@ -23,13 +23,25 @@ oper
|
||||
singular = Sg ; plural = Pl;
|
||||
|
||||
animate = Animate ; inanimate = Inanimate ; --i
|
||||
mkN01 : Str -> Animacy -> Noun ;
|
||||
mkN01 str ani = mkN str (str ++ "ها") ani;
|
||||
mkN02 : Str -> Animacy -> Noun ;
|
||||
mkN02 str ani = case (last str) of {
|
||||
"ه" => mkN str ((init str) + "گان") ani ;
|
||||
("ا"|"و") => mkN str (str + "یان") ani ;
|
||||
_ => mkN str (str+"ان") ani
|
||||
mkN01 : (sg : Str) -> Animacy -> Noun ; -- Takes singular form and animacy, forms plural with ها
|
||||
mkN01 sg ani =
|
||||
let pl = zwnj sg "ها" ; -- Using zero-width non-joiner, defined in ResPes
|
||||
in MorphoPes.mkN sg pl ani ;
|
||||
|
||||
mkN02 : (sg : Str) -> Animacy -> Noun ; -- Takes singular form and animacy, pattern matches singular and forms plural with either گان, یان or ان
|
||||
mkN02 str ani = case last str of {
|
||||
"ه" => MorphoPes.mkN str (init str + "گان") ani ;
|
||||
("ا"|"و") => MorphoPes.mkN str (str + "یان") ani ;
|
||||
_ => MorphoPes.mkN str (str + "ان") ani
|
||||
};
|
||||
|
||||
mkN = overload {
|
||||
mkN : (sg : Str) -> N -- Takes singular form, returns an inanimate noun with ها as the plural form
|
||||
= \sg -> mkN01 sg inanimate ;
|
||||
mkN : (sg,pl : Str) -> N -- Takes singular and plural form, returns an inanimate noun
|
||||
= \sg,pl -> MorphoPes.mkN sg pl inanimate ;
|
||||
mkN : (sg,pl : Str) -> Animacy -> N -- Worst-case constructor: takes singular and plural forms and animacy
|
||||
= \sg,pl,ani -> MorphoPes.mkN sg pl ani
|
||||
} ;
|
||||
{-
|
||||
|
||||
@@ -45,20 +57,19 @@ oper
|
||||
-- Compound Nouns
|
||||
|
||||
mkCmpdNoun1 : Str -> N -> N
|
||||
= \s,noun -> {s =\\ez,n => s ++ noun.s ! ez ! n ; animacy = noun.animacy ; definitness = noun.definitness ; lock_N = <>};
|
||||
= \s,noun -> noun ** {s =\\ez,n => s ++ noun.s ! ez ! n};
|
||||
mkCmpdNoun2 : N -> Str -> N
|
||||
= \noun,s -> {s =\\ez,n => noun.s ! ez ! n ++ s ; animacy = noun.animacy ; definitness =noun.definitness ; lock_N = <>};
|
||||
= \noun,s -> noun ** {s =\\ez,n => noun.s ! ez ! n ++ s};
|
||||
|
||||
|
||||
-- Proper names
|
||||
mkPN : Str -> Animacy -> PN =
|
||||
|
||||
\str,ani -> {s = str ; animacy = ani ; lock_PN = <>} ;
|
||||
mkPN : Str -> Animacy -> PN
|
||||
= \str,ani -> lin PN {s = str ; animacy = ani} ;
|
||||
|
||||
|
||||
-- Personal Pronouns
|
||||
personalPN : Str -> Number -> PPerson -> Pron =
|
||||
\str,nn,p -> {s = str ; a = AgPes nn p ; ps = str ; lock_Pron = <>};
|
||||
personalPN : Str -> Number -> PPerson -> Pron
|
||||
= \str,nn,p -> lin Pron {s = str ; a = AgPes nn p ; ps = str};
|
||||
{-
|
||||
-- Demonstration Pronouns
|
||||
demoPN : Str -> Str -> Str -> Quant =
|
||||
@@ -66,10 +77,10 @@ oper
|
||||
-- Determiner
|
||||
-}
|
||||
mkDet = overload {
|
||||
mkDet : Str -> Number -> Det =
|
||||
\s1,n -> makeDet s1 n False ** { lock_Det = <>};
|
||||
mkDet : Str -> Number -> Bool -> Det =
|
||||
\s1,n,b -> makeDet s1 n b ** { lock_Det = <>};
|
||||
mkDet : Str -> Number -> Det
|
||||
= \s1,n -> lin Det (makeDet s1 n False);
|
||||
mkDet : Str -> Number -> Bool -> Det
|
||||
= \s1,n,b -> lin Det (makeDet s1 n b)
|
||||
};
|
||||
{-
|
||||
-- Intergative pronouns
|
||||
@@ -83,11 +94,11 @@ oper
|
||||
|
||||
mkA = overload {
|
||||
mkA : Str -> A
|
||||
= \str -> mkAdj str str ** { lock_A = <>} ;
|
||||
= \str -> lin A (mkAdj str str);
|
||||
mkA : Str-> Str -> A
|
||||
= \str,adv -> mkAdj str adv ** { lock_A = <>} ;
|
||||
= \str,adv -> lin A (mkAdj str adv);
|
||||
mkA : Str -> Str -> A2
|
||||
= \a,c -> mkAdj a a ** { c2 = c ; lock_A2 = <>} ;
|
||||
= \a,c -> lin A2 (mkAdj a a ** {c2 = c})
|
||||
} ;
|
||||
|
||||
--2 Verbs
|
||||
@@ -113,26 +124,28 @@ oper
|
||||
} ;
|
||||
|
||||
mkV3 : V -> Str -> Str -> V3;
|
||||
mkV3 v p q = v ** { c2 = p ; c3 = q ; lock_V3 = <>} ;
|
||||
mkV3 v p q = lin V3 (v ** {c2 = p ; c3 = q}) ;
|
||||
mkV2V : V -> Str -> Str -> Bool -> V2V ;
|
||||
mkV2V v s1 s2 b = v ** {isAux = b ; c1 = s1 ; c2 = s2 ; lock_V2V = <>} ;
|
||||
mkV2V v s1 s2 b = lin V2V (v ** {isAux = b ; c1 = s1 ; c2 = s2}) ;
|
||||
|
||||
-- compund verbs
|
||||
compoundV = overload {
|
||||
compoundV : Str -> V -> V = \s,v -> {s = \\vf => s ++ v.s ! vf ; lock_V = <>} ;
|
||||
compoundV : Str -> V2 -> V = \s,v -> {s = \\vf => s ++ v.s ! vf ; lock_V = <>} ;
|
||||
compoundV : Str -> V -> V
|
||||
= \s,v -> v ** {s = \\vf => s ++ v.s ! vf} ;
|
||||
compoundV : Str -> V2 -> V
|
||||
= \s,v -> lin V {s = \\vf => s ++ v.s ! vf} ;
|
||||
};
|
||||
|
||||
invarV : Str -> V -- for verbs like " بایستن " ("must"), which don't inflect
|
||||
= \s -> lin V {s = \\_ => s} ;
|
||||
|
||||
----2 Adverbs
|
||||
mkAdv : Str -> Adv = \str -> {s = str ; lock_Adv = <>};
|
||||
mkAdv : Str -> Adv = \str -> lin Adv {s = str} ;
|
||||
|
||||
----2 Prepositions
|
||||
|
||||
mkPrep : Str -> Prep ;
|
||||
mkPrep str = {s = str ; lock_Prep = <>};
|
||||
mkPrep str = lin Prep {s = str};
|
||||
{-
|
||||
--3 Determiners and quantifiers
|
||||
|
||||
@@ -186,23 +199,5 @@ oper
|
||||
--
|
||||
-- V0 : Type ;
|
||||
-- AS, A2S, AV, A2V : Type ;
|
||||
--
|
||||
----.
|
||||
----2 Definitions of paradigms
|
||||
----
|
||||
---- The definitions should not bother the user of the API. So they are
|
||||
---- hidden from the document.
|
||||
--
|
||||
-- Gender = MorphoHin.Gender ;
|
||||
-- Number = MorphoHin.Number ;
|
||||
-- Case = MorphoHin.Case ;
|
||||
-- human = Masc ;
|
||||
-- nonhuman = Neutr ;
|
||||
-- masculine = Masc ;
|
||||
-- feminine = Fem ;
|
||||
-- singular = Sg ;
|
||||
-- plural = Pl ;
|
||||
-- nominative = Nom ;
|
||||
-- genitive = Gen ;
|
||||
-}
|
||||
--}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ resource ResPes = ParamX ** open Prelude,Predef in {
|
||||
Neg => CNeg b
|
||||
} ;
|
||||
|
||||
-- Zero-width non-joiner, used for certain morphemes
|
||||
-- See https://en.wikipedia.org/wiki/Persian_alphabet#Word_boundaries
|
||||
ZWNJ : Str = "" ;
|
||||
zwnj : Str -> Str -> Str = \s1,s2 -> s1 + ZWNJ + s2 ;
|
||||
-----------------------
|
||||
--- Verb Phrase
|
||||
-----------------------
|
||||
|
||||
@@ -28,7 +28,7 @@ concrete SymbolPes of Symbol = CatPes ** open Prelude, ResPes in {
|
||||
|
||||
SymbS sy = sy ;
|
||||
SymbNum sy = { s = sy.s ; n = Pl } ;
|
||||
SymbOrd sy = { s = sy.s ++ "wN" ; n = Pl} ;
|
||||
SymbOrd sy = { s = sy.s ++ "wN" ; n = Pl; isNum=False} ;
|
||||
|
||||
lincat
|
||||
|
||||
|
||||
@@ -41,9 +41,10 @@ concrete VerbPes of Verb = CatPes ** open ResPes in {
|
||||
ReflVP v = insertObjPre (\\a => reflPron ! a) v ;
|
||||
PassV2 v = predV v ; -- need to be fixed
|
||||
CompAP ap ={s = \\_ => ap.s ! bEzafa} ; -- check form of adjective
|
||||
CompNP np = {s = \\a => np.s ! NPC bEzafa} ;
|
||||
CompAdv adv = {s = \\_ => adv.s } ;
|
||||
CompCN cn = {s = \\a => cn.s ! bEzafa ! giveNumber a } ;
|
||||
|
||||
-- IL 2019-01-31 changed bEzafa to enClic according to
|
||||
-- https://sites.la.utexas.edu/persian_online_resources/nouns/noun-in-a-predicative-position/
|
||||
CompNP np = {s = \\a => np.s ! NPC enClic} ;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user