summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-09-03 15:15:00 +0200
committerSébastien Dailly <sebastien@chimrod.com>2021-09-03 15:15:00 +0200
commit48dc04c3b9afe19207d15b873452129d9c2b3b4c (patch)
tree2c46df86808aa738a28ce95d5b62a58ffaf12459
parentad45e1b397ba995dc0222057a8dc1d0c38970c4f (diff)
Continued refactoring
-rw-r--r--src/lib/modifiers/mute.ml2
-rw-r--r--src/lib/modifiers/nasal.ml6
-rw-r--r--src/lib/modifiers/sig.ml2
-rw-r--r--src/lib/modifiers/vocalize.ml2
-rw-r--r--src/lib/parser.mly3
-rw-r--r--src/lib/process.ml4
-rw-r--r--src/lib/prononciation.mly3
-rw-r--r--src/lib/sounds/repr.ml56
-rw-r--r--src/lib/sounds/repr.mli45
-rw-r--r--src/lib/sounds/sig.ml71
-rw-r--r--src/lib/sounds/sounds.ml710
-rw-r--r--src/lib/sounds/sounds.mli70
-rw-r--r--src/test/test.ml5
13 files changed, 544 insertions, 435 deletions
diff --git a/src/lib/modifiers/mute.ml b/src/lib/modifiers/mute.ml
index 253df21..3597876 100644
--- a/src/lib/modifiers/mute.ml
+++ b/src/lib/modifiers/mute.ml
@@ -6,7 +6,7 @@ open StdLabels
*)let process
: 'a Sig.modifier
= fun (type el) m init ->
- let module T = (val m:Sounds.T with type t = el) in
+ let module T = (val m:Sounds.Sig.T with type t = el) in
let (((v1, v2), c) , ending) = init in
let is_voyel = T.is_voyel v1 && T.is_voyel v2 in
match is_voyel, c with
diff --git a/src/lib/modifiers/nasal.ml b/src/lib/modifiers/nasal.ml
index 8fdc60c..ec8ddb4 100644
--- a/src/lib/modifiers/nasal.ml
+++ b/src/lib/modifiers/nasal.ml
@@ -1,9 +1,9 @@
(* Remove the ending consonant, and transform the voyel into
the nasal form *)
let transform
- : (module Sounds.T with type t = 'a) -> 'a Sig.consonants option -> 'a Sig.t -> 'a Sig.t
+ : (module Sounds.Sig.T with type t = 'a) -> 'a Sig.consonants option -> 'a Sig.t -> 'a Sig.t
= fun (type el) m c init ->
- let module T = (val m:Sounds.T with type t = el) in
+ let module T = (val m:Sounds.Sig.T with type t = el) in
let (((v1, v2), _) , _) = init in
begin match T.nasal v1, T.nasal v2 with
@@ -22,7 +22,7 @@ let transform
let process
: 'a Sig.modifier
= fun (type el) m init ->
- let module T = (val m:Sounds.T with type t = el) in
+ let module T = (val m:Sounds.Sig.T with type t = el) in
let (((v1, v2), c) , ending) = init in
let ending = Option.bind ending (fun x -> x) in
let opening = Option.map (fun v -> v.Sig.opening) c in
diff --git a/src/lib/modifiers/sig.ml b/src/lib/modifiers/sig.ml
index 1485247..4cf605f 100644
--- a/src/lib/modifiers/sig.ml
+++ b/src/lib/modifiers/sig.ml
@@ -9,4 +9,4 @@ type 'a group = 'a voyel * 'a consonants option
type 'a t = 'a group * 'a option option
-type 'a modifier = (module Sounds.T with type t = 'a) -> 'a t -> 'a t
+type 'a modifier = (module Sounds.Sig.T with type t = 'a) -> 'a t -> 'a t
diff --git a/src/lib/modifiers/vocalize.ml b/src/lib/modifiers/vocalize.ml
index dab36ed..b390757 100644
--- a/src/lib/modifiers/vocalize.ml
+++ b/src/lib/modifiers/vocalize.ml
@@ -3,7 +3,7 @@
let process
: 'a Sig.modifier
= fun (type el) m init ->
- let module T = (val m:Sounds.T with type t = el) in
+ let module T = (val m:Sounds.Sig.T with type t = el) in
let (((v1, v2), c) , ending) = init in
match c with
diff --git a/src/lib/parser.mly b/src/lib/parser.mly
index d228e83..251f359 100644
--- a/src/lib/parser.mly
+++ b/src/lib/parser.mly
@@ -7,7 +7,7 @@ See [1] for the theory behind the analysis
*)
-%parameter<T:Sounds.T>
+%parameter<T:Sounds.Sig.T>
@@ -96,6 +96,7 @@ voyels:
ending_consonant:
| B { Some (T.b ) }
| T { None }
+ | K { Some (T.k)}
| liquid { Some $1 }
| nasal { Some $1 }
diff --git a/src/lib/process.ml b/src/lib/process.ml
index d0d1884..13a24a1 100644
--- a/src/lib/process.ml
+++ b/src/lib/process.ml
@@ -1,6 +1,6 @@
open StdLabels
-module M(T:Sounds.T) = struct
+module M(T:Sounds.Sig.T) = struct
type voyel = T.t Modifiers.Sig.voyel
@@ -19,7 +19,7 @@ module M(T:Sounds.T) = struct
= fun e m ->
List.fold_left m
~init:e
- ~f:(fun e f -> f (module T:Sounds.T with type t = T.t) e)
+ ~f:(fun e f -> f (module T:Sounds.Sig.T with type t = T.t) e)
let change_voyel
= fun init ->
diff --git a/src/lib/prononciation.mly b/src/lib/prononciation.mly
index 3901ea5..31ed8ff 100644
--- a/src/lib/prononciation.mly
+++ b/src/lib/prononciation.mly
@@ -101,6 +101,7 @@ letters
| E L { letter_e $1 :: L :: [] }
| E L L { E_AGRAVE :: L :: [] }
| I L { I :: L :: [] }
+ | voyel I L L { $1 :: Y :: [] }
| I L L { I :: Y :: [] }
| L { L :: [] }
| M { M :: [] }
@@ -124,7 +125,7 @@ letters
| V { V :: [] }
| W { W :: [] }
- | X { K :: SZ :: [] }
+ | X { K :: Sep :: SZ :: [] }
| Y { Y :: [] }
| Z { Z :: [] }
diff --git a/src/lib/sounds/repr.ml b/src/lib/sounds/repr.ml
new file mode 100644
index 0000000..af13e68
--- /dev/null
+++ b/src/lib/sounds/repr.ml
@@ -0,0 +1,56 @@
+type t = string
+
+let a = "a"
+and a_nasal = "@"
+
+and e_opened = "E"
+and e_closed = "e"
+and schwa = "°"
+
+and eu = "9"
+
+and o = "o"
+and o_nasal = "§"
+
+and i = "i"
+and i_nasal = "5"
+and y = "y"
+and y_nasal = "1"
+
+and u = "u"
+
+and p = "p"
+and b = "b"
+and t = "t"
+and d = "d"
+
+and k = "k"
+and g = "g"
+
+and f = "f"
+and v = "v"
+
+and ch = "S"
+and j = "Z"
+
+and s = "s"
+and z = "z"
+
+and m = "m"
+and n = "n"
+
+and l = "L"
+and r = "R"
+
+and semi_voyel_w = "w"
+and semi_voyel_y = "j"
+
+let muted
+ : t -> t
+ = fun t ->
+ Printf.sprintf "(%s)" t
+
+let diphtongue
+ : t -> t -> t
+ = fun t1 t2 ->
+ Printf.sprintf "[%s%s]" t1 t2
diff --git a/src/lib/sounds/repr.mli b/src/lib/sounds/repr.mli
new file mode 100644
index 0000000..3e2a9c7
--- /dev/null
+++ b/src/lib/sounds/repr.mli
@@ -0,0 +1,45 @@
+type t = string
+
+val a : t
+val a_nasal : t
+
+val e_opened : t
+val e_closed : t
+val schwa : t
+
+val eu : t
+
+val o : t
+val o_nasal : t
+
+val i : t
+val i_nasal : t
+
+val y : t
+val y_nasal : t
+
+val u : t
+val p : t
+val b : t
+val t : t
+val d : t
+val k : t
+val g : t
+val f : t
+val v : t
+val ch : t
+val j : t
+val s : t
+val z : t
+val m : t
+val n : t
+val l : t
+val r : t
+
+val semi_voyel_w : t
+
+val semi_voyel_y : t
+
+val muted : t -> t
+
+val diphtongue : t -> t -> t
diff --git a/src/lib/sounds/sig.ml b/src/lib/sounds/sig.ml
new file mode 100644
index 0000000..372b888
--- /dev/null
+++ b/src/lib/sounds/sig.ml
@@ -0,0 +1,71 @@
+module type T = sig
+ type t
+ val muted : t -> t
+
+ val a : t
+ val e : [`Closed | `Opened] -> t
+ val eu : t
+
+ val o : t
+ val schwa : unit -> t
+
+ (** This is an empty sound.
+
+ It can be used to replace any element in a syllabus *)
+ val none: t
+
+ (** This is the voyel i like in "ici"
+ 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 become [un] like in "brun" *)
+ val voyel_y : t
+
+ (** Create a diphtongue from a semi-voyel and a voyel *)
+ val diphtongue: t -> t -> t
+
+ val nasal: t -> t option
+
+ val p: t
+ val b: t
+ val t: t
+ val d: t
+ val k: t
+ val g: t
+ val f: t
+ val v: t
+ val s: t
+ val z: t
+ val sz: t
+ val ch: t
+ val j: t
+
+ val n: t
+ val m: t
+
+ val r: t
+ val l: t
+
+ val semi_voyel_w: t
+ val semi_voyel_y: t
+
+ val is_voyel : t -> bool
+ val is_nasal : t -> bool
+
+ val repr : t -> string
+
+end
diff --git a/src/lib/sounds/sounds.ml b/src/lib/sounds/sounds.ml
index 276e8a1..92a644f 100644
--- a/src/lib/sounds/sounds.ml
+++ b/src/lib/sounds/sounds.ml
@@ -1,425 +1,287 @@
-module type T = sig
-
- type t
- val muted : t -> t
-
- val a : t
- val e : [`Closed | `Opened] -> t
- val eu : t
-
- val o : t
- val schwa : unit -> t
-
- (** This is an empty sound.
-
- It can be used to replace any element in a syllabus *)
- val none: t
-
- (** This is the voyel i like in "ici"
- 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 become [un] like in "brun" *)
- val voyel_y : t
-
- (** Create a diphtongue from a semi-voyel and a voyel *)
- val diphtongue: t -> t -> t
-
- val nasal: t -> t option
-
- val p: t
- val b: t
- val t: t
- val d: t
- val k: t
- val g: t
- val f: t
- val v: t
- val s: t
- val z: t
- val sz: t
- val ch: t
- val j: t
-
- val n: t
- val m: t
-
- val r: t
- val l: t
-
- val semi_voyel_w: t
- val semi_voyel_y: t
-
- 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
- | SZ (* This is a possible Z if followed by a voyel *)
- | Voyel_A
- | Voyel_E
- | Schwa
- | E_Opened
- | E_Closed
- | Voyel_I
- | Voyel_O
- | Voyel_U (* OU like in Ouvrir *)
- | Voyel_Y (* U like in Unique *)
- | Voyel_AI
- | Voyel_EU
- | SemiVoyel_W
- | SemiVoyel_Y
- | Consonant_P
- | Consonant_B
- | Consonant_T
- | Consonant_D
- | Consonant_K
- | Consonant_G
- | Consonant_F
- | Consonant_V
- | Consonant_S
- | Consonant_Z
- | Consonant_X
- | Consonant_J
-
- | Consonant_M
- | Consonant_N
- | Consonant_L
- | Consonant_R
- | Diphtonge of t * t
- | Muted of t
-
- and t =
- { code : code
- ; mutable_: bool (* Can the sound be muted ? *)
- ; kind : kind
- ; nasal : bool
- }
-
-end
-
-module Repr = struct
-
- type t = string
-
- let a = "a"
- and a_nasal = "@"
-
- and e_opened = "E"
- and e_closed = "e"
- and schwa = "°"
-
- and eu = "9"
-
- and o = "o"
- and o_nasal = "§"
-
- and i = "i"
- and i_nasal = "5"
- and y = "y"
- and y_nasal = "1"
-
- and u = "u"
-
- and p = "p"
- and b = "b"
- and t = "t"
- and d = "d"
-
- and k = "k"
- and g = "g"
-
- and f = "f"
- and v = "v"
-
- and ch = "S"
- and j = "Z"
-
- and s = "s"
- and z = "z"
-
- and m = "m"
- and n = "n"
-
- and l = "L"
- and r = "R"
-
- and semi_voyel_w = "w"
- and semi_voyel_y = "j"
-end
-
-module S = struct
-
- include T
-
- let is_voyel t =
- t.kind = Voyel
- || t.kind = SemiVoyel
- let is_nasal t = t.nasal
-
-
- let none =
- { mutable_ = true
- ; kind = None
- ; nasal = false
- ; code = None }
-
- let voyel =
- { none with kind = Voyel }
-
-
- let diphtongue v1 v2 =
- { voyel with
- code = Diphtonge (v1, v2)
- }
-
- let code t = t.code
-
- let a =
- { voyel with
- code = Voyel_A
- }
-
- let voyel_ai =
- { voyel with
- code = Voyel_AI
- }
-
- let e = function
- | `Closed -> { voyel with code = E_Closed }
- | `Opened -> { voyel with code = E_Opened }
-
- let eu =
- { voyel with
- code = Voyel_EU
- }
-
-
- let schwa () =
- { voyel with
- code = Schwa }
-
- let o =
- { voyel with
- code = Voyel_O }
-
- let i =
- { voyel with
- code = Voyel_I }
-
- let voyel_y =
- { voyel with
- code = Voyel_Y }
-
- let voyel_u =
- { voyel with
- code = Voyel_U }
-
- let p =
- { none with
- code = Consonant_P
- ; mutable_ = false }
-
- let b =
- { none with
- code = Consonant_B
- ; mutable_ = false
- }
-
- let t =
- { none with
- code = Consonant_T
- }
-
- let d =
- { none with
- code = Consonant_D }
-
- let k =
- { none with
- code = Consonant_K
- ; mutable_ = false }
-
- let g =
- { none with
- code = Consonant_G }
-
- let f =
- { none with
- code = Consonant_F
- ; mutable_ = false
- }
-
- let v =
- { none with
- code = Consonant_V }
-
- let s =
- { none with
- code = Consonant_S }
-
- let ch =
- { none with
- code = Consonant_X
- ; mutable_ = false }
-
- let j =
- { none with
- code = Consonant_J
- ; mutable_ = false }
-
- let sz =
- { s with code = SZ }
-
- let z =
- { none with
- code = Consonant_Z }
-
- let n =
- { none with
- code = Consonant_N
- ; nasal = true }
-
- let m =
- { none with
- code = Consonant_M
- ; nasal = true }
-
- let l =
- { none with
- code = Consonant_L }
-
- let r =
- { none with
- code = Consonant_R }
-
- let semi_voyel_w =
- { none with
- kind = SemiVoyel
- ; code = SemiVoyel_W}
-
- let semi_voyel_y =
+module Sig = Sig
+
+type kind =
+ | None
+ | Voyel
+ | SemiVoyel
+
+type code =
+ | None
+ | SZ (* This is a possible Z if followed by a voyel *)
+ | Voyel_A
+ | Voyel_E
+ | E_Opened
+ | E_Closed
+ | Voyel_I
+ | Voyel_O
+ | Voyel_U (* OU like in Ouvrir *)
+ | Voyel_Y (* U like in Unique *)
+ | Voyel_AI
+ | Voyel_EU
+ | SemiVoyel_W
+ | SemiVoyel_Y
+ | Consonant_P
+ | Consonant_B
+ | Consonant_T
+ | Consonant_D
+ | Consonant_K
+ | Consonant_G
+ | Consonant_F
+ | Consonant_V
+ | Consonant_S
+ | Consonant_Z
+ | Consonant_X
+ | Consonant_J
+
+ | Consonant_M
+ | Consonant_N
+ | Consonant_L
+ | Consonant_R
+ | Diphtonge of t * t
+ | Muted of t
+
+and t =
+ { code : code
+ ; mutable_: bool (* Can the sound be muted ? *)
+ ; kind : kind
+ ; nasal : bool
+ }
+
+let is_voyel t =
+ t.kind = Voyel
+ || t.kind = SemiVoyel
+let is_nasal t = t.nasal
+
+
+let none =
+ { mutable_ = true
+ ; kind = None
+ ; nasal = false
+ ; code = None }
+
+let voyel =
+ { none with kind = Voyel }
+
+
+let diphtongue v1 v2 =
+ { voyel with
+ code = Diphtonge (v1, v2)
+ }
+
+let a =
+ { voyel with
+ code = Voyel_A
+ }
+
+let voyel_ai =
+ { voyel with
+ code = Voyel_AI
+ }
+
+let e = function
+ | `Closed -> { voyel with code = E_Closed }
+ | `Opened -> { voyel with code = E_Opened }
+
+let eu =
+ { voyel with
+ code = Voyel_EU
+ }
+
+
+let schwa () =
+ { voyel with
+ code = Voyel_E }
+
+let o =
+ { voyel with
+ code = Voyel_O }
+
+let i =
+ { voyel with
+ code = Voyel_I }
+
+let voyel_y =
+ { voyel with
+ code = Voyel_Y }
+
+let voyel_u =
+ { voyel with
+ code = Voyel_U }
+
+let p =
+ { none with
+ code = Consonant_P
+ ; mutable_ = false }
+
+let b =
+ { none with
+ code = Consonant_B
+ ; mutable_ = false
+ }
+
+let t =
+ { none with
+ code = Consonant_T
+ }
+
+let d =
+ { none with
+ code = Consonant_D }
+
+let k =
+ { none with
+ code = Consonant_K
+ ; mutable_ = false }
+
+let g =
+ { none with
+ code = Consonant_G }
+
+let f =
+ { none with
+ code = Consonant_F
+ ; mutable_ = false
+ }
+
+let v =
+ { none with
+ code = Consonant_V }
+
+let s =
+ { none with
+ code = Consonant_S }
+
+let sz =
+ { s with code = SZ }
+
+let z =
+ { none with
+ code = Consonant_Z }
+
+let ch =
+ { none with
+ code = Consonant_X
+ ; mutable_ = false }
+
+let j =
+ { none with
+ code = Consonant_J
+ ; mutable_ = false }
+
+let n =
+ { none with
+ code = Consonant_N
+ ; nasal = true }
+
+let m =
+ { none with
+ code = Consonant_M
+ ; nasal = true }
+
+let l =
+ { none with
+ code = Consonant_L }
+
+let r =
+ { none with
+ code = Consonant_R }
+
+let semi_voyel_w =
+ { none with
+ kind = SemiVoyel
+ ; code = SemiVoyel_W}
+
+let semi_voyel_y =
+ { none with
+ kind = SemiVoyel
+ ; code = SemiVoyel_Y}
+
+let nasal t =
+
+ match t.code with
+ | Voyel_E | E_Opened ->
+ Some { t with nasal = true }
+ | Voyel_A -> Some { t with nasal = true }
+ | Voyel_AI -> Some { t with nasal = true }
+ | Voyel_O -> Some { t with nasal = true }
+ | Voyel_I -> Some { t with nasal = true }
+ | Voyel_Y -> Some { t with nasal = true }
+ | Diphtonge (s1, s2) ->
+ begin match s1.code, s2.code with
+ | (SemiVoyel_W, Voyel_I) ->
+ (* The only case we could have the nasalisation of such diphtongue, is
+ the case O I, N -> wich is transformed into O, I N *)
+ Some (
+ diphtongue
+ semi_voyel_w
+ { i with nasal = true } )
+ | (Voyel_I, Voyel_E) ->
+ (* The only case we could have the nasalisation of such diphtongue, is
+ the case I E, N -> wich is transformed into I, E N *)
+ Some (
+ diphtongue
+ i
+ { t with nasal = true } )
+ | _ -> None
+ end
+ | _ -> None
+
+let muted f =
+ (* f is alway pronounend in endding consonant. Know exeception are :
+ - cerf
+ - clef
+ - nerf
+ - serf *)
+ match f.mutable_ with
+ | false -> f
+ | true ->
{ none with
- kind = SemiVoyel
- ; code = SemiVoyel_Y}
-
- let nasal t =
-
- match t.code with
- | Voyel_E | E_Opened | Schwa ->
- Some { t with nasal = true }
- | Voyel_A -> Some { t with nasal = true }
- | Voyel_AI -> Some { t with nasal = true }
- | Voyel_O -> Some { t with nasal = true }
- | Voyel_I -> Some { t with nasal = true }
- | Voyel_Y -> Some { t with nasal = true }
- | Diphtonge (s1, s2) ->
- begin match s1.code, s2.code with
- | (SemiVoyel_W, Voyel_I) ->
- (* The only case we could have the nasalisation of such diphtongue, is
- the case O I, N -> wich is transformed into O, I N *)
- Some (
- diphtongue
- semi_voyel_w
- { i with nasal = true } )
- | (Voyel_I, Voyel_E) ->
- (* The only case we could have the nasalisation of such diphtongue, is
- the case I E, N -> wich is transformed into I, E N *)
- Some (
- diphtongue
- i
- { t with nasal = true } )
- | _ -> None
- end
- | _ -> None
-
- let muted f =
- (* f is alway pronounend in endding consonant. Know exeception are :
- - cerf
- - clef
- - nerf
- - serf *)
- match f.mutable_ with
- | false -> f
- | true ->
- { none with
- code = Muted f }
-
- let rec repr
- : t -> Repr.t
- = fun letter ->
- match letter.code, letter.nasal with
-
- | None, _ -> ""
-
- | Voyel_A, false -> Repr.a
- | Voyel_A, true -> Repr.a_nasal
- | Voyel_AI, false -> "E"
- | Voyel_AI, true -> Repr.i_nasal
- | Voyel_E, _ -> ""
- | E_Closed, _ -> Repr.e_closed
- | E_Opened, true | Schwa, true -> Repr.a_nasal
- | Schwa, _ -> Repr.schwa
- | E_Opened, _ -> Repr.e_opened
- | Voyel_I, false -> Repr.i
- | Voyel_I, true -> Repr.i_nasal
- | Voyel_O, true -> Repr.o_nasal
- | Voyel_O, false -> Repr.o
- | Voyel_U, _ -> Repr.u
- | Voyel_Y, false -> Repr.y
- | Voyel_Y, true -> Repr.y_nasal
- | Voyel_EU, _ -> Repr.eu
-
- | SemiVoyel_W, _ -> Repr.semi_voyel_w
- | SemiVoyel_Y, _ -> Repr.semi_voyel_y
-
- | Consonant_P, _ -> Repr.p
- | Consonant_B, _ -> Repr.b
- | Consonant_T, _ -> Repr.t
- | Consonant_D, _ -> Repr.d
- | Consonant_K, _ -> Repr.k
- | Consonant_G, _ -> Repr.g
- | Consonant_F, _ -> Repr.f
- | Consonant_V, _ -> Repr.v
- | SZ, _
- | Consonant_S, _ -> Repr.s
- | Consonant_Z, _ -> Repr.z
-
- | Consonant_X, _ -> Repr.ch
- | Consonant_J, _ -> Repr.j
-
- | Consonant_M, _ -> Repr.m
- | Consonant_N, _ -> Repr.n
- | Consonant_L, _ -> Repr.l
- | Consonant_R, _ -> Repr.r
- | Diphtonge (l1, l2), _ ->
- "[" ^ (repr l1) ^ (repr l2) ^ "]"
- | Muted t, _ ->
- "(" ^ (repr t) ^ ")"
-end
-
-include S
+ code = Muted f }
+
+let rec repr
+ : t -> Repr.t
+ = fun letter ->
+ match letter.code, letter.nasal with
+
+ | None, _ -> ""
+ | Voyel_A, false -> Repr.a
+ | Voyel_A, true -> Repr.a_nasal
+ | Voyel_AI, false -> "E"
+ | Voyel_AI, true -> Repr.i_nasal
+ | E_Closed, _ -> Repr.e_closed
+ | E_Opened, true | Voyel_E, true -> Repr.a_nasal
+ | Voyel_E , _ -> Repr.schwa
+ | E_Opened, _ -> Repr.e_opened
+ | Voyel_I, false -> Repr.i
+ | Voyel_I, true -> Repr.i_nasal
+ | Voyel_O, true -> Repr.o_nasal
+ | Voyel_O, false -> Repr.o
+ | Voyel_U, _ -> Repr.u
+ | Voyel_Y, false -> Repr.y
+ | Voyel_Y, true -> Repr.y_nasal
+ | Voyel_EU, _ -> Repr.eu
+
+ | SemiVoyel_W, _ -> Repr.semi_voyel_w
+ | SemiVoyel_Y, _ -> Repr.semi_voyel_y
+
+ | Consonant_P, _ -> Repr.p
+ | Consonant_B, _ -> Repr.b
+ | Consonant_T, _ -> Repr.t
+ | Consonant_D, _ -> Repr.d
+ | Consonant_K, _ -> Repr.k
+ | Consonant_G, _ -> Repr.g
+ | Consonant_F, _ -> Repr.f
+ | Consonant_V, _ -> Repr.v
+ | SZ, _
+ | Consonant_S, _ -> Repr.s
+ | Consonant_Z, _ -> Repr.z
+
+ | Consonant_X, _ -> Repr.ch
+ | Consonant_J, _ -> Repr.j
+
+ | Consonant_M, _ -> Repr.m
+ | Consonant_N, _ -> Repr.n
+ | Consonant_L, _ -> Repr.l
+ | Consonant_R, _ -> Repr.r
+ | Diphtonge (l1, l2), _ -> Repr.diphtongue (repr l1) (repr l2)
+ | Muted t, _ -> Repr.muted (repr t)
diff --git a/src/lib/sounds/sounds.mli b/src/lib/sounds/sounds.mli
new file mode 100644
index 0000000..acb3335
--- /dev/null
+++ b/src/lib/sounds/sounds.mli
@@ -0,0 +1,70 @@
+module Sig = Sig
+
+type t
+val muted : t -> t
+
+val a : t
+val e : [`Closed | `Opened] -> t
+val eu : t
+
+val o : t
+val schwa : unit -> t
+
+(** This is an empty sound.
+
+ It can be used to replace any element in a syllabus *)
+val none: t
+
+(** This is the voyel i like in "ici"
+ 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 become [un] like in "brun" *)
+val voyel_y : t
+
+(** Create a diphtongue from a semi-voyel and a voyel *)
+val diphtongue: t -> t -> t
+
+val nasal: t -> t option
+
+val p: t
+val b: t
+val t: t
+val d: t
+val k: t
+val g: t
+val f: t
+val v: t
+val s: t
+val z: t
+val sz: t
+val ch: t
+val j: t
+
+val n: t
+val m: t
+
+val r: t
+val l: t
+
+val semi_voyel_w: t
+val semi_voyel_y: t
+
+val is_voyel : t -> bool
+val is_nasal : t -> bool
+
+val repr : t -> string
diff --git a/src/test/test.ml b/src/test/test.ml
index 5203d12..eed0bef 100644
--- a/src/test/test.ml
+++ b/src/test/test.ml
@@ -46,7 +46,8 @@ let tests =
; "abaissées", "abEse(s)"
; "abaissera", "abEs°Ra"
; "achat", "aSa(t)"
- ; "ani", "ani"
+ ; "aiment", "Em°(t)"
+ ; "anniversaire", "anivERsER°"
; "anta", "@ta"
; "anneaux", "ano(s)"
; "arachide", "aRaSid°"
@@ -67,6 +68,7 @@ let tests =
; "croire", "kR[wa]R°"
; "ébrouas", "ebRua(s)"
; "em|magasinais","@magazinE(s)"
+ ; "extra", "EkstRa"
; "famille", "famij°"
; "loin", "Lw5"
; "groin", "gR[w5]"
@@ -90,6 +92,7 @@ let tests =
; "souris", "suRi(s)"
; "toiture", "twatyR°"
; "trois", "tR[wa](s)"
+ ; "veillons", "vEj§(s)"
; "vil|le", "viLL°"
; "wèb", "wEb"
]