diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-09-05 19:41:40 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2021-09-05 19:41:40 +0200 |
commit | 6a34154b77ac80f89df816ba0062f382d915fb22 (patch) | |
tree | 5dab18f15fe8555d5369a9c492228f6aa4d23001 /src/lib | |
parent | 853e281a6719125866f8b948540944c571b091c6 (diff) |
Updated tests
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/lexer.mll | 1 | ||||
-rw-r--r-- | src/lib/modifiers/e.ml | 18 | ||||
-rw-r--r-- | src/lib/modifiers/modifiers.ml | 1 | ||||
-rw-r--r-- | src/lib/modifiers/mute.ml | 2 | ||||
-rw-r--r-- | src/lib/modifiers/nasal.ml | 2 | ||||
-rw-r--r-- | src/lib/modifiers/sig.ml | 10 | ||||
-rw-r--r-- | src/lib/parser.mly | 35 | ||||
-rw-r--r-- | src/lib/process.ml | 14 | ||||
-rw-r--r-- | src/lib/prononciation.mly | 10 | ||||
-rw-r--r-- | src/lib/repr/default.ml | 2 | ||||
-rw-r--r-- | src/lib/sounds/sig.ml | 1 | ||||
-rw-r--r-- | src/lib/sounds/sounds.ml | 7 | ||||
-rw-r--r-- | src/lib/sounds/sounds.mli | 1 | ||||
-rw-r--r-- | src/lib/tokens.mly | 4 |
14 files changed, 72 insertions, 36 deletions
diff --git a/src/lib/lexer.mll b/src/lib/lexer.mll index 0e9cebf..50c25a7 100644 --- a/src/lib/lexer.mll +++ b/src/lib/lexer.mll @@ -17,6 +17,7 @@ rule letter = parse | 'e' { E Accent.NONE } | '\232' { E Accent.ACUTE } | "è" { E Accent.AGRAVE } +| "ê" { E Accent.AGRAVE } | '\233' { E Accent.ACUTE } | "é" { E Accent.ACUTE } | 'f' { F } diff --git a/src/lib/modifiers/e.ml b/src/lib/modifiers/e.ml index 8fd65bf..5f6e6fe 100644 --- a/src/lib/modifiers/e.ml +++ b/src/lib/modifiers/e.ml @@ -2,14 +2,26 @@ let process : 'a Sig.modifier = fun init -> - let ((v2, c) , ending) = init in + let ((v, c) , ending) = init in match ending with - | None when v2 = Sounds.schwa -> + | None when v = 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 -> + | Some _ when v = Sounds.schwa -> + (* If there is an ending consonant, change the e into E like essai *) + ((Sounds.e `Opened, c) , ending) + | _ -> init + +(** Transform the final e into E if there is a consonant *) +let ending_e + : 'a Sig.modifier + = fun init -> + let ((v, c) , ending) = init in + + match ending with + | Some _ when v = 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 3a9ecd6..4e58cba 100644 --- a/src/lib/modifiers/modifiers.ml +++ b/src/lib/modifiers/modifiers.ml @@ -4,3 +4,4 @@ let nasal = Nasal.process let vocalize_s = Vocalize.process let mute_consonant = Mute.process let e = E.process +let ending_e = E.ending_e diff --git a/src/lib/modifiers/mute.ml b/src/lib/modifiers/mute.ml index b89fda7..7b58336 100644 --- a/src/lib/modifiers/mute.ml +++ b/src/lib/modifiers/mute.ml @@ -1,6 +1,6 @@ open StdLabels -(** Mute the last consonant if there is no voyel in the syllabus. +(** Mute the last consonant if there is no voyel in the syllabe. This modifier is only applied in the first step, and not repeated anymore. *) diff --git a/src/lib/modifiers/nasal.ml b/src/lib/modifiers/nasal.ml index cc29efc..43f3bd8 100644 --- a/src/lib/modifiers/nasal.ml +++ b/src/lib/modifiers/nasal.ml @@ -1,7 +1,7 @@ (* 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 + : Sig.consonants option -> Sounds.t Sig.t -> Sounds.t Sig.t = fun c init -> let ((v, _) , _) = init in diff --git a/src/lib/modifiers/sig.ml b/src/lib/modifiers/sig.ml index 5f82620..19c4ff7 100644 --- a/src/lib/modifiers/sig.ml +++ b/src/lib/modifiers/sig.ml @@ -1,11 +1,11 @@ type voyel = Sounds.t -type 'a consonants = - { ending : 'a option option - ; opening : 'a list - ; following : 'a option } +type consonants = + { ending : Sounds.t option option + ; opening : Sounds.t list + ; following : Sounds.t option } -type 'a group = voyel * 'a consonants option +type 'a group = voyel * consonants option type 'a t = 'a group * 'a option option diff --git a/src/lib/parser.mly b/src/lib/parser.mly index e5e6773..8fe4a55 100644 --- a/src/lib/parser.mly +++ b/src/lib/parser.mly @@ -11,7 +11,7 @@ See [1] for the theory behind the analysis %{ - + open Modifiers.Sig %} %start<Sounds.t List.t> main @@ -51,6 +51,7 @@ liquid: nasal: | N { Sounds.n } | M { Sounds.m } + | G N { Sounds.gn } consonant: | occlusiv { $1 } @@ -69,7 +70,8 @@ opening_consonant: | liquid { $1, None } | obstruent liquid { $1, Some $2 } | occlusiv fricativ { $1, Some $2 } - | consonant semi_voyel{ $1, Some $2 } + +semi: | semi_voyel { $1, None } @@ -87,6 +89,9 @@ voyels: | O { Sounds.o } | U { Sounds.voyel_y } | OU { Sounds.voyel_u } + +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 E { Sounds.diphtongue Sounds.i (Sounds.e `Opened) } @@ -96,18 +101,20 @@ ending_consonant: | B { Some (Sounds.b ) } | T { Some (Sounds.t )} | K { Some (Sounds.k)} + | G { Some (Sounds.g)} | liquid { Some $1 } | nasal { Some $1 } -consonant_group: - | f = fricativ - o = opening_consonant + +%inline consonant_group(opening) + : f = fricativ + o = opening { { ending = None ; opening = f::(fst o)::[] ; following = snd o } } - | o = opening_consonant + | o = opening { { ending = None ; opening = [ fst o ] @@ -115,7 +122,7 @@ consonant_group: } | e = ending_consonant Sep? - o = opening_consonant + o = opening { { ending = Some e ; opening = [ fst o ] @@ -124,18 +131,24 @@ consonant_group: | e = ending_consonant Sep? f = fricativ - o = opening_consonant + o = opening { { ending = Some e ; opening = f::[ fst o ] ; following = snd o } } + +(** Exclude a semi voyel in both consonant and voyel position *) syllable: - | c = consonant_group? - v = voyels + | c = consonant_group(opening_consonant)? + v = voyels_semi Sep? { (v, c) } + | c = consonant_group(semi) + v = voyels + Sep? + { (v, Some c) } syllables: @@ -145,7 +158,7 @@ syllables: word: - | Sep? syllables consonant_group? EOL { Process.rebuild $3 $2 } + | Sep? syllables consonant_group(opening_consonant)? EOL { Process.rebuild $3 $2 } main: | word { $1 } diff --git a/src/lib/process.ml b/src/lib/process.ml index f85853f..d6ad291 100644 --- a/src/lib/process.ml +++ b/src/lib/process.ml @@ -2,7 +2,7 @@ open StdLabels type voyel = Sounds.t -type group = voyel * Sounds.t Modifiers.Sig.consonants option +type group = voyel * Modifiers.Sig.consonants option type modifier = Sounds.t Modifiers.Sig.modifier (** Apply all the modifiers to the syllabic group in order to correct the @@ -41,9 +41,9 @@ let rec _rebuild ~(m:modifier list) acc ending_consonant : group list -> Sounds. | Some s -> voyel :: s::acc in - (* Apply the modifiers to the previous syllabus. + (* Apply the modifiers to the previous syllabe. - Only transform the e into eu / E if there is previous syllabus with + Only transform the e into eu / E if there is previous syllabe with voyel. *) let modifiers = if voyel = Sounds.none then [] @@ -75,10 +75,8 @@ let rec _rebuild ~(m:modifier list) acc ending_consonant : group list -> Sounds. *) let rebuild - : Sounds.t Modifiers.Sig.consonants option -> group list -> Sounds.t list + : Modifiers.Sig.consonants option -> group list -> Sounds.t list = fun ending elems -> - let elems' = match ending with - | None -> elems - | Some _ -> (Sounds.none, ending)::elems in - _rebuild ~m:[Modifiers.mute_consonant] [] None elems' + let elems' = (Sounds.none, ending)::elems in + _rebuild ~m:[Modifiers.mute_consonant;Modifiers.ending_e;] [] None elems' diff --git a/src/lib/prononciation.mly b/src/lib/prononciation.mly index 65e203c..d367170 100644 --- a/src/lib/prononciation.mly +++ b/src/lib/prononciation.mly @@ -58,20 +58,23 @@ %start<Tokens.token list> main %% - -voyel +voyel_without_i : A { A } | E { letter_e $1 } - | I { I } | O { O } | A U { O } | E A U { O } | O U { OU } | U { U } +voyel + : I { I } + | voyel_without_i { $1 } + letters : voyel { $1 :: [] } + | voyel_without_i I { $1 :: I :: []} | Space { Space :: [] } | Sep { Sep :: [] } @@ -101,6 +104,7 @@ letters | L L { Nothing :: L :: [] } | I L { I :: L :: [] } | I L L { I :: Y :: [] } + | voyel_without_i I L L { $1 :: Y :: [] } | L { L :: [] } | M { M :: [] } | M M { M :: [] } diff --git a/src/lib/repr/default.ml b/src/lib/repr/default.ml index 4110679..2688411 100644 --- a/src/lib/repr/default.ml +++ b/src/lib/repr/default.ml @@ -44,6 +44,8 @@ and z = "z" and m = "m" and n = "n" +and gn = "N" + and l = "L" and r = "R" diff --git a/src/lib/sounds/sig.ml b/src/lib/sounds/sig.ml index 5322a12..016c757 100644 --- a/src/lib/sounds/sig.ml +++ b/src/lib/sounds/sig.ml @@ -37,6 +37,7 @@ module type REPR = sig val z : t val m : t val n : t + val gn : t val l : t val r : t diff --git a/src/lib/sounds/sounds.ml b/src/lib/sounds/sounds.ml index afaf110..58d511b 100644 --- a/src/lib/sounds/sounds.ml +++ b/src/lib/sounds/sounds.ml @@ -36,6 +36,7 @@ type code = | Consonant_M | Consonant_N + | Consonant_GN | Consonant_L | Consonant_R | Diphtonge of t * t @@ -168,6 +169,11 @@ let j = code = Consonant_J ; mutable_ = false } +let gn = + { none with + code = Consonant_GN + ; nasal = true } + let n = { none with code = Consonant_N @@ -287,6 +293,7 @@ let repr | 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) diff --git a/src/lib/sounds/sounds.mli b/src/lib/sounds/sounds.mli index 2fae17f..4f0bbc1 100644 --- a/src/lib/sounds/sounds.mli +++ b/src/lib/sounds/sounds.mli @@ -60,6 +60,7 @@ val ch: t val j: t val n: t +val gn: t val m: t val r: t diff --git a/src/lib/tokens.mly b/src/lib/tokens.mly index ea1493a..35c8e1d 100644 --- a/src/lib/tokens.mly +++ b/src/lib/tokens.mly @@ -3,14 +3,12 @@ %token Nothing %token A %token B -%token C %token D %token E %token E_ACUTE %token E_AGRAVE %token F %token G -%token H %token I %token J %token K @@ -19,7 +17,6 @@ %token N %token O %token OU -%token Q %token P %token R %token S @@ -35,7 +32,6 @@ %token EOL %nonassoc Low -%left R %right High %% |