summaryrefslogtreecommitdiff
path: root/next-lib/src/arabic/OrthoAra.gf
blob: 62ebc9b58bdf8fb1aa4a60d174daa80b4a67d325 (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
resource OrthoAra = open Prelude, Predef in {

flags coding=utf8 ;

  oper
    
    rectifyHmz: Str -> Str = \word ->
      case word of {
        l@(""|"ال") + "؟" + v@("َ"|"ُ") + tail => l + "أ" + v + tail;
        l@(""|"ال") + "؟" + v@("ِ") + tail => l + "إ" + v + tail;
        head + v1@("ِ"|"ُ"|"َ"|"ْ"|"ا"|"ي"|"و") + "؟" + v2@(""|"ُ"|"َ"|"ْ"|"ِ") => head + v1 + (tHmz v1) + v2;
        head + "؟" + tail => head + (bHmz (dp 2 head) (take 2 tail)) + tail; --last head , take 1 tail
        _           => word
      };
    
    --hamza at beginning of word (head)
    hHmz : Str -> Str = \d ->
      case d of {
        "ِ" => "إ";
	    _	 => "أ"
      };
    
    --hamza in middle of word (body)
    bHmz : Str -> Str -> Str = \d1,d2 ->
      case <d1,d2> of {
        <"ِ",_> | <_,"ِ"> => "ئ";
	    <"ُ",_> | <_,"ُ"> => "ؤ";
	    <"َ",_> | <_,"َ"> => "أ";
	    _				   => "ء"
      };
    
    --hamza carrier sequence
    tHmz : Str -> Str = \d ->
      case d of {
        "ِ" => "ئ";
	    "ُ" => "ؤ";
	    "َ" => "أ";
	    "ْ"|"ا"|"و"|"ي" => "ء"
      };
    
}