diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-09-03 11:44:55 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2021-09-03 11:44:55 +0200 |
commit | ad45e1b397ba995dc0222057a8dc1d0c38970c4f (patch) | |
tree | 311e8b38215503ae05a78573c8a92500d7ca01f4 /src/lib | |
parent | 6af889039d232381b13f1f07a694abcfaff2535e (diff) |
Update model
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/lexer.mll | 1 | ||||
-rw-r--r-- | src/lib/prononciation.mly | 2 | ||||
-rw-r--r-- | src/lib/reader.ml | 2 | ||||
-rw-r--r-- | src/lib/sounds/sounds.ml | 106 |
4 files changed, 57 insertions, 54 deletions
diff --git a/src/lib/lexer.mll b/src/lib/lexer.mll index 27533cd..0e9cebf 100644 --- a/src/lib/lexer.mll +++ b/src/lib/lexer.mll @@ -46,6 +46,7 @@ rule letter = parse | 'z' { Z } | ' ' { Space } | ending { EOL } +| "erf" ending { ERF_ } | "el" ending { EL_ } | "ent" ending { ENT_ } | "ient" ending { IENT_ } diff --git a/src/lib/prononciation.mly b/src/lib/prononciation.mly index be153cb..3901ea5 100644 --- a/src/lib/prononciation.mly +++ b/src/lib/prononciation.mly @@ -18,6 +18,7 @@ %token X_ %token ENT_ +%token ERF_ %token EL_ %token IENT_ %token Sep @@ -132,6 +133,7 @@ ending: | X_ { S::EOL::[]} | IENT_ { I::T::EOL::[]} | ENT_ { E::T::EOL::[]} + | ERF_ { E_AGRAVE::R::EOL::[]} | EL_ { E_AGRAVE::L::EOL::[]} | EOL { EOL::[] } diff --git a/src/lib/reader.ml b/src/lib/reader.ml index c5f8cda..52339a2 100644 --- a/src/lib/reader.ml +++ b/src/lib/reader.ml @@ -9,7 +9,7 @@ let sound_to_string = fun t -> let buff = Buffer.create 16 in List.iter t - ~f:(fun f -> Buffer.add_string buff f.Sounds.repr); + ~f:(fun f -> Buffer.add_string buff (Sounds.repr f)); Buffer.contents buff let succeed (res : Sounds.t list) = diff --git a/src/lib/sounds/sounds.ml b/src/lib/sounds/sounds.ml index 9892ace..276e8a1 100644 --- a/src/lib/sounds/sounds.ml +++ b/src/lib/sounds/sounds.ml @@ -82,11 +82,15 @@ module T = struct | 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 @@ -107,10 +111,10 @@ module T = struct | Consonant_L | Consonant_R | Diphtonge of t * t + | Muted of t and t = { code : code - ; repr : string ; mutable_: bool (* Can the sound be muted ? *) ; kind : kind ; nasal : bool @@ -125,6 +129,12 @@ module Repr = struct 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 = "§" @@ -173,8 +183,7 @@ module S = struct let none = - { repr = "" - ; mutable_ = true + { mutable_ = true ; kind = None ; nasal = false ; code = None } @@ -186,7 +195,6 @@ module S = struct let diphtongue v1 v2 = { voyel with code = Diphtonge (v1, v2) - ; repr = "[" ^ (v1.repr) ^ (v2.repr) ^ "]" } let code t = t.code @@ -194,108 +202,94 @@ module S = struct let a = { voyel with code = Voyel_A - ; 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 } + | `Closed -> { voyel with code = E_Closed } + | `Opened -> { voyel with code = E_Opened } let eu = - { voyel with repr = "9" } + { voyel with + code = Voyel_EU + } let schwa () = { voyel with - code = Voyel_E - ; repr = "°" } + code = Schwa } let o = { voyel with - repr = Repr.o - ; code = Voyel_O } + code = Voyel_O } let i = { voyel with - repr = Repr.i - ; code = Voyel_I } + code = Voyel_I } let voyel_y = { voyel with - repr = Repr.y - ; code = Voyel_Y } + code = Voyel_Y } let voyel_u = { voyel with - repr = Repr.u - ; code = Voyel_U } + code = Voyel_U } let p = { none with code = Consonant_P - ; repr = Repr.p ; mutable_ = false } let b = { none with code = Consonant_B - ; repr = Repr.b ; mutable_ = false } let t = { none with code = Consonant_T - ; repr = Repr.t } let d = { none with - code = Consonant_D - ; repr = Repr.d } + code = Consonant_D } let k = { none with code = Consonant_K - ; repr = Repr.k ; mutable_ = false } let g = { none with - code = Consonant_G - ; repr = Repr.g } + code = Consonant_G } let f = { none with code = Consonant_F - ; repr = Repr.f } + ; mutable_ = false + } let v = { none with - code = Consonant_V - ; repr = Repr.v } + code = Consonant_V } let s = { none with - code = Consonant_S - ; repr = Repr.s } + code = Consonant_S } let ch = { none with code = Consonant_X - ; repr = Repr.ch ; mutable_ = false } let j = { none with code = Consonant_J - ; repr = Repr.j ; mutable_ = false } let sz = @@ -303,52 +297,46 @@ module S = struct let z = { none with - code = Consonant_Z - ; repr = Repr.z } + code = Consonant_Z } let n = { none with code = Consonant_N - ; repr = Repr.n ; nasal = true } let m = { none with code = Consonant_M - ; repr = Repr.m ; nasal = true } let l = { none with - code = Consonant_L - ; repr = Repr.l } + code = Consonant_L } let r = { none with - code = Consonant_R - ; repr = Repr.r } + code = Consonant_R } let semi_voyel_w = { none with kind = SemiVoyel - ; repr = Repr.semi_voyel_w ; code = SemiVoyel_W} let semi_voyel_y = { none with 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_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 } + | 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) -> @@ -357,24 +345,29 @@ module S = struct Some ( diphtongue semi_voyel_w - { i with repr = Repr.i_nasal ; nasal = true } ) + { 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 repr = Repr.i_nasal ; nasal = true } ) + { 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 - repr = "(" ^ f.repr ^ ")" } + code = Muted f } let rec repr : t -> Repr.t @@ -388,6 +381,10 @@ module S = struct | 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 @@ -395,6 +392,7 @@ module S = struct | 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 @@ -420,6 +418,8 @@ module S = struct | Consonant_R, _ -> Repr.r | Diphtonge (l1, l2), _ -> "[" ^ (repr l1) ^ (repr l2) ^ "]" + | Muted t, _ -> + "(" ^ (repr t) ^ ")" end include S |