arabic.patch

This commit is contained in:
eldada
2006-06-25 17:07:08 +00:00
parent ea828398da
commit 996a599920
7 changed files with 586 additions and 669 deletions

View File

@@ -20,9 +20,6 @@
-- first we give a handful of patterns that aim to cover all
-- regular cases. Then we give a worst-case function $mkC$, which serves as an
-- escape to construct the most irregular words of type $C$.
-- However, this function should only seldom be needed: we have a
-- separate module $IrregularAra$, which covers all irregularly inflected
-- words.
--
-- The following modules are presupposed:
@@ -38,278 +35,48 @@ resource ParadigmsAra = open
oper
--lexical paradigms for nouns
mkN : NTable -> Gender -> Species -> N =
\nsc,gen,spec ->
{ s = nsc;
g = gen;
h = spec;
lock_N = <>
};
--takes a root string, a singular pattern string, a broken plural
--pattern string, a gender, and species. Gives a noun
regN : Str -> Str -> Str -> Gender -> Species -> N =
\root,sg,pl,gen,spec ->
let { raw = regN' root sg pl gen spec} in
{ s = \\n,d,c =>
case root of {
_ + "؟" + _ => rectifyHmz(raw.s ! n ! d ! c);
_ => raw.s ! n ! d ! c
};
g = gen;
h = spec ; lock_N = <>
};
regN' : Str -> Str -> Str -> Gender -> Species -> N =
\root,sg,pl,gen,spec ->
let { kitAb = mkWord sg root;
kutub = mkWord pl root
} in mkN (reg kitAb kutub) gen spec;
--takes a root string, a singular pattern string, a gender,
--and species. Gives a noun whose plural is sound feminine
sdfN : Str -> Str -> Gender -> Species -> N =
\root,sg,gen,spec ->
let { kalima = mkWord sg root;
} in mkN (sndf kalima) gen spec;
--takes a root string, a singular pattern string, a gender,
--and species. Gives a noun whose plural is sound masculine
sdmN : Str -> Str -> Gender -> Species -> N =
\root,sg,gen,spec ->
let { mucallim = mkWord sg root;
} in mkN (sndm mucallim) gen spec;
-- mkN3 : N -> Str -> Str -> N3 =
-- \n,p,q -> n ** {c2 = p ; c3 = q; lock_N3 = <>} ;
--lexical paradigms for adjectives
--takes a root string and a pattern string
regA : Str -> Str -> A =
\root,pat ->
let { raw = regA' root pat } in
{ s = \\g,n,d,c =>
case root of {
_ + "؟" + _ => rectifyHmz(raw.s ! g ! n ! d ! c);
_ => raw.s ! g ! n ! d ! c
};
lock_A = <>
};
regA' : Str -> Str -> A =
\root,pat ->
let { kabIr = mkWord pat root
} in {
s = adj kabIr ;
lock_A = <>
};
--takes a root string only
clrA : Str -> A =
\root ->
let { eaHmar = mkWord "أَفعَل" root;
HamrA' = mkWord "فَعلاء" root;
Humr = mkWord "فُعل" root
} in {
s = clr eaHmar HamrA' Humr;
lock_A = <>
};
--lexical paradigms for verbs
v1 : Str -> Vowel -> Vowel -> V =
\rootStr,vPerf,vImpf ->
let { raw = v1' rootStr vPerf vImpf } in
{ s = \\vf =>
case rootStr of {
_ + "؟" + _ => rectifyHmz(raw.s ! vf);
_ => raw.s ! vf
};
lock_V = <>
} ;
v1' : Str -> Vowel -> Vowel -> Verb =
\rootStr,vPerf,vImpf ->
let { root = mkRoot3 rootStr ;
l = dp 2 rootStr } in --last rootStr
case <l, root.c> of {
<"ّ",_> => v1geminate rootStr vPerf vImpf ;
<"و"|"ي",_> => v1defective root vImpf ;
<_,"و"|"ي"> => v1hollow root vImpf ;
_ => v1sound root vPerf vImpf
};
--Verb Form II : faccala
-- Prepositions are used in many-argument functions for rection.
v2 : Str -> V =
\rootStr ->
let {
root = mkRoot3 rootStr
} in {
s =
case root.l of {
"و"|"ي" => (v2defective root).s;
_ => (v2sound root).s
};
lock_V = <>
};
--Verb Form III : fAcala
v3 : Str -> V =
\rootStr ->
let {
tbc = mkRoot3 rootStr ;
} in {
s = (v3sound tbc).s ;
lock_V = <>
};
--Verb Form IV : >afcala
v4 : Str -> V =
\rootStr ->
let {
root = mkRoot3 rootStr
} in {
s =
case root.l of {
"و"|"ي" => (v4defective root).s;
_ => (v4sound root).s
};
lock_V = <>
};
--Verb Form V : tafaccala
v5 : Str -> V =
\rootStr ->
let { raw = v5' rootStr } in
{ s = \\vf =>
case rootStr of {
_ + "؟" + _ => rectifyHmz(raw.s ! vf);
_ => raw.s ! vf
};
lock_V = <>
};
v5' : Str -> V =
\rootStr ->
let {
nfs = mkRoot3 rootStr ;
} in {
s = (v5sound nfs).s ; lock_V = <>
};
--Verb Form VI : tafaacala
v6 : Str -> V =
\rootStr ->
let {
fqm = mkRoot3 rootStr ;
} in {
s = (v6sound fqm).s ;
lock_V = <>
};
--Verb Form VIII <iftacala
v8 : Str -> V =
\rootStr ->
let {
rbT = mkRoot3 rootStr ;
} in {
s = (v8sound rbT).s ;
lock_V = <>
};
---- Prepositions are used in many-argument functions for rection.
--
Preposition : Type ;
--2 Nouns
-- Use the function $mkPreposition$ or see the section on prepositions below to
-- form other prepositions.
--
--This is used for loan words or anything that has untreated irregularities
--in the interdigitization process of its words
mkN : NTable -> Gender -> Species -> N ;
--Takes a root string, a singular pattern string, a broken plural
--pattern string, a gender, and species. Gives a noun.
brkN : Str -> Str -> Str -> Gender -> Species -> N ;
--Takes a root string, a singular pattern string, a gender,
--and species. Gives a noun whose plural is sound feminine.
sdfN : Str -> Str -> Gender -> Species -> N ;
--takes a root string, a singular pattern string, a gender,
--and species. Gives a noun whose plural is sound masculine
sdmN : Str -> Str -> Gender -> Species -> N ;
--3 Relational nouns
--
-- Relational nouns ("دَُغهتر ْف خ") need a preposition.
mkN2 : N -> Preposition -> N2 ;
-- Three-place relational nouns ("تهي عْنّعتِْن فرْم خ تْ ي") need two prepositions.
mkN3 : N -> Preposition -> Preposition -> N3 ;
--2 Adjectives
--Takes a root string and a pattern string
sndA : Str -> Str -> A ;
--Takes a root string only
clrA : Str -> A ;
----3 Relational common noun phrases
----
---- In some cases, you may want to make a complex $CN$ into a
---- relational noun (e.g. "تهي ْلد تْون هَلّ ْف").
--
-- cnN2 : CN -> Preposition -> N2 ;
-- cnN3 : CN -> Preposition -> Preposition -> N3 ;
--
--
--3 Proper names and noun phrases
--
-- Proper names, with a regular genitive, are formed as follows
mkPN : Str -> Gender -> PN ;
---- Sometimes you can reuse a common noun as a proper name, e.g. "َنك".
--
-- nounPN : N -> PN ;
--
---- To form a noun phrase that can also be plural and have an irregular
---- genitive, you can use the worst-case function.
--
-- mkNP : Str -> Str -> Number -> Gender -> NP ;
--
----2 Adjectives
--
--3 Two-place adjectives
--
-- Two-place adjectives need a preposition for their second argument.
mkA2 : A -> Preposition -> A2 ;
---- Comparison adjectives may two more forms.
--
-- ADeg : Type ;
--
-- mkADeg : (good,better,best,well : Str) -> ADeg ;
--
---- The regular pattern recognizes two common variations:
---- "ي" ("رُدي" - "رُدر" - "رُدست") and
---- "ي" ("هَةّي هَةِّر هَةِّست هَةِّلي")
--
-- regADeg : Str -> ADeg ; -- long, longer, longest
--
---- However, the duplication of the final consonant is nor predicted,
---- but a separate pattern is used:
--
-- duplADeg : Str -> ADeg ; -- fat, fatter, fattest
--
---- If comparison is formed by "مْري، "most", as in general for
---- long adjective, the following pattern is used:
--
-- compoundADeg : A -> ADeg ; -- -/more/most ridiculous
--
---- From a given $ADeg$, it is possible to get back to $A$.
--
-- adegA : ADeg -> A ;
--
--
--2 Adverbs
-- Adverbs are not inflected. Most lexical ones have position
@@ -328,26 +95,45 @@ resource ParadigmsAra = open
-- build $PP$s in the resource API, just requires a string.
mkPreposition : Str -> Preposition ;
mkPrep : Str -> Prep ;
-- (These two functions are synonyms.)
--2 Verbs
--
----3 Verbs with a particle.
----
---- The particle, such as in "سوِتعه ْن", is given as a string.
--
-- partV : V -> Str -> V ;
--
----3 Reflexive verbs
----
---- By default, verbs are not reflexive; this function makes them that.
--
-- reflV : V -> V ;
--
----3 Two-place verbs
--
--The verb in the imperfect tense gives the most information
regV : Str -> V ;
--Verb Form I : fa`ala, fa`ila, fa`ula
v1 : Str -> Vowel -> Vowel -> V ;
--Verb Form II : fa``ala
v2 : Str -> V ;
--Verb Form III : faa`ala
v3 : Str -> V ;
--Verb Form IV : 'af`ala
v4 : Str -> V ;
--Verb Form V : tafa``ala
v5 : Str -> V ;
--Verb Form VI : tafaa`ala
v6 : Str -> V ;
--Verb Form VIII 'ifta`ala
v8 : Str -> V ;
--3 Two-place verbs
-- Two-place verbs need a preposition, except the special case with direct object.
-- (transitive verbs). Notice that a particle comes from the $V$.
@@ -356,7 +142,7 @@ resource ParadigmsAra = open
dirV2 : V -> V2 ;
--3 Three-place verbs
--
-- Three-place (ditransitive) verbs need two prepositions, of which
-- the first one or both can be absent.
@@ -392,113 +178,231 @@ resource ParadigmsAra = open
V0, V2S, V2V, V2A, V2Q : 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 = MorphoAra.Gender ;
-- Number = MorphoAra.Number ;
-- Case = MorphoAra.Case ;
-- human = Masc ;
-- nonhuman = Neutr ;
-- masculine = Masc ;
-- feminine = Fem ;
-- singular = Sg ;
-- plural = Pl ;
-- nominative = Nom ;
-- genitive = Gen ;
--
--2 Definitions of paradigms
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
--.
regV = \word ->
case word of {
"يَ" + f@_ + c@_ + "ُ" + l@_ => v1 (f+c+l) a u ;
"يَ" + f@_ + c@_ + "ِ" + l@_ => v1 (f+c+l) a i ;
"يَ" + f@_ + c@_ + "َ" + l@_ => v1 (f+c+l) a a ;
f@_ + "َ" + c@_ + "ِ" + l@_ => v1 (f+c+l) i a
};
v1 = \rootStr,vPerf,vImpf ->
let { raw = v1' rootStr vPerf vImpf } in
{ s = \\vf =>
case rootStr of {
_ + "؟" + _ => rectifyHmz(raw.s ! vf);
_ => raw.s ! vf
};
lock_V = <>
} ;
v1' : Str -> Vowel -> Vowel -> Verb =
\rootStr,vPerf,vImpf ->
let { root = mkRoot3 rootStr ;
l = dp 2 rootStr } in --last rootStr
case <l, root.c> of {
<"ّ",_> => v1geminate rootStr vPerf vImpf ;
<"و"|"ي",_> => v1defective root vImpf ;
<_,"و"|"ي"> => v1hollow root vImpf ;
_ => v1sound root vPerf vImpf
};
v2 =
\rootStr ->
let {
root = mkRoot3 rootStr
} in {
s =
case root.l of {
"و"|"ي" => (v2defective root).s;
_ => (v2sound root).s
};
lock_V = <>
};
v3 =
\rootStr ->
let {
tbc = mkRoot3 rootStr ;
} in {
s = (v3sound tbc).s ;
lock_V = <>
};
v4 =
\rootStr ->
let {
root = mkRoot3 rootStr
} in {
s =
case root.l of {
"و"|"ي" => (v4defective root).s;
_ => (v4sound root).s
};
lock_V = <>
};
v5 =
\rootStr ->
let { raw = v5' rootStr } in
{ s = \\vf =>
case rootStr of {
_ + "؟" + _ => rectifyHmz(raw.s ! vf);
_ => raw.s ! vf
};
lock_V = <>
};
v5' : Str -> V =
\rootStr ->
let {
nfs = mkRoot3 rootStr ;
} in {
s = (v5sound nfs).s ; lock_V = <>
};
v6 =
\rootStr ->
let {
fqm = mkRoot3 rootStr ;
} in {
s = (v6sound fqm).s ;
lock_V = <>
};
v8 =
\rootStr ->
let {
rbT = mkRoot3 rootStr ;
} in {
s = (v8sound rbT).s ;
lock_V = <>
};
Preposition = Str ;
mkN nsc gen spec =
{ s = nsc;
g = gen;
h = spec;
lock_N = <>
};
brkN' : Str -> Str -> Str -> Gender -> Species -> N =
\root,sg,pl,gen,spec ->
let { kitAb = mkWord sg root;
kutub = mkWord pl root
} in mkN (reg kitAb kutub) gen spec;
brkN root sg pl gen spec =
let { raw = brkN' root sg pl gen spec} in
{ s = \\n,d,c =>
case root of {
_ + "؟" + _ => rectifyHmz(raw.s ! n ! d ! c);
_ => raw.s ! n ! d ! c
};
g = gen;
h = spec ; lock_N = <>
};
sdfN =
\root,sg,gen,spec ->
let { kalima = mkWord sg root;
} in mkN (sndf kalima) gen spec;
sdmN =
\root,sg,gen,spec ->
let { mucallim = mkWord sg root;
} in mkN (sndm mucallim) gen spec;
mkN2 = \n,p -> n ** {lock_N2 = <> ; c2 = p} ;
-- regN2 n = mkN2 (regN n) (mkPreposition "ْف") ;
mkN3 = \n,p,q -> n ** {lock_N3 = <> ; c2 = p ; c3 = q} ;
-- cnN2 = \n,p -> n ** {lock_N2 = <> ; c2 = p} ;
-- cnN3 = \n,p,q -> n ** {lock_N3 = <> ; c2 = p ; c3 = q} ;
--
-- mkPN n g = nameReg n g ** {lock_PN = <>} ;
-- nounPN n = {s = n.s ! singular ; g = n.g ; lock_PN = <>} ;
mkNP : (_,_,_ : Str) -> PerGenNum -> NP = \ana,nI,I,pgn ->
{ s =
table {
Nom => ana;
Acc => nI;
Gen => I
};
a = {pgn = pgn; isPron = True };
lock_NP = <>
};
-- mkNP x y n g = {s = table {Gen => x ; _ => y} ; a = agrP3 n ;
-- lock_NP = <>} ;
--
mkQuant7 : (_,_,_,_,_,_,_ : Str) -> State -> Quant =
\hava,havihi,havAn,havayn,hAtAn,hAtayn,hA'ulA,det ->
{ s = \\n,s,g,c =>
case <s,g,c,n> of {
<_,Masc,_,Sg> => hava;
<_,Fem,_,Sg> => havihi;
<_,Masc,Nom,Dl>=> havAn;
<_,Masc,_,Dl> => havayn;
<_,Fem,Nom,Dl> => hAtAn;
<_,Fem,_,Dl> => hAtayn;
<Hum,_,_,Pl> => hA'ulA;
_ => havihi
};
d = Def;
lock_Quant = <>
};
mkQuant3 : (_,_,_ : Str) -> State -> Quant =
\dalika,tilka,ula'ika,det ->
{ s = \\n,s,g,c =>
case <s,g,c,n> of {
<_,Masc,_,Sg> => dalika;
<_,Fem,_,Sg> => tilka;
<Hum,_,_,_> => ula'ika;
_ => tilka
};
d = Def;
lock_Quant = <>
};
-- mkA a b = mkAdjective a a a b ** {lock_A = <>} ;
-- regA a = regAdjective a ** {lock_A = <>} ;
--
mkNP : (_,_,_ : Str) -> PerGenNum -> NP = \ana,nI,I,pgn ->
{ s =
table {
Nom => ana;
Acc => nI;
Gen => I
};
a = {pgn = pgn; isPron = True };
lock_NP = <>
};
mkQuant7 : (_,_,_,_,_,_,_ : Str) -> State -> Quant =
\hava,havihi,havAn,havayn,hAtAn,hAtayn,hA'ulA,det ->
{ s = \\n,s,g,c =>
case <s,g,c,n> of {
<_,Masc,_,Sg> => hava;
<_,Fem,_,Sg> => havihi;
<_,Masc,Nom,Dl>=> havAn;
<_,Masc,_,Dl> => havayn;
<_,Fem,Nom,Dl> => hAtAn;
<_,Fem,_,Dl> => hAtayn;
<Hum,_,_,Pl> => hA'ulA;
_ => havihi
};
d = Def;
lock_Quant = <>
};
mkQuant3 : (_,_,_ : Str) -> State -> Quant =
\dalika,tilka,ula'ika,det ->
{ s = \\n,s,g,c =>
case <s,g,c,n> of {
<_,Masc,_,Sg> => dalika;
<_,Fem,_,Sg> => tilka;
<Hum,_,_,_> => ula'ika;
_ => tilka
};
d = Def;
lock_Quant = <>
};
sndA root pat =
let { raw = sndA' root pat } in
{ s = \\g,n,d,c =>
case root of {
_ + "؟" + _ => rectifyHmz(raw.s ! g ! n ! d ! c);
_ => raw.s ! g ! n ! d ! c
};
lock_A = <>
};
sndA' : Str -> Str -> A =
\root,pat ->
let { kabIr = mkWord pat root
} in {
s = adj kabIr ;
lock_A = <>
};
clrA root =
let { eaHmar = mkWord "أَفعَل" root;
HamrA' = mkWord "فَعلاء" root;
Humr = mkWord "فُعل" root
} in {
s = clr eaHmar HamrA' Humr;
lock_A = <>
};
mkA2 a p = a ** {c2 = p ; lock_A2 = <>} ;
--
-- ADeg = A ; ----
--
-- mkADeg a b c d = mkAdjective a b c d ** {lock_A = <>} ;
--
-- duplADeg fat =
-- mkADeg fat
-- (fat + last fat + "ر") (fat + last fat + "ست") (fat + "لي") ;
--
-- compoundADeg a =
-- let ad = (a.s ! AAdj Posit)
-- in mkADeg ad ("مْري" ++ ad) ("مْست" ++ ad) (a.s ! AAdv) ;
--
-- adegA a = a ;
--
mkAdv x = ss x ** {lock_Adv = <>} ;
mkAdV x = ss x ** {lock_AdV = <>} ;
mkAdA x = ss x ** {lock_AdA = <>} ;
mkPreposition p = p ;
-- mkPrep p = ss p ** {lock_Prep = <>} ;
--
-- mkV a b c d e = mkVerb a b c d e ** {s1 = [] ; lock_V = <>} ;
--
--
-- partV v p = verbPart v p ** {lock_V = <>} ;
-- reflV v = {s = v.s ; part = v.part ; lock_V = v.lock_V ; isRefl = True} ;
--
mkV2 v p = v ** {s = v.s ; c2 = p ; lock_V2 = <>} ;
dirV2 v = mkV2 v [] ;
@@ -507,10 +411,6 @@ resource ParadigmsAra = open
dirdirV3 v = dirV3 v [] ;
mkVS v = v ** {lock_VS = <>} ;
-- mkVV v = {
-- s = table {VVF vf => v.s ! vf ; _ => variants {}} ;
-- isAux = False ; lock_VV = <>
-- } ;
mkVQ v = v ** {lock_VQ = <>} ;
V0 : Type = V ;