diff options
-rw-r--r-- | src/lib/parser.mly | 27 | ||||
-rw-r--r-- | src/lib/sounds/sounds.ml | 124 | ||||
-rw-r--r-- | src/test/test.ml | 10 |
3 files changed, 72 insertions, 89 deletions
diff --git a/src/lib/parser.mly b/src/lib/parser.mly index 9d44b1f..6c1722a 100644 --- a/src/lib/parser.mly +++ b/src/lib/parser.mly @@ -45,36 +45,27 @@ obstruent: liquid: | L { Sounds.l } - | L L { Sounds.l } | R { Sounds.r } nasal: | N { Sounds.n } | M { Sounds.m } - | G N { Sounds.gn } -consonant: - | occlusiv { $1 } - | fricativ { $1 } - | liquid { $1 } - | nasal { $1 } -semi_voyel: - (* | Y { Sounds.semi_voyel_y } *) - | W { Sounds.semi_voyel_w } +initial_nasal: + | nasal { $1 } + | G N { Sounds.gn } opening_consonant: | occlusiv { $1, None } | fricativ { $1, None } - | nasal { $1, None } + | initial_nasal { $1, None } | liquid { $1, None } + +opening_double: | obstruent liquid { $1, Some $2 } | occlusiv fricativ { $1, Some $2 } -semi: - | semi_voyel { $1, None } - - (* Each voyel as two associated sounds, depending there is a followng sound or not *) voyels: @@ -89,11 +80,11 @@ voyels: | O { Sounds.o } | U { Sounds.voyel_y } | OU { Sounds.voyel_u } + (* This semi voyel can never be separated *) + | W voyels { Sounds.diphtongue Sounds.semi_voyel_w $2 } voyels_semi: | voyels { $1 } - | W A { Sounds.diphtongue Sounds.semi_voyel_w Sounds.a} - | W I { Sounds.diphtongue Sounds.semi_voyel_w Sounds.i} | I voyels { Sounds.diphtongue Sounds.semi_voyel_y $2 } | Y voyels { Sounds.diphtongue Sounds.semi_voyel_y $2 } @@ -143,7 +134,7 @@ syllable: v = voyels_semi Sep? { (v, c) } - | c = consonant_group(semi) + | c = consonant_group(opening_double) v = voyels Sep? { (v, Some c) } diff --git a/src/lib/sounds/sounds.ml b/src/lib/sounds/sounds.ml index 58d511b..2e8e95b 100644 --- a/src/lib/sounds/sounds.ml +++ b/src/lib/sounds/sounds.ml @@ -203,34 +203,21 @@ let semi_voyel_y = 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) -> +let rec nasal t = + + match t.kind, t.code with + | Voyel, 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) -> + | (SemiVoyel_Y, 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 } ) + the case I E, N -> wich is transformed into I, I N. *) + Some ( diphtongue s1 { i with nasal = true } ) + | (SemiVoyel_Y, _) + | (SemiVoyel_W, _) -> + Option.map (fun s -> diphtongue s1 s) (nasal s2) | _ -> None end + | Voyel, _ -> Some { t with nasal = true } | _ -> None let muted f = @@ -254,50 +241,51 @@ let repr match letter.code, letter.nasal with - | None, _ -> Repr.none - | Voyel_A, false -> Repr.a - | Voyel_A, true -> Repr.a_nasal - | Voyel_AI, false -> Repr.e_opened - | Voyel_AI, true -> Repr.i_nasal - | E_Closed, _ -> Repr.e_closed - | E_Opened, true | Voyel_E, true -> Repr.a_nasal - | Voyel_E , false -> Repr.schwa - | E_Opened, false -> 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_Closed, _ -> Repr.eu_closed - | Voyel_EU_Opened, _ -> Repr.eu_opened - - | 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_GN, _ -> Repr.gn - | Consonant_L, _ -> Repr.l - | Consonant_R, _ -> Repr.r - | Diphtonge (l1, l2), _ -> Repr.diphtongue (_repr l1) (_repr l2) - | Muted t, _ -> Repr.muted (_repr t) + | None , _ -> Repr.none + | Voyel_A , false -> Repr.a + | Voyel_A , true -> Repr.a_nasal + | Voyel_AI , false -> Repr.e_opened + | Voyel_AI , true -> Repr.i_nasal + | E_Closed , _ -> Repr.e_closed + | E_Opened , false -> Repr.e_opened + | E_Opened , true + | Voyel_E , true -> Repr.a_nasal + | Voyel_E , false -> Repr.schwa + | 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_Closed , _ -> Repr.eu_closed + | Voyel_EU_Opened , _ -> Repr.eu_opened + + | 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_GN , _ -> Repr.gn + | Consonant_L , _ -> Repr.l + | Consonant_R , _ -> Repr.r + | Muted t , _ -> Repr.muted (_repr t) + | Diphtonge (l1, l2), _ -> Repr.diphtongue (_repr l1) (_repr l2) in diff --git a/src/test/test.ml b/src/test/test.ml index c3ba019..f6f1f2c 100644 --- a/src/test/test.ml +++ b/src/test/test.ml @@ -64,7 +64,7 @@ let tests = ; "atmosphère", "atmosfER°" ; "automne", "ot§n°" ; "autruche", "otRyS°" - ; "besoin", "b°zw5" + ; "besoin", "b°z[w5]" ; "beaumont", "bom§(t)" ; "bisoux", "bizu(s)" ; "boulangerie", "buL@Z°Ri" @@ -74,6 +74,7 @@ let tests = ; "chanci", "S@si" ; "chat", "Sa(t)" ; "chipant", "Sip@(t)" + ; "crions", "kRi§(s)" ; "co|incidant", "ko5sid@(t)" ; "croire", "kR[wa]R°" ; "cuillère", "kyi[jE]R°" @@ -87,6 +88,8 @@ let tests = ; "famille", "fami[j°]" ; "feuille", "f9[j°]" ; "final", "finaL" + ; "liant", "L[j@](t)" + ; "lion", "L[j§]" ; "loin", "L[w5]" ; "groin", "gR[w5]" ; "hélicoptère", "eLikoptER°" @@ -111,13 +114,14 @@ let tests = ; "proie", "pR[wa]" ; "quille", "ki[j°]" ; "reine", "REn°" - ; "soin", "sw5" + ; "rien", "R[j5]" + ; "soin", "s[w5]" ; "souris", "suRi(s)" ; "toiture", "t[wa]tyR°" ; "trois", "tR[wa](s)" ; "vieux", "v[j9](s)" ; "vil|le", "viLL°" - ; "wèb", "wEb" + ; "wèb", "[wE]b" ] let () = |