summaryrefslogtreecommitdiff
path: root/src/lib/modifiers/vocalize.ml
blob: dab36edd8d1f71cf984ed6c472d62e4b77faffd9 (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
(** Transform the S into Z if the S is the opening consonant and
    there is no ending consonant before *)
let process
  : 'a Sig.modifier
  = fun (type el) m init ->
    let module T = (val m:Sounds.T with type t = el) in
    let (((v1, v2), c) , ending) = init in

    match c with
    | None -> init
    | Some op ->
      (* The voyel may be none in case of ending word. In such case, we shall
         not transform the S into Z *)
      let is_voyel = T.is_voyel v1 && T.is_voyel v2 in

      match is_voyel, op.Sig.opening, op.Sig.ending with
      | true, hd::[], None when hd = T.sz ->
        let c = Some { op with opening = [T.z] } in
        (((v1, v2), c) , ending)
      | true, hd::n::[], None when hd = T.sz && T.is_voyel n->
        (* The s is followed by a semi-voyel *)
        let c = Some { op with opening = [T.z; n] } in
        (((v1, v2), c) , ending)
      | _ -> init