diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-09-04 10:43:01 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2021-09-04 10:43:01 +0200 |
commit | 0ba049daed6e4b5d01f83d236f3178747bf849cb (patch) | |
tree | 72eeedcaa5fbe9736e2842879d62d0bf412a149f /src/lib/modifiers | |
parent | 0b2e63791a073000b70b4463db5d8bce88ab4d23 (diff) |
Transform the letter e into eu or E
Diffstat (limited to 'src/lib/modifiers')
-rw-r--r-- | src/lib/modifiers/e.ml | 15 | ||||
-rw-r--r-- | src/lib/modifiers/modifiers.ml | 1 | ||||
-rw-r--r-- | src/lib/modifiers/mute.ml | 10 | ||||
-rw-r--r-- | src/lib/modifiers/nasal.ml | 19 | ||||
-rw-r--r-- | src/lib/modifiers/sig.ml | 6 | ||||
-rw-r--r-- | src/lib/modifiers/vocalize.ml | 18 |
6 files changed, 40 insertions, 29 deletions
diff --git a/src/lib/modifiers/e.ml b/src/lib/modifiers/e.ml new file mode 100644 index 0000000..8fd65bf --- /dev/null +++ b/src/lib/modifiers/e.ml @@ -0,0 +1,15 @@ +(** Transform the e into eu or E *) +let process + : 'a Sig.modifier + = fun init -> + let ((v2, c) , ending) = init in + + match ending with + | None when v2 = Sounds.schwa -> + (* If there is no more consononant in the syllabe, change the e + into eu, like in sera *) + ((Sounds.eu `Closed, c) , ending) + | Some _ when v2 = Sounds.schwa -> + (* If there is an ending consonant, change the e into E like essai *) + ((Sounds.e `Opened, c) , ending) + | _ -> init diff --git a/src/lib/modifiers/modifiers.ml b/src/lib/modifiers/modifiers.ml index 89e9485..3a9ecd6 100644 --- a/src/lib/modifiers/modifiers.ml +++ b/src/lib/modifiers/modifiers.ml @@ -3,3 +3,4 @@ module Sig = Sig let nasal = Nasal.process let vocalize_s = Vocalize.process let mute_consonant = Mute.process +let e = E.process diff --git a/src/lib/modifiers/mute.ml b/src/lib/modifiers/mute.ml index 331ed1a..e23965f 100644 --- a/src/lib/modifiers/mute.ml +++ b/src/lib/modifiers/mute.ml @@ -1,18 +1,16 @@ open StdLabels -module T = Sounds - (** Mute the last consonant if there is no voyel in the syllabus. This modifier is only applied in the first step, and not repeated anymore. *)let process : 'a Sig.modifier = fun init -> - let (((v1, v2), c) , ending) = init in - let is_voyel = T.is_voyel v1 && T.is_voyel v2 in + let ((v, c) , ending) = init in + let is_voyel = Sounds.is_voyel v in match is_voyel, c with | false, Some c -> - let c = { c with Sig.opening = List.map ~f:T.muted c.Sig.opening } in - (((v1, v2), Some c) , ending) + let c = { c with Sig.opening = List.map ~f:Sounds.muted c.Sig.opening } in + ((v, Some c) , ending) | _ -> init diff --git a/src/lib/modifiers/nasal.ml b/src/lib/modifiers/nasal.ml index 57a3235..cc29efc 100644 --- a/src/lib/modifiers/nasal.ml +++ b/src/lib/modifiers/nasal.ml @@ -1,14 +1,13 @@ -module T = Sounds (* Remove the ending consonant, and transform the voyel into the nasal form *) let transform : Sounds.t Sig.consonants option -> Sounds.t Sig.t -> Sounds.t Sig.t = fun c init -> - let (((v1, v2), _) , _) = init in + let ((v, _) , _) = init in - begin match T.nasal v1, T.nasal v2 with - | Some t1, Some t2 -> - ( ( (t1, t2) + begin match Sounds.nasal v with + | Some t -> + ( ( t , c ) , None ) | _ -> init @@ -22,14 +21,14 @@ let transform let process : 'a Sig.modifier = fun init -> - let (((v1, v2), c) , ending) = init in + let ((v, c) , ending) = init in let ending = Option.bind ending (fun x -> x) in let opening = Option.map (fun v -> v.Sig.opening) c in - let is_voyel = T.is_voyel v1 && T.is_voyel v2 in + let is_voyel = Sounds.is_voyel v in match ending, is_voyel, opening with - | Some ending, _, _ when T.is_nasal ending -> + | Some ending, _, _ when Sounds.is_nasal ending -> transform c init - | None, false, Some (opening::tl) when T.is_nasal opening -> + | None, false, Some (opening::tl) when Sounds.is_nasal opening -> (* If there is no voyel here, transform the opening consonant as an ending consonant for the next syllabus *) let c = Option.map @@ -38,7 +37,7 @@ let process Sig.opening = tl ; Sig.ending = (Some (Some opening)) }) c in - ( ( (v1, v2) + ( ( v , c ) , None ) | _ -> diff --git a/src/lib/modifiers/sig.ml b/src/lib/modifiers/sig.ml index bcc4af2..5f82620 100644 --- a/src/lib/modifiers/sig.ml +++ b/src/lib/modifiers/sig.ml @@ -1,12 +1,12 @@ -type 'a voyel = ('a * 'a) +type voyel = Sounds.t type 'a consonants = { ending : 'a option option ; opening : 'a list ; following : 'a option } -type 'a group = 'a voyel * 'a consonants option +type 'a group = voyel * 'a consonants option type 'a t = 'a group * 'a option option -type 'a modifier = 'a t -> 'a t +type 'a modifier = Sounds.t t -> Sounds.t t diff --git a/src/lib/modifiers/vocalize.ml b/src/lib/modifiers/vocalize.ml index 1014642..068279d 100644 --- a/src/lib/modifiers/vocalize.ml +++ b/src/lib/modifiers/vocalize.ml @@ -1,25 +1,23 @@ -module T = Sounds - (** 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 init -> - let (((v1, v2), c) , ending) = init in + let ((v, 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 + let is_voyel = Sounds.is_voyel v 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-> + | true, hd::[], None when hd = Sounds.sz -> + let c = Some { op with opening = [Sounds.z] } in + ((v, c) , ending) + | true, hd::n::[], None when hd = Sounds.sz && Sounds.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) + let c = Some { op with opening = [Sounds.z; n] } in + ((v, c) , ending) | _ -> init |