mmsyn6ukr 0.3.4.0 → 0.4.0.0
raw patch · 3 files changed
+38/−47 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +3/−0
- Melodics/Ukrainian.hs +34/−46
- mmsyn6ukr.cabal +1/−1
ChangeLog.md view
@@ -39,3 +39,6 @@ * Third version revised E. Fixed issues with the jotted sounds. +## 0.4.0.0 -- 2019-12-05++* Fourth version. Fixed issues with the sound conversions. Now they works properly.
Melodics/Ukrainian.hs view
@@ -16,12 +16,11 @@ ) where import Data.Char-import Data.List (groupBy) import qualified Data.Vector as V import qualified Data.ByteString.Lazy as B-import System.IO +import System.IO import CaseBi (getBFst')-import Data.List.InnToOut.Basic+import Data.List.InnToOut.Basic (mapI, mapI2) import Paths_mmsyn6ukr {-@@ -67,16 +66,18 @@ -- | The function that converts a written Ukrainian text into the sounding in the program phonetical respesentation. -- It is not exact phonetically but you can make for yourself a general imression of the Ukrainian sounding. convertToProperUkrainian :: String -> V.Vector String-convertToProperUkrainian ys = let ks = createTuplesByAnalysis . wasFstConverted . filterUkr $ ys in toVector . correctA $ ks+convertToProperUkrainian ys = toVector . correctA . applyChanges . createTuplesByAnalysis . changeJotted . secondConv . wasFstConverted . filterUkr $ ys filterUkr :: String -> String filterUkr xs = concatMap (\x -> if isUkrainian x then [toLower x] else if isSpace x || isControl x then [x] else []) xs --- Need testing!! It does not work properly!+secondConv :: String -> String+secondConv (y:ys) | if isSpace y then True else isControl y = '1':secondConv ys+ | otherwise = y:secondConv ys+secondConv _ = []+ createTuplesByAnalysis :: String -> [(String, Triple)]-createTuplesByAnalysis x@(y:ys) | isSpace y || isControl y || y == '-' = ("1", Z):createTuplesByAnalysis ys- | getBFst' (False, V.fromList $ zip "\1075\1076\1078\1079\1082\1085\1087\1089\1090\1092\1093\1094\1095\1096" (repeat True)) y = - let ts = changeJotted x in applyChanges . initialA . groupBy isSimilar $ ts+createTuplesByAnalysis x@(y:ys) | getBFst' (False, V.fromList $ zip "\1075\1076\1078\1079\1082\1085\1087\1089\1090\1092\1093\1094\1095\1096" (repeat True)) y = initialA x | not (null ys) && head ys == '\1081' && isConsNotJ y = case y of '\1089' -> ("\1089\1100", T):createTuplesByAnalysis (tail ys) '\1094' -> ("\1094\1100", T):createTuplesByAnalysis (tail ys)@@ -84,29 +85,26 @@ | otherwise = ([y], Z):createTuplesByAnalysis ys createTuplesByAnalysis _ = [] -canChange :: String -> Triple-canChange ~(x:_) | isSpace x || isControl x || x == '-' = O- | getBFst' (False, V.fromList $ zip "\1075\1076\1078\1079\1082\1085\1087\1089\1090\1092\1093\1094\1095\1096" (repeat True)) x = T- | otherwise = Z+canChange :: Char -> Triple+canChange x | isSpace x || isControl x || x == '-' = O+ | getBFst' (False, V.fromList $ zip "\1075\1076\1078\1079\1082\1085\1087\1089\1090\1092\1093\1094\1095\1096" (repeat True)) x = T+ | otherwise = Z isVoicedObstruent :: String -> Bool isVoicedObstruent xs | not (null xs) = getBFst' (False, V.fromList $ zip ["\1073","\1075","\1076","\1076\1078","\1076\1079","\1078","\1079","\1169"] (repeat True)) xs | otherwise = False -initialA :: [String] -> [(String, Triple)]-initialA (t:ts) | null t = initialA ts- | tu == O = ("_", Z):initialA (tail t:ts)- | (tu == T) = - if getBFst' (False, V.fromList $ zip ["\1076","\1085","\1089","\1090","\1093","\1094"] (repeat True)) ht - then let (us,vs) = splitAt 2 t in +initialA :: String -> [(String, Triple)]+initialA t1@(t:ts) | canChange t == O = ("1", Z):initialA ts+ | canChange t == T = + if getBFst' (False, V.fromList $ zip "\1076\1085\1089\1090\1093\1094" (repeat True)) t+ then let (us,vs) = splitAt 2 t1 in if getBFst' (False, V.fromList $ zip ["\1076\1078","\1076\1079","\1085\1090","\1089\1090","\1089\1100","\1090\1089","\1090\1100","\1093\1075","\1094\1100"] (repeat True)) us- then (us, T):initialA (vs:ts)- else (ht, T):initialA (tail t:ts)- else case (getBFst' (False, V.fromList $ zip ["\1075","\1078","\1079","\1082","\1087","\1092","\1095","\1096"] (repeat True)) ht) of- ~True -> (ht, T):initialA (tail t:ts)- | otherwise = (ht, Z):initialA (tail t:ts)- where ht = [head t]- tu = canChange ht+ then (us, T):initialA (vs)+ else ([t], T):initialA ts+ else case (getBFst' (False, V.fromList $ zip "\1075\1078\1079\1082\1087\1092\1095\1096" (repeat True)) t) of+ ~True -> ([t], T):initialA ts+ | otherwise = ([t], Z):initialA ts initialA _ = [] wasFstConverted :: String -> String@@ -130,22 +128,19 @@ isNotVowel :: Char -> Bool isNotVowel = getBFst' (True, V.fromList $ zip "\1072\1077\1080\1086\1091\1102\1103\1108\1110\1111" (repeat False)) -isSimilar :: Char -> Char -> Bool-isSimilar x y = isNotVowel x && isNotVowel y- applyChanges :: [(String, Triple)] -> [(String, Triple)] applyChanges (z:t:zs) | snd z == T = getBFst' ((fst z, Z), V.fromList . zip ["\1075","\1076","\1076\1079","\1078","\1079","\1082","\1085\1090", "\1087","\1089","\1089\1090","\1089\1100","\1090","\1090\1089","\1090\1100","\1092","\1093","\1093\1075","\1094","\1094\1100","\1095","\1096"] - $ [гT zs, дT zs, дзT zs, жT zs, зT zs, кT zs, - нтT zs, пT zs, сT zs, стT zs, сьT zs, тT zs, тсT zs, тьT zs, - фT zs, хT zs, хгT zs, цT zs, цьT zs, чT zs, шT zs]) (fst z):applyChanges (t:zs)+ $ [гT (t:zs), дT (t:zs), дзT (t:zs), жT (t:zs), зT (t:zs), кT (t:zs), + нтT (t:zs), пT (t:zs), сT (t:zs), стT (t:zs), сьT (t:zs), тT (t:zs), тсT (t:zs), тьT (t:zs), + фT (t:zs), хT (t:zs), хгT (t:zs), цT (t:zs), цьT (t:zs), чT (t:zs), шT (t:zs)]) (fst z):applyChanges (t:zs) | otherwise = z:applyChanges (t:zs) applyChanges [(xs, _)] = [(xs, Z)] applyChanges _ = [] (===) :: Eq a => a -> [a] -> Bool-(===) x ys = or . map (\y -> x == y) $ ys+(===) x ys = any (\y -> x == y) ys -- in the further ??T functions the last (, T) means that it must be afterwards be separated with the soft sign into two tuples (1 additional function in the composition) -- need further processing means that there should be additional checks and may be transformations. May be they can be omitted@@ -240,7 +235,6 @@ тсT :: [(String, Triple)] -> (String, Triple) тсT _ = ("\1094", Z) - тьT :: [(String, Triple)] -> (String, Triple) тьT t1@(_:_) | isVoicedObstruent (takeFromFT_ 2 t1) || isVoicedObstruent (takeFromFT_ 1 t1) = ("\1076\1100", T) | takeFromFT_ 3 t1 == "\1089\1100\1072" = ("\1094\1100", Z)@@ -290,35 +284,29 @@ correctA = correctSomeW . separateSoftS separateSoftS :: [(String, Triple)] -> [(String, Triple)]-separateSoftS xs = mapI (\x -> snd x == T) divideToParts xs+separateSoftS xss = mapI (\x -> snd x == T) divideToParts xss divideToParts :: (String, Triple) -> [(String, Triple)] divideToParts (xs, _) = [(init xs, Z),([last xs], Z)] correctSomeW :: [(String, Triple)] -> [(String, Triple)] correctSomeW (x:y:z:xs) | fst x == "\1094\1100" && fst y == "\1089\1100" && fst z == "\1072" = x:("\1094\1100", Z):z:correctSomeW xs- | fst x == "1" && fst y == "\1081" && fst z == "\1072" = + | (fst x == "1" || fst x == "0") && fst y == "\1081" && fst z == "\1072" = if takeFromFT 2 xs == "\1095\1085" then x:y:z:("\1096", Z):correctSomeW (tail xs) else x:correctSomeW (y:z:xs)- | fst x == "\1090" && fst y == "\1100" && fst z == "\1089\1100" && not (null xs) && (not . null . fst . head $ xs) = - if (fst . head $ xs) == "\1072" - then ("\1094\1100", Z):("\1094\1100", Z):("\1072", Z):correctSomeW (tail xs)- else x:correctSomeW (y:z:xs)+ | otherwise = x:correctSomeW (y:z:xs) correctSomeW zs = zs takeFromFT :: Int -> [(String, Triple)] -> String-takeFromFT n ts | compare n 0 == GT = if null ts - then []- else if compare k n /= LT - then take n ks- else ks ++ takeFromFT (n - length ks) (tail ts)- | otherwise = []+takeFromFT n ts | if compare 0 n /= LT then True else null ts = []+ | compare k n /= LT = take n ks+ | otherwise = ks ++ takeFromFT (n - k) (tail ts) where ks = fst (head ts) k = length ks takeFromFT_ :: Int -> [(String, Triple)] -> String-takeFromFT_ n ts = takeFromFT n (map (\(xs, y) -> (filter (/='_') xs, y)) ts)+takeFromFT_ n ts = takeFromFT n (filter (\(xs, y) -> (xs /= "1" && xs /= "0")) ts) toVector :: [(String, Triple)] -> V.Vector String toVector ts = V.fromList . mapI2 (\x -> not . null . fst $ x) fst (\y -> []) $ ts
mmsyn6ukr.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: mmsyn6ukr-version: 0.3.4.0+version: 0.4.0.0 synopsis: A musical instrument synthesizer or a tool for Ukrainian language listening description: A program can be used as a musical instrument synthesizer or for Ukrainian speech synthesis especially for poets and writers homepage: https://hackage.haskell.org/package/mmsyn6ukr