ukrainian-phonetics-basic-array 0.5.3.0 → 0.6.0.0
raw patch · 4 files changed
+99/−38 lines, 4 files
Files
- CHANGELOG.md +7/−0
- Languages/Phonetic/Ukrainian/Syllable/ArrInt8.hs +73/−26
- Melodics/Ukrainian/ArrInt8.hs +17/−10
- ukrainian-phonetics-basic-array.cabal +2/−2
CHANGELOG.md view
@@ -57,3 +57,10 @@ * Fifth version revised C. Updated the dependencies boundaries so that the latest versions of GHC and Cabal are supported. +## 0.6.0.0 -- 2022-08-09++* Sixth version. Fixed issues with the syllable segmentation with soft sign consonant sequences. Changed the structure of the non-sound Ukraninian symbols+representation (now they are converted to one of the [100,101,102]). +Fixed some issues with the dash '-' and apostrophe signs in word and syllable segmentation.+These changes affect the general results of the package functions work.+
Languages/Phonetic/Ukrainian/Syllable/ArrInt8.hs view
@@ -21,6 +21,7 @@ , isVoicedC1 , isVoicelessC1 , isNotVowel2+ , isNotVowel2' , sndGroups , groupSnds , divCnsnts@@ -29,6 +30,8 @@ , createSyllablesUkrS , notEqC , representProlonged+ , showS8+ , showFS -- * With additional data used (probably for speed up) , notEqCTup , divCnsntsTup@@ -51,7 +54,7 @@ -- | Function-predicate 'isVowel1' checks whether its argument is a vowel representation in the 'Sound8' format. isVowel1 :: Sound8 -> Bool-isVowel1 x = x > 0 && x < 7+isVowel1 x = x < 7 {-# INLINE isVowel1 #-} -- | Function-predicate 'isSonorous1' checks whether its argument is a sonorous consonant representation in the 'Sound8' format.@@ -70,10 +73,18 @@ {-# INLINE isVoicelessC1 #-} -- | Binary function-predicate 'isNotVowel2' checks whether its arguments are both consonant representations in the 'Sound8' format.+-- Starting from the version 0.6.0.0 variants of either of arguments is greater than 99 is also included. isNotVowel2 :: Sound8 -> Sound8 -> Bool isNotVowel2 x y = x > 6 && y > 6 {-# INLINE isNotVowel2 #-} +-- | Binary function-predicate 'isNotVowel2'' checks whether its arguments are both consonant representations in the 'Sound8' format.+-- Starting from the version 0.6.0.0 variants of either of arguments is greater than 99 are not included (so its behaviour is equivalent to the+-- 'isNotVowel2' till the 0.5.3.0 version).+isNotVowel2' :: Sound8 -> Sound8 -> Bool+isNotVowel2' x y = x < 100 && y < 100 && x > 6 && y > 6+{-# INLINE isNotVowel2' #-}+ -- | Function 'sndGroups' converts a Ukrainian word being a list of 'Sound8' to the list of phonetically similar (consonants grouped with consonants and each vowel separately) -- sounds representations in 'Sound8' format. sndGroups :: FlowSound -> [FlowSound]@@ -88,29 +99,55 @@ -- The phonetical information for the proper performance is taken from the: -- https://msn.khnu.km.ua/pluginfile.php/302375/mod_resource/content/1/%D0%9B.3.%D0%86%D0%86.%20%D0%A1%D0%BA%D0%BB%D0%B0%D0%B4.%D0%9D%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D1%81.pdf divCnsnts :: FlowSound -> (FlowSound -> FlowSound,FlowSound -> FlowSound)-divCnsnts xs@(x:ys@(_:_:_:_))- | isSonorous1 x || isVoicedC1 x = ((`mappend` [x]),mappend ys)+divCnsnts xs@(x:ys@(y:zs@(z:ts@(_:_))))+ | isSonorous1 x || isVoicedC1 x =+ case y of+ 7 -> ((`mappend` [x,7]),mappend zs) -- "рибаль-ство"+ _ -> ((`mappend` [x]),mappend ys)+ | isSonorous1 y =+ case z of+ 7 -> ((`mappend` [x,y,7]),mappend ts) -- "рокль-ський" (?), "супрасль-ський"+ _ -> ((`mappend` [x,y]),mappend zs) -- "дофр-ський" (?) | otherwise = (id,mappend xs)-divCnsnts xs@(x:ys@(y:zs@(_:_)))- | isSonorous1 x = ((`mappend` [x]),mappend ys)- | isSonorous1 y = ((`mappend` [x,y]),mappend zs)+divCnsnts xs@(x:ys@(y:zs@(z:ts)))+ | isSonorous1 x =+ case y of+ 7 -> ((`mappend` [x,7]),mappend zs) -- "поль-ка", "каль-ка"+ _ -> ((`mappend` [x]),mappend ys)+ | isSonorous1 y =+ case z of+ 7 -> (id,mappend xs) -- "сього-дні"+ _ -> ((`mappend` [x,y]),mappend zs) | otherwise = (id,mappend xs)-divCnsnts xs@(x:ys@(y:_))- | (isSonorous1 x && (notEqC x y)) || (isVoicedC1 x && isVoicelessC1 y) = ((`mappend` [x]),mappend ys)+divCnsnts xs@(x:ys@(y:zs))+ | (isSonorous1 x && notEqC x y && y /= 7) || (isVoicedC1 x && isVoicelessC1 y) = ((`mappend` [x]),mappend ys) | otherwise = (id,mappend xs) divCnsnts xs = (id,mappend xs) -- | Function 'divCnsntsTup' is a variant of the 'divCnsts' where you can provide the tuple element for 'getBFst'' inside. divCnsntsTup :: Array Int (Int8,Bool) -> FlowSound -> (FlowSound -> FlowSound,FlowSound -> FlowSound)-divCnsntsTup !tup17 xs@(x:ys@(_:_:_:_))- | isSonorous1 x || isVoicedC1 x = ((`mappend` [x]),mappend ys)+divCnsntsTup !tup17 xs@(x:ys@(y:zs@(z:ts@(_:_))))+ | isSonorous1 x || isVoicedC1 x =+ case y of+ 7 -> ((`mappend` [x,7]),mappend zs) -- "рибаль-ство"+ _ -> ((`mappend` [x]),mappend ys)+ | isSonorous1 y =+ case z of+ 7 -> ((`mappend` [x,y,7]),mappend ts) -- "рокль-ський" (?), "супрасль-ський"+ _ -> ((`mappend` [x,y]),mappend zs) -- "дофр-ський" (?) | otherwise = (id,mappend xs)-divCnsntsTup !tup17 xs@(x:ys@(y:zs@(_:_)))- | isSonorous1 x = ((`mappend` [x]),mappend ys)- | isSonorous1 y = ((`mappend` [x,y]),mappend zs)+divCnsntsTup !tup17 xs@(x:ys@(y:zs@(z:ts)))+ | isSonorous1 x =+ case y of+ 7 -> ((`mappend` [x,7]),mappend zs) -- "поль-ка", "каль-ка"+ _ -> ((`mappend` [x]),mappend ys)+ | isSonorous1 y =+ case z of+ 7 -> (id,mappend xs) -- "сього-дні"+ _ -> ((`mappend` [x,y]),mappend zs) | otherwise = (id,mappend xs) divCnsntsTup !tup17 xs@(x:ys@(y:_))- | (isSonorous1 x && (notEqCTup tup17 x y)) || (isVoicedC1 x && isVoicelessC1 y) = ((`mappend` [x]),mappend ys)+ | (isSonorous1 x && (notEqCTup tup17 x y) && y /= 7) || (isVoicedC1 x && isVoicelessC1 y) = ((`mappend` [x]),mappend ys) | otherwise = (id,mappend xs) divCnsntsTup _ xs = (id,mappend xs) @@ -134,12 +171,7 @@ where (ys,zs) = span (>6) us createSyllablesUkrS :: String -> [[FlowSound]]-createSyllablesUkrS = map (divVwls . reSyllableCntnts . groupSnds) . words1 . convertToProperUkrainianI8 .- map (\x -> if x == '-' then ' ' else x)- where words1 xs = if null ts then [] else w : words1 s'' -- Practically this is an optimized version for this case 'words' function from Prelude.- where ts = dropWhile (< 1) xs- (w, s'') = span (> 0) ts- {-# NOINLINE words1 #-}+createSyllablesUkrS = map (divVwls . reSyllableCntnts . groupSnds) . words1 . convertToProperUkrainianI8 {-# INLINE createSyllablesUkrS #-} createSyllablesUkrSTup@@ -164,14 +196,16 @@ -> [[FlowSound]] createSyllablesUkrSTup !tup1 !tup2 !tup3 !tup4 !tup5 !tup6 !tup7 !tup8 !tup9 !tup10 !tup11 !tup12 !tup13 !tup14 !tup15 !tup16 !tup17 = map (divVwls . reSyllableCntntsTup tup17 . groupSnds) . words1 .- convertToProperUkrainianI8WithTuples tup1 tup2 tup3 tup4 tup5 tup6 tup7 tup8 tup9 tup10 tup11 tup12 tup13 tup14 tup15 tup16 .- map (\x -> if x == '-' then ' ' else x)- where words1 xs = if null ts then [] else w : words1 s'' -- Practically this is an optimized version for this case 'words' function from Prelude.- where ts = dropWhile (< 1) xs- (w, s'') = span (> 0) ts- {-# NOINLINE words1 #-}+ convertToProperUkrainianI8WithTuples tup1 tup2 tup3 tup4 tup5 tup6 tup7 tup8 tup9 tup10 tup11 tup12 tup13 tup14 tup15 tup16 {-# INLINE createSyllablesUkrSTup #-} +-- | Practically this is an optimized version for this case 'words' function from Prelude.+words1 :: FlowSound -> [FlowSound]+words1 xs = if null ts then [] else w : words1 s'' + where ts = dropWhile (> 99) xs+ (w, s'') = span (< 100) ts+{-# NOINLINE words1 #-}+ ----------------------------------------------------- -- | Binary function-predicate 'notEqC' checks whether its arguments are not the same consonant sound representations (not taking palatalization into account).@@ -220,3 +254,16 @@ | not . notEqC x $ y = y:representProlonged xs | otherwise = x:representProlonged (y:xs) representProlonged xs = xs++showS8 :: Sound8 -> String+showS8 = getBFstLSorted' " " [(1,"\1072"),(2,"\1077"),(3,"\1086"),(4,"\1091"),(5,"\1080"),(6,"\1110"),(7,"\1100"),(8,"\1076\1079"),+ (9,"\1076\1079"),(10,"\1078"),(11,"\1078"),(15,"\1073"),(16,"\1073"),(17,"\1076"),(18,"\1076"),(19,"\1169"),(20,"\1169"),+ (21,"\1075"),(22,"\1075"),(23,"\1076\1078"),(24,"\1076\1078"),(25,"\1079"),(26,"\1079"),(27,"\1081"),(28,"\1083"),(29,"\1083"),+ (30,"\1084"),(31,"\1084"),(32,"\1085"),(33,"\1085"),(34,"\1088"),(35,"\1088"),(36,"\1074"),(37,"\1074"),(38,"\1094"),+ (39,"\1095"),(40,"\1095"),(41,"\1096"),(42,"\1096"),(43,"\1092"),(44,"\1092"),(45,"\1082"),(46,"\1082"),(47,"\1087"),+ (48,"\1087"),(49,"\1089"),(50,"\1090"),(51,"\1090"),(52,"\1093"),(53,"\1093"),(54,"\1089\1100"),(66,"\1094\1100")]+{-# INLINABLE showS8 #-}++showFS :: FlowSound -> String+showFS = concatMap showS8 -- Probably, it is better to transform several consequent spaces into the combination smth like \", \" (but not in this version)+{-# INLINE showFS #-}
Melodics/Ukrainian/ArrInt8.hs view
@@ -127,6 +127,12 @@ UZ \'z\' D з (plain) 25 UZ \'z\' K з (palatalized) 26 @++Starting from the version 0.6.0.0:++-2 -> 102+-1 -> 101+0 -> 100 -} convertToProperUkrainianI8 :: String -> FlowSound convertToProperUkrainianI8 =@@ -152,13 +158,13 @@ (39, чT),(41, шT),(43, фT), (45, кT),(47, пT),(49, сT tup8 tup9 tup10),(50, тT tup8 tup11 tup10), (52, хT),(54, сьT),(62, нтT),(63, стT),(64, тьT),(66, цьT)] !tup12 = listArray (0,6) [(12,[8,7]),(13,[25,7]),(14,[17,7]),(62,[32,50]),(63,[49,50]),(64,[50,7]), (65,[32,7])]- !tup13 = listArray (0,36) [('\'',-2),('-',-1),('\700',60),('\1072',1),('\1073',15),('\1074',36),('\1075',21),+ !tup13 = listArray (0,36) [('\'',102),('-',101),('\700',60),('\1072',1),('\1073',15),('\1074',36),('\1075',21), ('\1076',17),('\1077',2),('\1078',10),('\1079',25),('\1080',5),('\1081',27),('\1082',45),('\1083',28), ('\1084',30),('\1085',32),('\1086',3),('\1087',47),('\1088',34),('\1089',49),('\1090',50),('\1091',4), ('\1092',43),('\1093',52),('\1094',38),('\1095',39),('\1096',41),('\1097',55),('\1100',7),('\1102',56), ('\1103',57),('\1108',58),('\1110',6),('\1111',59),('\1169',19),('\8217',61)]- !tup14 = listArray (0,8) [(-2,[-1]),(-1,[-1]),(55,[41,39]),(56,[27,4]),(57,[27,1]),(58,[27,2]),(59,[27,6]),- (60,[-1]),(61,[-1])]+ !tup14 = listArray (0,8) [(55,[41,39]),(56,[27,4]),(57,[27,1]),(58,[27,2]),(59,[27,6]),+ (60,[101]),(61,[101]),(101,[101]),(102,[101])] !tup15 = listArray (0,15) [('\'',True),('-',True),('\700',True),('\1028',True),('\1030',True),('\1031',True), ('\1068',True),('\1100',True),('\1102',True),('\1103',True),('\1108',True),('\1110',True),('\1111',True), ('\1168',True),('\1169',True),('\8217',True)]@@ -200,11 +206,12 @@ changeIotated :: Array Int (Char,Bool) -> String -> String changeIotated !tup16 (x:y:zs) | (y `elem` ("\1102\1103\1108\1110"::String)) && isConsNotJTup tup16 x = x:'\1100':(case y of { '\1102' -> '\1091' ; '\1103' -> '\1072' ; '\1108' -> '\1077' ; ~r -> '\1110' }):changeIotated tup16 zs+ | x == '\'' || x == '\x2019' || x == '\x02BC' || x == '-' = if (y `elem` ("\1102\1103\1108\1110"::String)) then '\1081':(case y of { '\1102' -> '\1091' ; '\1103' -> '\1072' ; '\1108' -> '\1077' ; ~r -> '\1110' }):changeIotated tup16 zs else changeIotated tup16 (y:zs) | otherwise = x:changeIotated tup16 (y:zs) changeIotated _ xs = xs filterUkr :: Array Int (Char,Int8) -> String -> FlowSound-filterUkr tup13 = let !tup = (0, tup13) in map (getBFst' tup)+filterUkr tup13 = let !tup = (100, tup13) in map (getBFst' tup) secondConv :: Array Int (Int8,[Int8]) -> FlowSound -> FlowSound secondConv tup14 = concatMap (\y -> getBFst' ([y], tup14) y)@@ -218,7 +225,7 @@ initialA :: Array Int (Int8,Bool) -> Array Int (Int8,Bool) -> Array Int ([Int8],Bool) -> FlowSound -> [FlowSound] initialA tup3 tup4 tup5 t1@(t:ts)- | t < 1 = [0]:initialA tup3 tup4 tup5 ts+ | t < 1 || t > 99 = [100]:initialA tup3 tup4 tup5 ts | getBFst' (True, tup3) t = [t]:initialA tup3 tup4 tup5 ts | getBFst' (False, tup4) t = let (us,vs) = splitAt 2 t1 in@@ -232,7 +239,7 @@ bsToCharUkr :: Array Int ([Int8],Int8) -> [FlowSound] -> FlowSound bsToCharUkr tup6 zs@(_:_) = map (g tup6) zs where g tup6 ts@(t:_) = getBFst' (t, tup6) ts- g _ _ = -1+ g _ _ = 101 bsToCharUkr _ _ = [] applyChanges@@ -406,7 +413,7 @@ | otherwise = dropFromFT2 (n - 1) (tail ts) takeFromFT_ :: Int -> FlowSound -> FlowSound-takeFromFT_ n = takeFromFT n . filter (>0)+takeFromFT_ n = takeFromFT n . filter (\t -> t > 0 && t < 100) correctA :: Array Int (Int8,[Int8]) -> FlowSound -> FlowSound correctA tup12 = correctSomeW . separateSoftS tup12@@ -417,7 +424,7 @@ correctSomeW :: FlowSound -> FlowSound correctSomeW (x:y:z:xs@(t:ys)) | x == 50 && y == 7 && z == 54 && t == 1 = 66:66:1:correctSomeW ys- | (x < 1) && y == 27 && z == 1 =+ | (x > 99) && y == 27 && z == 1 = if take 2 xs == [39,32] then x:y:z:41:correctSomeW ys else x:correctSomeW (y:z:xs)@@ -426,8 +433,8 @@ correctB :: FlowSound -> FlowSound correctB ys@(x:xs)- | (length . filter (== 0) . takeFromFT2 6 $ ys) > 1 = map (\t -> if t <= 0 then -1 else t) (takeFromFT2 6 ys) ++ correctB (dropFromFT2 6 ys)- | otherwise = (if x < 0 then -1 else x):correctB xs+ | (length . filter (== 100) . takeFromFT2 6 $ ys) > 1 = map (\t -> if t >= 100 then 101 else t) (takeFromFT2 6 ys) ++ correctB (dropFromFT2 6 ys)+ | otherwise = (if x > 100 then 101 else x):correctB xs correctB _ = [] -- | Can be used to map the 'Sound8' representation and the mmsyn6ukr-array files with some recordings.
ukrainian-phonetics-basic-array.cabal view
@@ -2,9 +2,9 @@ -- further documentation, see http://haskell.org/cabal/users-guide/ name: ukrainian-phonetics-basic-array-version: 0.5.3.0+version: 0.6.0.0 synopsis: A library to work with the basic Ukrainian phonetics and syllable segmentation.-description: Rewritten from the mmsyn6ukr and mmsyn7s packages. Comparing to the ukrainian-phonetics-basic package, all the vector-related functionality removed, it also removed from the dependencies and the mmsyn2 is changed to mmsyn2-array. Since 0.4.0.0 version switched to the more optimized Int8-based functionality. The modules that do not use Int8 after ugrading the phonetic-languages-simplified-examples-array to the Int8-based functionality are planned to be moved to the new package.+description: Rewritten from the mmsyn6ukr and mmsyn7s packages. Comparing to the ukrainian-phonetics-basic package, all the vector-related functionality removed, it also removed from the dependencies and the mmsyn2 is changed to mmsyn2-array. Since 0.4.0.0 version switched to the more optimized Int8-based functionality. The old modules with bytestring dependencies since the 0.6.0.0 version moved to the other package ukrainian-phonetics-basic-array-bytestring to reduce the actual dependencies for the phonetic languages concerning packages. homepage: https://hackage.haskell.org/package/ukrainian-phonetics-basic-array license: MIT license-file: LICENSE