summaryrefslogtreecommitdiff
path: root/gf-book/examples/chapter9/hebrew/ResHeb.gf
blob: 87387a3dc4e84a1a6f0e8c0c3394992fad0ab8f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
--# -path=alltenses

-- (c) 2011 Dana Dannells
-- Licensed under LGPL
-- Compiled with GF version 3.2

resource ResHeb =  open PatternsHeb, Prelude, Predef in {

  flags coding=utf8 ;

param

 Number = Sg | Pl | Dl ;
 Gender = Masc | Fem ;
 Species = Def | Indef ;
 Case = Nom | Acc | Dat ;
 Agr = Ag Gender Number Person;
 Person = Per1 | Per2 | Per3 ;
 Voice = Active | Passive | Reflexive ; 
 VPerNumGen = Vp1Sg | Vp1Pl | Vp2Sg Gender | Vp2Pl Gender | Vp3Sg Gender | Vp3Pl Gender ;
 Tense = Perf | Part | Imperf ;


oper
 
 VP = {v : Verb ; obj : Str} ; -- obj value to deal with direct objects 
 NP = {s :  Case => {obj : Str} ; a : Agr ; isDef : Bool ; sp : Species };

-------------------------------------------------  
-- Auxiliaries
-- Pronouns modify nouns in a noun phrase, they agree 
-- in gender and number with the head noun.

 pronNP : (s,a,d : Str) -> Gender -> Number -> Person ->  NP =
 \s,a,d,g,n,p ->  { 
    s =  
       table {
            Nom => {obj = s}  ;
	    Acc => {obj = a}  ;
	    Dat => {obj = []}
        };
    isDef = False ;
    sp = Indef ; 
    a = Ag g n p 
  } ;

-------------------------------------------------  
-- Predication

  agrV : Verb -> Tense ->  Agr -> Str = \v,t,a -> case a of {
    Ag g n p => v.s ! t ! (chooseForm g n p)  
  } ;
   
  chooseForm : Gender -> Number -> Person -> VPerNumGen = \g,n,p->
  case <g,n,p> of {
  <_,Sg,Per1> => Vp1Sg;
  <_,Pl,Per1> =>  Vp1Pl; 
  <_,Sg,Per2> => Vp2Sg g ; 
  <_,Pl,Per2> => Vp2Pl g ; 
  <_,Sg,Per3> => Vp3Sg g ; 
  <_,Pl,Per3> => Vp3Pl g ;
    _         => Vp3Sg Masc
  };
   
-------------------------------------------------  
-- Roots and patterns for verbs 

oper    
 
    Pattern : Type = {C1, C1C2, C2C3, C3 : Str}; 
    Root    : Type = {C1,C2,C3 : Str};	   -- most verb roots consist of three consonants
    Root4   : Type = Root ** {C4 : Str};   -- for verb roots with four consonants


-------------------------------------------------  
-- Morphology

oper    
   
   Noun : Type = {s : Number => Species => Str ; g : Gender} ; 
   Adj  : Type = {s : Number => Species => Gender => Str} ; 
   Verb : Type = {s : Tense => VPerNumGen  => Str } ;
   Verb2 : Type = Verb ** {c : Case} ; 

-------------------------------------------------  
-- Nouns  
-- Nouns have different endings, 
-- some are also duals: his- anashim, bait- batim, bat-banot. 

oper    

mkNoun : (bait,batim,batimD : Str) -> Gender -> Noun = \bait,batim,batimD,g -> {
	s = table {
		Sg => table{Indef => bait ; Def => defH bait};
		Pl => table{Indef => batim ; Def => defH batim} ;
		Dl => table{Indef => batimD ; Def => defH batimD}
		};
	g=g ;
  }; 

-- For some nouns it is not possible to infer the gender from the pefix, 
-- depending on the gender, a noun can either end with yM or wt. 

regNoun2 :  Str -> Gender -> Noun = \root,g -> 
	case root of {
	heret + c@? => table {
		Masc => mkNoun root (heret + replaceLastLet (c) + "yM" ) ("")  g;
		Fem => mkNoun root (heret + replaceLastLet (c) + "wt") ("") g
 		  } ! g
  } ;
		
-- For regular nouns, it is possible to infer the gender from the pefix.

regNoun : Str -> Noun = 
	\root -> case root of {
        malc + "h" => mkNoun root (malc + "wt") ("") Fem ;
	mecon + "yt" => mkNoun root (mecon + "ywt") ("") Fem ; --  (it -> iyot)	
	khan + "wt" => mkNoun root (khan + "ywt") ("") Fem; -- (ut -> uyot)	
	tsalakh + "t" => mkNoun root (tsalakh + "wt") ("") Fem ; --  (at -> ot)
	_ => mkNoun root (root + "yM") ("")  Masc 
  } ;

mkN = overload {
    mkN : (root: Str) -> Noun = regNoun ;
    mkN : (kaf : Str) -> Gender-> Noun = regNoun2 ; 
    mkN : (bait, batim : Str) -> Gender -> Noun = \bait,batim -> mkNoun bait batim ""; 
    mkN : (regel,  raglayim,  raglaim : Str) -> Gender -> Noun = mkNoun ; 
  } ;
	
replaceLastLet :  Str -> Str = \c -> 
	 case c of {"P" => "p" ; "M" => "m" ; "N" => "n" ; "Z." => "Z" ; "K" => "k"; _ => c} ;
 
-------------------------------------------------  
-- Adjectives
-- Adjectives are formed either linearly, 
-- by adding a suffix without affecting the stem 
-- or discontinuously, by adding feminine or plural marker 
-- that requires a shift of stress in the word and certain 
-- vowel deletions and modifications.    

oper

regA : Str ->  Adj = \root 
	-> case root of { kaTan + c@? =>
	mkAdj root (kaTan + replaceLastLet (c) + "h") (kaTan +
	replaceLastLet (c) + "yM") (kaTan + replaceLastLet (c) + "wt") 
   };

regA2 : Str ->  Adj = \bwleT
	-> mkAdj bwleT  ( bwleT + "t") ( bwleT + "yM" ) (bwleT + "wt" ); 
	
mkAdj : (_,_,_,_ : Str) -> Adj = \tov,tova,tovim,tovot -> {
    s = table {
      	Sg => table { 
		Indef => table { Masc => tov ; Fem => tova } ; 
		Def => table { Masc => defH tov ; Fem => defH tova }  
            	} ; 
        _ => table { 
		Indef => table {Masc => tovim ; Fem  => tovot } ; 
		Def => table { Masc => defH tovim ; Fem  => defH tovot }
               }
         }
   };


-------------------------------------------------  
-- Determination

defH : Str -> Str = \cn ->
	case cn of {_ => "h" + cn};	


-------------------------------------------------  
-- Verbs 
-- The way of forming verbs follows the traditional 
-- Hebrew pattern group classification, called Binyanim. 
-- Each pattern has a three consonant slot structure with special
-- inflectional characteristics. 
-- Verbs are formed by a [root + pattern] combination.  
    
oper

dirV2: Verb -> Verb2 =\v -> 
       {
       s = v.s ;
       c = Acc	
       }; 
       

mkVPaal : Str -> Verb = \v ->
  let root = getRoot v
    in {s = table { 
   Perf => table {        
      Vp1Sg       => appPattern root C1aC2aC3ti ;
      Vp1Pl       => appPattern root C1aC2aC3nu ;
	
      Vp2Sg Masc => appPattern root C1aC2aC3ta ;
      Vp2Sg Fem  => appPattern root C1aC2aC3t ;
      Vp2Pl Masc => appPattern root C1aC2aC3tem ;
      Vp2Pl Fem  => appPattern root C1aC2aC3ten ;
      
      Vp3Sg Masc => appPattern root C1aC2aC3 ;
      Vp3Sg Fem  => appPattern root C1aC2aC3a ;
      Vp3Pl Masc => appPattern root C1aC2aC3u ;
      Vp3Pl Fem  => appPattern root C1aC2aC3u 
	} ;

   Part => table {           
      Vp1Sg       => appPattern root C1oC2eC3 ;
      Vp1Pl       => appPattern root C1oC2C3im ;
	
      Vp2Sg Masc => appPattern root C1oC2eC3 ;
      Vp2Sg Fem  => appPattern root C1oC2eC3et ;
      Vp2Pl Masc => appPattern root C1oC2C3im ;
      Vp2Pl Fem  => appPattern root C1oC2C3ot ;
      
      Vp3Sg Masc => appPattern root C1oC2eC3;
      Vp3Sg Fem  => appPattern root C1oC2eC3et ;
      Vp3Pl Masc => appPattern root C1oC2C3im ;
      Vp3Pl Fem  => appPattern root C1oC2C3ot
	} ;
 
   Imperf => table {        
      Vp1Sg       => appPattern root eC1C2oC3 ;
      Vp1Pl       => appPattern root niC1C2oC3 ;
	
      Vp2Sg Masc => appPattern root tiC1C2oC3 ;
      Vp2Sg Fem  => appPattern root tiC1C2eC3i ;
      Vp2Pl Masc => appPattern root tiC1C2eC3o ;
      Vp2Pl Fem  => appPattern root tiC1C2eC3o ;
      
      Vp3Sg Masc => appPattern root yiC1C2oC3 ;
      Vp3Sg Fem  => appPattern root tiC1C2oC3 ;
      Vp3Pl Masc => appPattern root yiC1C2eC3u ;
      Vp3Pl Fem  => appPattern root yiC1C2eC3u  
	} 
      }
  };
 

mkVHifhil : Str -> Verb = \v ->
  let root = getRoot v
    in {s = table { 
   Perf => table {        
      Vp1Sg       => appPattern root hiC1C2aC3ti ;
      Vp1Pl       => appPattern root hiC1C2aC3nu ;
	
      Vp2Sg Masc => appPattern root hiC1C2aC3ta ;
      Vp2Sg Fem  => appPattern root hiC1C2aC3t ;
      Vp2Pl Masc => appPattern root hiC1C2aC3tem ;
      Vp2Pl Fem  => appPattern root hiC1C2aC3ten ;
      
      Vp3Sg Masc => appPattern root hiC1C2iC3 ;
      Vp3Sg Fem  => appPattern root hiC1C2iC3a ;
      Vp3Pl Masc => appPattern root hiC1C2iC3u ;
      Vp3Pl Fem  => appPattern root hiC1C2iC3u 
	} ;

   Part => table {           
      Vp1Sg       => appPattern root C1oC2eC3 ;
      Vp1Pl       => appPattern root C1oC2C3im ;
	
      Vp2Sg Masc => appPattern root C1oC2eC3 ;
      Vp2Sg Fem  => appPattern root C1oC2eC3et ;
      Vp2Pl Masc => appPattern root C1oC2C3im ;
      Vp2Pl Fem  => appPattern root C1oC2C3ot ;
      
      Vp3Sg Masc => appPattern root C1oC2eC3;
      Vp3Sg Fem  => appPattern root C1oC2eC3et ;
      Vp3Pl Masc => appPattern root C1oC2C3im ;
      Vp3Pl Fem  => appPattern root C1oC2C3ot
	};
   Imperf => table {        
      Vp1Sg       => appPattern root eC1C2oC3 ;
      Vp1Pl       => appPattern root niC1C2oC3 ;
	
      Vp2Sg Masc => appPattern root tiC1C2oC3 ;
      Vp2Sg Fem  => appPattern root tiC1C2eC3i ;
      Vp2Pl Masc => appPattern root tiC1C2eC3o ;
      Vp2Pl Fem  => appPattern root tiC1C2eC3o ;
      
      Vp3Sg Masc => appPattern root yiC1C2oC3 ;
      Vp3Sg Fem  => appPattern root tiC1C2oC3 ;
      Vp3Pl Masc => appPattern root yiC1C2eC3u ;
      Vp3Pl Fem  => appPattern root yiC1C2eC3u  
	} 	
     }
   } ;

mkVHifhil2 : Str -> Verb = \v ->
  let root = getRoot v  
     in {s = table { 
   Perf => table {        
      Vp1Sg       => appPattern2 root hiC1C2aC3ti ;
      Vp1Pl       => appPattern2 root hiC1C2aC3nu ;
	
      Vp2Sg Masc => appPattern2 root hiC1C2aC3ta ;
      Vp2Sg Fem  => appPattern2 root hiC1C2aC3t ;
      Vp2Pl Masc => appPattern2 root hiC1C2aC3tem ;
      Vp2Pl Fem  => appPattern2 root hiC1C2aC3ten ;
      
      Vp3Sg Masc => appPattern2 root hiC1C2iC3 ;
      Vp3Sg Fem  => appPattern2 root hiC1C2iC3a ;
      Vp3Pl Masc => appPattern2 root hiC1C2iC3u ;
      Vp3Pl Fem  => appPattern2 root hiC1C2iC3u 
	} ;

   Part => table {           
      Vp1Sg       => appPattern2 root C1oC2eC3 ;
      Vp1Pl       => appPattern2 root C1oC2C3im ;
	
      Vp2Sg Masc => appPattern2 root C1oC2eC3 ;
      Vp2Sg Fem  => appPattern2 root C1oC2eC3et ;
      Vp2Pl Masc => appPattern2 root C1oC2C3im ;
      Vp2Pl Fem  => appPattern2 root C1oC2C3ot ;
      
      Vp3Sg Masc => appPattern2 root C1oC2eC3;
      Vp3Sg Fem  => appPattern2 root C1oC2eC3et ;
      Vp3Pl Masc => appPattern2 root C1oC2C3im ;
      Vp3Pl Fem  => appPattern2 root C1oC2C3ot
	} ;
   Imperf => table {        
      Vp1Sg       => appPattern2 root eC1C2oC3 ;
      Vp1Pl       => appPattern2 root niC1C2oC3 ;
	
      Vp2Sg Masc => appPattern2 root tiC1C2oC3 ;
      Vp2Sg Fem  => appPattern2 root tiC1C2eC3i ;
      Vp2Pl Masc => appPattern2 root tiC1C2eC3o ;
      Vp2Pl Fem  => appPattern2 root tiC1C2eC3o ;
      
      Vp3Sg Masc => appPattern2 root yiC1C2oC3 ;
      Vp3Sg Fem  => appPattern2 root tiC1C2oC3 ;
      Vp3Pl Masc => appPattern2 root yiC1C2eC3u ;
      Vp3Pl Fem  => appPattern2 root yiC1C2eC3u  
	} 
     }
  };
 
  appPattern : Root -> Pattern -> Str = \r,p ->
    p.C1 + r.C1 + p.C1C2 + r.C2 + p.C2C3 + r.C3 + p.C3 ;

-- remove the first letter
  appPattern2 : Root -> Pattern -> Str = \r,p ->
    p.C1 + p.C1C2 + r.C2 + p.C2C3 + r.C3 + p.C3 ;

  getRoot : Str -> Root = \s -> case s of {
    C1@? + C2@? + C3 => {C1 = C1 ; C2 = C2 ; C3 = C3} ;
    _ => Predef.error ("cannot get root from" ++ s)
    } ;

}