1
0
forked from GitHub/gf-rgl

Merge pull request #181 from inariksit/persian

Persian
This commit is contained in:
Inari Listenmaa
2019-02-20 15:20:53 +01:00
committed by GitHub
4 changed files with 31 additions and 28 deletions

View File

@@ -188,7 +188,7 @@ concrete LexiconPes of Lexicon = CatPes **
switch8off_V2 = mkV2 (compoundV "خاموش" doVerb) "را"; switch8off_V2 = mkV2 (compoundV "خاموش" doVerb) "را";
switch8on_V2 = mkV2 (compoundV "روشن" doVerb) "را"; switch8on_V2 = mkV2 (compoundV "روشن" doVerb) "را";
table_N = mkN01 "میز" inanimate; table_N = mkN01 "میز" inanimate;
talk_V3 = mkV3 (compoundV "حرف" hitVerb) "با" [" درباره ی"]; talk_V3 = mkV3 (compoundV "حرف" hitVerb) "با" "دربارۀ";
teacher_N = mkN02 "معلم" animate; teacher_N = mkN02 "معلم" animate;
teach_V2 = mkV2 (compoundV "آموزش" giveVerb) "را"; teach_V2 = mkV2 (compoundV "آموزش" giveVerb) "را";
television_N = mkN01 "تلوزیون" inanimate; television_N = mkN01 "تلوزیون" inanimate;
@@ -202,18 +202,18 @@ concrete LexiconPes of Lexicon = CatPes **
understand_V2 = mkV2 (mkV_1 "فهمیدن") "را"; understand_V2 = mkV2 (mkV_1 "فهمیدن") "را";
university_N = mkN01 "دانشگاه" inanimate; university_N = mkN01 "دانشگاه" inanimate;
village_N = mkN01 "روستا" inanimate; village_N = mkN01 "روستا" inanimate;
-- wait_V2 = mkV2 (compoundV "منتظر" (mkVToBe "بودن" "باش")); wait_V2 = mkV2 (compoundV "منتظر" beVerb);
walk_V = compoundV "راه" (mkV "رفتن" "رو"); walk_V = compoundV "راه" (mkV "رفتن" "رو");
warm_A = mkA "گرم" ; warm_A = mkA "گرم" ;
war_N = mkN01 "جنگ" inanimate; war_N = mkN01 "جنگ" inanimate;
-- watch_V2 = mkV2 (compoundV "مراقب" (mkVToBe "بودن" "باش")); -- check harfe rabt!!! watch_V2 = mkV2 (compoundV "مراقب" beVerb); -- check harfe rabt!!!
water_N = mkN01 "آب" inanimate; water_N = mkN01 "آب" inanimate;
white_A = mkA "سفید" ; white_A = mkA "سفید" ;
window_N = mkN01 "پنجره" inanimate; window_N = mkN01 "پنجره" inanimate;
wine_N = mkN01 "شراب" inanimate; wine_N = mkN01 "شراب" inanimate;
win_V2 = mkV2 (compoundV "برنده" (mkV "شدن" "شو")) "را"; -- also possible with simple verb: mkV_2 "بردن" win_V2 = mkV2 (compoundV "برنده" (mkV "شدن" "شو")) "را"; -- also possible with simple verb: mkV_2 "بردن"
woman_N = mkN02 "زن" animate; woman_N = mkN02 "زن" animate;
-- wonder_VQ = compoundV "متعجب" (mkVToBe "بودن" "باش") ; wonder_VQ = compoundV "متعجب" beVerb ;
wood_N = mkN01 "چوب" inanimate; wood_N = mkN01 "چوب" inanimate;
write_V2 = mkV2 (mkV "نوشتن" "نویس") "را" ; write_V2 = mkV2 (mkV "نوشتن" "نویس") "را" ;
yellow_A = mkA "زرد" ; yellow_A = mkA "زرد" ;

View File

@@ -60,7 +60,7 @@ oper
case str of { case str of {
st + "اه" => str + kasre ; st + "اه" => str + kasre ;
st + "وه" => str + kasre ; st + "وه" => str + kasre ;
st + "ه" => st + "ۀ" ; -- str ++ "ی" ; st + "ه" => zwnj str "ی" ;-- alt. st + "ۀ" ;
st + "او" => str + kasre ; st + "او" => str + kasre ;
st + "وو" => str + kasre ; st + "وو" => str + kasre ;
st + "و" => str + "ی" ; st + "و" => str + "ی" ;
@@ -71,7 +71,8 @@ oper
mkEnclic : Str -> Str ; mkEnclic : Str -> Str ;
mkEnclic str = case str of { mkEnclic str = case str of {
st + ("ا"|"و") => zwnj str "یی" ; -- ی after a long vowel to help pronunciation st + ("ا"|"و") => zwnj str "یی" ; -- ی after a long vowel to help pronunciation
st + "اه" => str + "ی" ; -- here ه is a consonant, so single ی st + "اه" => zwnj str "ی" ; -- here ه is a consonant, so single ی
-- st + "اه" => str + "ی" ; -- old version, no ZWNJ
st + ("ی"|"ه") => zwnj str "ای" ; -- after ی or ه as a vowel, add an alif to help pronunciation st + ("ی"|"ه") => zwnj str "ای" ; -- after ی or ه as a vowel, add an alif to help pronunciation
_ => str + "ی" -- any other case: just a single ی _ => str + "ی" -- any other case: just a single ی
} ; } ;

View File

@@ -17,26 +17,24 @@ resource ParadigmsPes = open
oper oper
Animacy : Type ; -- Argument to mkN Animacy : Type ; -- Argument to mkN
animate : Animacy ; animate : Animacy ; -- e.g. /mkN "خواهر" animate/ to get the plural خواهران.
inanimate : Animacy ; inanimate : Animacy ; -- default animacy for mkN, not needed unless you want to make the animacy explicit or force a plural with ها.
Number : Type ; -- Argument to Number : Type ; -- Argument to mkDet and mkConj
singular : Number ; singular : Number ; -- e.g. mkConj "یا" singular
plural : Number ; plural : Number ; -- e.g. mkConj "و" plural
--2 Nouns --2 Nouns
mkN = overload { mkN = overload {
mkN : (sg : Str) -> N -- Takes singular form, returns an inanimate noun with ها as the plural form mkN : (sg : Str) -> N -- Takes singular form, returns an inanimate noun with ها as the plural form.
= \sg -> mkN01 sg inanimate ; = \sg -> mkN01 sg inanimate ;
mkN : (sg : Str) -> Animacy -> N -- Takes singular form and animacy. Inaminate plural ها. Animate plural ان or an allomorph of it (یان or گان) depending on the singular form. mkN : (sg : Str) -> Animacy -> N -- Takes singular form and animacy. Inanimate plural ها. Animate plural ان or an allomorph of it (یان or گان) depending on the singular form.
= \sg,ani -> case ani of { = \sg,ani -> case ani of {
Inanimate => mkN01 sg ani ; Inanimate => mkN01 sg ani ;
Animate => mkN02 sg ani } ; Animate => mkN02 sg ani } ;
-- mkN : (sg,pl : Str) -> N -- Takes singular and plural form, returns an inanimate noun mkN : (sg,pl : Str) -> Animacy -> N -- Worst-case constructor: takes singular and plural forms and animacy. Use for e.g. loanwords with Arabic plural, or animate nouns with ها as plural.
-- = \sg,pl -> M.mkN sg pl inanimate ;
mkN : (sg,pl : Str) -> Animacy -> N -- Worst-case constructor: takes singular and plural forms and animacy. Use for e.g. loanwords with Arabic plural.
= \sg,pl,ani -> M.mkN sg pl ani = \sg,pl,ani -> M.mkN sg pl ani
} ; } ;
@@ -93,9 +91,10 @@ oper
= \s1, s2 -> lin V (mkVerb s1 s2) = \s1, s2 -> lin V (mkVerb s1 s2)
} ; } ;
haveVerb : V = lin V M.haveVerb ; -- The verb "have", to be used for light verb constructions: e.g. compoundV "دوست" haveVerb. NB. this has different imperative and VV forms from StructuralPes.have_V2. haveVerb : V -- The verb "have", to be used for light verb constructions: e.g. compoundV "دوست" haveVerb. NB. this has different imperative and VV forms from StructuralPes.have_V2.
beVerb : V = lin V M.beVerb ; -- The verb "be", to be used for light verb constructions: e.g. compoundV "عاشق" beVerb. = lin V M.haveVerb ;
beVerb : V -- The verb "be", to be used for light verb constructions: e.g. compoundV "عاشق" beVerb.
= lin V M.beVerb ;
mkV2 : overload { mkV2 : overload {
mkV2 : Str -> V2 ; -- Predictable V2 out of string. No preposition, را for direct object. mkV2 : Str -> V2 ; -- Predictable V2 out of string. No preposition, را for direct object.
mkV2 : V -> V2 ; -- V2 out of V. No preposition, را for direct object. mkV2 : V -> V2 ; -- V2 out of V. No preposition, را for direct object.
@@ -103,10 +102,10 @@ oper
} ; } ;
mkV3 : V -> Str -> Str -> V3 ; -- Takes a verb and two prepositions (can be empty), e.g. speak, with, about mkV3 : V -> (dir,indir : Str) -> V3 ; -- Takes a verb and two prepositions as strings (can be empty). If the verb takes را for direct object, it's the first Str argument. e.g. talk, با, دربارۀ
mkV3 v p q = lin V3 (v ** {c2 = p ; c3 = q}) ; mkV3 v p q = lin V3 (v ** {c2 = p ; c3 = q}) ;
mkV2V : V -> (cV : Str) -> (cN : Str) -> (isAux : Bool) -> V2V ; -- Verb, complementiser for the verb, complementiser for the noun, whether it's auxiliary. mkV2V : V -> (cV, cN : Str) -> (isAux : Bool) -> V2V ; -- Verb, complementiser for the verb, complementiser for the noun, whether it's auxiliary.
mkV2V v s1 s2 b = lin V2V (v ** {isAux = b ; c1 = s1 ; c2 = s2}) ; mkV2V v s1 s2 b = lin V2V (v ** {isAux = b ; c1 = s1 ; c2 = s2}) ;
-- compund verbs -- compund verbs
@@ -114,11 +113,12 @@ oper
compoundV : Str -> V -> V -- Invariable prefix to a verb, e.g. compoundV "دوست" haveVerb compoundV : Str -> V -> V -- Invariable prefix to a verb, e.g. compoundV "دوست" haveVerb
} ; } ;
invarV : Str -> V -- for verbs like " بایستن " ("must"), which don't inflect invarV : Str -> V -- for verbs like بایستن ('must'), which don't inflect
= \s -> lin V {s = \\_ => s} ; = \s -> lin V {s = \\_ => s} ;
----2 Adverbs ----2 Adverbs
mkAdv : Str -> Adv = \str -> lin Adv {s = str} ; -- Takes a string, returns an adverb. mkAdv : Str -> Adv -- Takes a string, returns an adverb.
= \str -> lin Adv {s = str} ;
----2 Prepositions ----2 Prepositions
@@ -171,7 +171,9 @@ oper
mkN01 : (sg : Str) -> Animacy -> Noun ; -- Takes singular form and animacy, forms plural with ها mkN01 : (sg : Str) -> Animacy -> Noun ; -- Takes singular form and animacy, forms plural with ها
mkN01 sg ani = mkN01 sg ani =
let pl = zwnj sg "ها" ; -- Using zero-width non-joiner, defined in ResPes let pl : Str = case last sg of {
--"د"|"ذ"|"ر"|"ز"|"ژ" => sg + "ها" ; -- these letters are separated by default
_ => zwnj sg "ها" } ; -- Using zero-width non-joiner, defined in MorphoPes
in M.mkN sg pl ani ; in M.mkN sg pl ani ;
mkN02 : (sg : Str) -> Animacy -> Noun ; -- Takes singular form and animacy, pattern matches singular and forms plural with either گان, یان or ان mkN02 : (sg : Str) -> Animacy -> Noun ; -- Takes singular form and animacy, pattern matches singular and forms plural with either گان, یان or ان

View File

@@ -45,10 +45,10 @@ concrete VerbPes of Verb = CatPes ** open ResPes,Prelude in {
-- see https://sites.la.utexas.edu/persian_online_resources/nouns/noun-in-a-predicative-position/ -- see https://sites.la.utexas.edu/persian_online_resources/nouns/noun-in-a-predicative-position/
CompCN cn = { CompCN cn = {
s = \\a => cn.s ! case cn.hasAdj of { s = \\a =>
False => bEzafa ; case cn.hasAdj of {
True => enClic } False => cn.s ! bEzafa ! Sg ;
! giveNumber a True => cn.s ! enClic ! giveNumber a }
} ; } ;
CompNP np = { CompNP np = {