From 12ccc075d724f9985be488b162b243f46dff871a Mon Sep 17 00:00:00 2001
From: Sébastien Dailly <sebastien@chimrod.com>
Date: Wed, 1 Sep 2021 18:33:26 +0200
Subject: Made all tests pass

---
 src/lib/sounds/sounds.ml | 46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)

(limited to 'src/lib/sounds')

diff --git a/src/lib/sounds/sounds.ml b/src/lib/sounds/sounds.ml
index f2a9d86..9892ace 100644
--- a/src/lib/sounds/sounds.ml
+++ b/src/lib/sounds/sounds.ml
@@ -19,12 +19,21 @@ module type T = sig
       When nazalized, the voyel become [in] like in "ainsi" *)
   val i : t
 
+  (** This is the sound present with letter [ai].
+      It is the e like in "semaine".
+
+      When nazalized, the voyel become [in]
+
+
+  *)
+  val voyel_ai : t
+
   (** This is the sound ou like in "ouvrier"
       When nazalized, the voyel does not change *)
   val voyel_u : t
 
   (** This is the sound u like in "unis"
-      When nazalized, the voyel becom [un] like in "brun" *)
+      When nazalized, the voyel become [un] like in "brun" *)
   val voyel_y : t
 
   (** Create a diphtongue from a semi-voyel and a voyel *)
@@ -58,12 +67,15 @@ module type T = sig
   val is_voyel : t -> bool
   val is_nasal : t -> bool
 
+  val repr : t -> string
+
 end
 
 module T = struct
   type kind =
     | None
     | Voyel
+    | SemiVoyel
 
   type code =
     | None
@@ -74,6 +86,7 @@ module T = struct
     | Voyel_O
     | Voyel_U (* OU like in Ouvrir *)
     | Voyel_Y (* U like in Unique *)
+    | Voyel_AI
     | SemiVoyel_W
     | SemiVoyel_Y
     | Consonant_P
@@ -134,7 +147,7 @@ module Repr = struct
   and v = "v"
 
   and ch = "S"
-  and j = "j"
+  and j = "Z"
 
   and s = "s"
   and z = "z"
@@ -153,7 +166,9 @@ module S = struct
 
   include T
 
-  let is_voyel t = t.kind = Voyel
+  let is_voyel t =
+    t.kind = Voyel
+    || t.kind = SemiVoyel
   let is_nasal t = t.nasal
 
 
@@ -182,6 +197,12 @@ module S = struct
     ; repr = Repr.a
     }
 
+  let voyel_ai =
+    { voyel with
+      code = Voyel_AI
+    ; repr = "E"
+    }
+
   let e = function
     | `Closed -> { voyel with repr = "e" ; code = Voyel_E }
     | `Opened -> { voyel with repr = "E" ; code = Voyel_E }
@@ -309,22 +330,25 @@ module S = struct
 
   let semi_voyel_w =
     { none with
-      repr = Repr.semi_voyel_w
+      kind = SemiVoyel
+    ; repr = Repr.semi_voyel_w
     ; code = SemiVoyel_W}
 
   let semi_voyel_y =
     { none with
-      repr = Repr.semi_voyel_y
+      kind = SemiVoyel
+    ; repr = Repr.semi_voyel_y
     ; code = SemiVoyel_Y}
 
   let nasal t =
 
     match t.code with
-    | Voyel_E -> Some { t with repr = Repr.a_nasal ; nasal = true }
-    | Voyel_A -> Some { t with repr = Repr.a_nasal ; nasal = true }
-    | Voyel_O -> Some { t with repr = Repr.o_nasal ; nasal = true }
-    | Voyel_I -> Some { t with repr = Repr.i_nasal ; nasal = true }
-    | Voyel_Y -> Some { t with repr = Repr.y_nasal ; nasal = true }
+    | Voyel_E -> Some  { t with repr = Repr.a_nasal ; nasal = true }
+    | Voyel_A -> Some  { t with repr = Repr.a_nasal ; nasal = true }
+    | Voyel_AI -> Some { t with repr = Repr.i_nasal ; nasal = true }
+    | Voyel_O -> Some  { t with repr = Repr.o_nasal ; nasal = true }
+    | Voyel_I -> Some  { t with repr = Repr.i_nasal ; nasal = true }
+    | Voyel_Y -> Some  { t with repr = Repr.y_nasal ; nasal = true }
     | Diphtonge (s1, s2) ->
       begin match s1.code, s2.code with
         | (SemiVoyel_W, Voyel_I) ->
@@ -361,6 +385,8 @@ module S = struct
 
       | Voyel_A, false -> Repr.a
       | Voyel_A, true  -> Repr.a_nasal
+      | Voyel_AI, false -> "E"
+      | Voyel_AI, true  -> Repr.i_nasal
       | Voyel_E, _ -> ""
       | Voyel_I, false -> Repr.i
       | Voyel_I, true -> Repr.i_nasal
-- 
cgit v1.2.3