mmsyn7s 0.6.3.0 → 0.6.4.0
raw patch · 4 files changed
+145/−63 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ MMSyn7.Syllable: createSyllablesP :: [[UZP]] -> [[UZP]]
+ MMSyn7.Syllable: filterC :: (Char -> Bool) -> UZP -> String
+ MMSyn7.Syllable: representProlonged :: [UZP] -> [UZP]
+ MMSyn7.Syllable: sylLengthsP :: [[[UZP]]] -> [[Int]]
+ MMSyn7.Syllable: sylLengthsP2 :: [[[UZP]]] -> [[Int]]
+ MMSyn7.Syllable: syllablesUkrP :: String -> [[[UZP]]]
+ MMSyn7.Syllable: takeWithVP :: [[UZP]] -> [[UZP]]
+ MMSyn7.Syllable: takeWordSP :: Int -> String -> [[[UZP]]]
Files
- CHANGELOG.md +8/−2
- MMSyn7/Syllable.hs +107/−30
- MMSyn7s.hs +29/−30
- mmsyn7s.cabal +1/−1
CHANGELOG.md view
@@ -58,8 +58,14 @@ ## 0.6.2.0 -- 2020-02-28 -* Sixth version revised B. Fixed issue with the not being compiled because of the wrong application of the function in the exceptRead function.+* Sixth version revised B. Fixed issue with the not being compiled because of the wrong application of the function in the 'exceptRead' function. ## 0.6.3.0 -- 2020-02-28 -* Sixth version revised C. Fixed issue with the not being compiled because of the wrong application of the function in the takeWordS function.+* Sixth version revised C. Fixed issue with the not being compiled because of the wrong application of the function in the 'takeWordS' function.++## 0.6.4.0 -- 2020-02-29++* Sixth version revised D. Fixed issue with the 'notEqC' and respectively 'divideConsonants' functions. Added new functions to deal more with UZP datatype and so with+classical sounds in the MMSyn7.Syllable module and respectively in the MMSyn7s and Main modules. Changed the behaviour for "-s2" first command line argument+for mmsyn7s executable. Some minor documentation improvements.
MMSyn7/Syllable.hs view
@@ -19,6 +19,11 @@ , syllablesUkr , takeWordS , sylLengths+ -- ** Working more with UZP format+ , syllablesUkrP+ , takeWordSP+ , sylLengthsP+ , sylLengthsP2 -- * Used internally , createSyllables , divideConsonants@@ -28,6 +33,11 @@ , vecToUZPs , vecWords , uzpsToList+ , representProlonged+ , filterC+ -- ** Working more with UZP format+ , createSyllablesP+ , takeWithVP -- * Auxiliary predicate functions , isNotVowel2 , isSonorous1@@ -66,20 +76,20 @@ show (Voiced xs) = xs show (Voiceless xs) = xs --- | Function 'vecToUZPs' is used to convert a @Vector@ of @String@ representing Ukrainian sounds to a list of 'UZP'.+-- | Function 'vecToUZPs' is used to convert a 'V.Vector' of 'String' representing Ukrainian sounds to a list of 'UZP'. vecToUZPs :: V.Vector String -> [UZP] vecToUZPs v | V.null v = []- | getBFst' (False, (V.fromList . zip ["а","е","и","о","у","і"] $ (replicate 6 True))) . V.unsafeHead $ v = (Vowel (V.unsafeHead v)):vecToUZPs (V.unsafeTail v)- | V.unsafeHead v == "сь" || V.unsafeHead v == "ць" = (VoicelessP2 (V.unsafeHead v)):(vecToUZPs (V.unsafeTail v))- | ((V.null . V.unsafeTail $ v) || (V.unsafeIndex v 1 /= "ь")) && getBFst' (False, V.fromList . zip ["в","й","л","м","н","р"] $ (replicate 6 True)) (V.unsafeHead v) = (Sonorous (V.unsafeHead v)):(if V.null . V.unsafeTail $ v then [] else vecToUZPs (V.unsafeTail v))- | ((V.null . V.unsafeTail $ v) || (V.unsafeIndex v 1 /= "ь")) && getBFst' (False, V.fromList . zip ["б","г","д","дж","дз","ж","з","ґ"] $ (replicate 8 True)) (V.unsafeHead v) = (Voiced (V.unsafeHead v)):(if V.null . V.unsafeTail $ v then [] else vecToUZPs (V.unsafeTail v))- | ((V.null . V.unsafeTail $ v) || (V.unsafeIndex v 1 /= "ь")) = (Voiceless (V.unsafeHead v)):(if V.null . V.unsafeTail $ v then [] else vecToUZPs (V.unsafeTail v))- | getBFst' (False, V.fromList . zip ["в","л","м","н","р"] $ (replicate 5 True)) (V.unsafeHead v) = (SonorousP (V.unsafeHead v)):vecToUZPs (V.unsafeDrop 2 v)- | getBFst' (False, V.fromList . zip ["б","г","д","дж","дз","ж","з","ґ"] $ (replicate 8 True)) (V.unsafeHead v) = (VoicedP (V.unsafeHead v)):vecToUZPs (V.unsafeDrop 2 v)- | otherwise = (VoicelessP (V.unsafeHead v)):vecToUZPs (V.unsafeDrop 2 v)+ | getBFst' (False, (V.fromList . zip ["а","е","и","о","у","і"] $ (replicate 6 True))) . V.unsafeHead $ v = Vowel (V.unsafeHead v):vecToUZPs (V.unsafeTail v)+ | V.unsafeHead v == "сь" || V.unsafeHead v == "ць" = VoicelessP2 (V.unsafeHead v):(vecToUZPs (V.unsafeTail v))+ | ((V.null . V.unsafeTail $ v) || (V.unsafeIndex v 1 /= "ь")) && getBFst' (False, V.fromList . zip ["в","й","л","м","н","р"] $ (replicate 6 True)) (V.unsafeHead v) = Sonorous (V.unsafeHead v):(if V.null . V.unsafeTail $ v then [] else vecToUZPs (V.unsafeTail v))+ | ((V.null . V.unsafeTail $ v) || (V.unsafeIndex v 1 /= "ь")) && getBFst' (False, V.fromList . zip ["б","г","д","дж","дз","ж","з","ґ"] $ (replicate 8 True)) (V.unsafeHead v) = Voiced (V.unsafeHead v):(if V.null . V.unsafeTail $ v then [] else vecToUZPs (V.unsafeTail v))+ | ((V.null . V.unsafeTail $ v) || (V.unsafeIndex v 1 /= "ь")) = Voiceless (V.unsafeHead v):(if V.null . V.unsafeTail $ v then [] else vecToUZPs (V.unsafeTail v))+ | getBFst' (False, V.fromList . zip ["в","л","м","н","р"] $ (replicate 5 True)) (V.unsafeHead v) = SonorousP (V.unsafeHead v):vecToUZPs (V.unsafeDrop 2 v)+ | getBFst' (False, V.fromList . zip ["б","г","д","дж","дз","ж","з","ґ"] $ (replicate 8 True)) (V.unsafeHead v) = VoicedP (V.unsafeHead v):vecToUZPs (V.unsafeDrop 2 v)+ | otherwise = VoicelessP (V.unsafeHead v):vecToUZPs (V.unsafeDrop 2 v) --- | Function 'sndGroups' converts a Ukrainian word being a list of 'UZP' to the list of phonetically similar (consonants with consonants and vowels separately) +-- | Function 'sndGroups' converts a Ukrainian word being a list of 'UZP' to the list of phonetically similar (consonants grouped with consonants and each vowel separately) -- sounds representations in 'UZP' format. sndGroups :: [UZP] -> [[UZP]] sndGroups ys@(_:_) = L.groupBy isNotVowel2 ys@@ -125,10 +135,15 @@ _ -> case y of (Vowel _) -> True- _ -> compare x y /= EQ+ _ -> filterC (/= 'ь') x /= filterC (/= 'ь') y +-- | Auxiliary function used internally in the 'notEqC' function.+filterC :: (Char -> Bool) -> UZP -> String+filterC p t | isVowel1 t = show t+ | otherwise = filter p . show $ t+ -- | Function 'vecWords' similarly to 'Prelude.words' divides a 'V.Vector' of 'String' into list of them, each element of which is a Ukrainian word (or its part --- for dashed and hyphenated words).+-- for dashed and hyphenated words or that ones with an apostrophe). vecWords :: V.Vector String -> [V.Vector String] vecWords v | V.null v = [] | V.unsafeHead v == "-" || V.unsafeHead v == "0" || V.unsafeHead v == "1" = vecWords (V.unsafeTail v)@@ -136,17 +151,18 @@ let (v1, v2) = V.break (\x -> x == "-" || x == "0" || x == "1") v v3 = snd . V.span (\x -> x == "-" || x == "0" || x == "1") $ v2 in v1:vecWords v3 --- | Function 'divideConsonants' is used to divide groups of Ukrainian consonants into two-elements lists that later are made belonging to different neighbour syllables--- if the group is between two vowels in a word. The group must be not empty, but this is not checked.+-- | Function 'divideConsonants' is used to divide groups of Ukrainian consonants into two-elements lists that later are made belonging to+-- different neighbour syllables if the group is between two vowels in a word. The group must be not empty, but this is not checked. -- 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 divideConsonants :: [UZP] -> [[UZP]] divideConsonants xs = case length xs of 1 -> [[],xs] 2 -> if ((isSonorous1 . head $ xs) && (head xs `notEqC` last xs)) || ((isVoicedC1 . head $ xs) && (isVoicelessC1 . head . tail $ xs)) then [[head xs], tail xs] else [[],xs]- 3 -> if isSonorous1 . head $ xs then [[head xs], tail xs]- else if isSonorous1 . head . tail $ xs then [[head xs, head . tail $ xs], [last xs]]- else [[],xs]+ 3 | isSonorous1 . head $ xs -> [[head xs], tail xs]+ | isSonorous1 . head . tail $ xs ->+ [[head xs, head . tail $ xs], [last xs]]+ | otherwise -> [[], xs] _ -> if (isSonorous1 . head $ xs) || (isVoicedC1 . head $ xs) then [[head xs], tail xs] else [[],xs] -- | Function 'groupConsonants' is used to apply 'divideConsonants' to the needed groups of consonants.@@ -155,39 +171,75 @@ -- | Function 'uzpsToList' converts a Ukrainian word being a list of syllables in 'UZP' format to a list of 'String'. uzpsToList :: [[UZP]] -> [String]-uzpsToList xss = map (concatMap show) xss+uzpsToList = map (concatMap show) --- | Function 'createSyllables' takes a prepared Ukrainian word and joins the parts (being a list of @UZP@) so that they constitute syllables.+-- | Function 'createSyllables' takes a prepared Ukrainian word and joins the parts (each one being a list of 'UZP') so that they constitute syllables in the 'String' format. createSyllables :: [[UZP]] -> [String] createSyllables xss = let (tss, vss) = L.span (any isVwl) . takeWithV $ xss in if null tss then [concat . takeWithV $ xss]- else concat [init tss, [last tss ++ concat vss]]+ else init tss ++ [last tss ++ concat vss] --- | Function 'syllablesUkr' actually converts a 'String' to the list of words being segmented into the syllables. If the Ukrainian word being written down contains+-- | Function 'syllablesUkr' actually converts a 'String' to the list of words being segmented into the syllables in the 'String' format. If the Ukrainian word+-- being written down contains an apostrophe or a dash (hyphen) signs (or even both) then they are treated as separators for the distinguished words.+-- This does not influence the syllable structure and so the poetic characteristics of the text.+syllablesUkr :: String -> [[String]]+syllablesUkr = map ( createSyllables . additionalF) . vecWords . convertToProperUkrainian++-- Used internally in the 'syllablesUkr' and 'syllablesUkrP' functions.+additionalF :: V.Vector String -> [[UZP]]+additionalF = groupConsonants . sndGroups . vecToUZPs++-- | Function 'syllablesUkrP' actually converts a 'String' to the list of words being segmented into the syllables in the 'UZP' format. If the Ukrainian word being written down contains -- an apostrophe or a dash (hyphen) signs (or even both) then they are treated as separators for the distinguished words. This does not influence the syllable structure -- and so the poetic characteristics of the text.-syllablesUkr :: String -> [[String]]-syllablesUkr xs = map ( createSyllables . groupConsonants . sndGroups . vecToUZPs) . vecWords . convertToProperUkrainian $ xs+syllablesUkrP :: String -> [[[UZP]]]+syllablesUkrP = map ( createSyllablesP . additionalF) . vecWords . convertToProperUkrainian -- | Function 'takeWithV' is used internally in the 'createSyllables'. takeWithV :: [[UZP]] -> [String]-takeWithV ((x@(t:ts)):ys:xss)- | (isVowel1 t) && (null ys) = show t:takeWithV xss- | (isVowel1 t) && (isVowel1 . head $ ys) = show t:takeWithV (ys:xss)- | (isVowel1 t) = (show t ++ (show . head $ ys)):takeWithV xss+takeWithV (x@(t:_):ys:xss)+ | isVowel1 t && null ys = show t:takeWithV xss+ | isVowel1 t && (isVowel1 . head $ ys) = show t:takeWithV (ys:xss)+ | isVowel1 t = (show t ++ (show . head $ ys)):takeWithV xss | otherwise = (concatMap show x ++ (head . takeWithV $ (ys:xss))):(tail . takeWithV $ (ys:xss)) takeWithV (_:ys:xss) = takeWithV (ys:xss)-takeWithV (x:xs) = map show x+takeWithV (x:_) = map show x takeWithV _ = [] --- | Function 'takeWordS' takes a number (which is its first argument) of the Ukrainian words and represents them as a list of list of 'String', each of which is a syllable.+-- | Function 'takeWithVP' is used internally in the 'createSyllablesP'.+takeWithVP :: [[UZP]] -> [[UZP]]+takeWithVP (x@(t:_):ys:xss)+ | (isVowel1 t) && (null ys) = x:takeWithVP xss+ | (isVowel1 t) && (isVowel1 . head $ ys) = x:takeWithVP (ys:xss)+ | (isVowel1 t) = (x ++ ys):takeWithVP xss+ | otherwise = (x ++ (head . takeWithVP $ (ys:xss))):(tail . takeWithVP $ (ys:xss))+takeWithVP (_:ys:xss) = takeWithVP (ys:xss)+takeWithVP (x:_) = [x]+takeWithVP _ = []++-- | Function 'createSyllablesP' takes a prepared Ukrainian word and joins the parts (each one being a list of 'UZP') so that they constitute syllables in the 'UZP' format.+createSyllablesP :: [[UZP]] -> [[UZP]]+createSyllablesP xss =+ let (tss, vss) = L.span (any isVowel1) . takeWithVP $ xss in+ if null tss+ then [concat . takeWithVP $ xss]+ else init tss ++ [last tss ++ concat vss]++-- | Function 'takeWordS' takes a number (which is its first argument) of the Ukrainian words and represents them as a list of list of 'String', each of which is a syllable+-- in the 'String' format. -- If the Ukrainian word being written down contains an apostrophe or a dash (hyphen) signs (or even both) then they are treated as separators for the distinguished words. -- This does not influence the syllable structure and so the poetic characteristics of the text. takeWordS :: Int -> String -> [[String]]-takeWordS n xs = take n . syllablesUkr $ xs+takeWordS n = take n . syllablesUkr +-- | Function 'takeWordSP' takes a number (which is its first argument) of the Ukrainian words and represents them as a list of list of list of 'UZP', each list of 'UZP' is a syllable.+-- If the Ukrainian word being written down contains an apostrophe or a dash (hyphen) signs (or even both) then they are treated as separators for the distinguished words.+-- This does not influence the syllable structure and so the poetic characteristics of the text.+takeWordSP :: Int -> String -> [[[UZP]]]+takeWordSP n = take n . syllablesUkrP+ -- | Function 'sylLengths' shows number of Ukrainian letters (except 'ь') in the syllables in the text needed to represent a sounding of the text, -- which was previously converted with 'syllablesUkr' function. If the syllable does not contain either sounds "дж" / "дз" or prolonged sounds then this number -- is also a number of sounds in it. @@ -195,3 +247,28 @@ -- This does not influence the syllable structure and so the poetic characteristics of the text. sylLengths :: [[String]] -> [[Int]] sylLengths = fmap (fmap (length . filter (/= 'ь')))++-- | Function 'sylLengthsP' shows number of 'UZP' in the syllables in the text,+-- which was previously converted with 'syllablesUkrP' function. If the syllable does not contain prolonged sounds then this number+-- is also a number of sounds in it. +-- If the Ukrainian word being written down contains an apostrophe or a dash (hyphen) signs (or even both) then they are treated as separators for the distinguished words.+-- This does not influence the syllable structure and so the poetic characteristics of the text.+sylLengthsP :: [[[UZP]]] -> [[Int]]+sylLengthsP = fmap (fmap length)++-- | Function 'sylLengthsP2' shows number of sounds in the syllables in the text,+-- which was previously converted with 'syllablesUkrP' function. +-- If the Ukrainian word being written down contains an apostrophe or a dash (hyphen) signs (or even both) then they are treated as separators for the distinguished words.+-- This does not influence the syllable structure and so the poetic characteristics of the text.+sylLengthsP2 :: [[[UZP]]] -> [[Int]]+sylLengthsP2 = fmap (fmap (length . representProlonged))++-- | Function 'representProlonged' is used internally in the 'sylLengthsP2' function. It converts duplicated consequent in the syllable consonants+-- so that they are represented by just one 'UZP'. After applying the function to the list of 'UZP' being a syllable all groups of duplicated consequent consonants+-- in every syllable are represented with only one 'UZP' respectively.+representProlonged :: [UZP] -> [UZP]+representProlonged (x:y:xs)+ | isVowel1 x = x:representProlonged (y:xs)+ | not . notEqC x $ y = y:representProlonged xs+ | otherwise = x:representProlonged (y:xs)+representProlonged xs = xs
MMSyn7s.hs view
@@ -45,7 +45,7 @@ import Data.Char (isSpace) import qualified Data.Vector as V-import Data.List (sort, nub,(\\),nubBy,groupBy)+import Data.List (sort, nub,(\\),nubBy) import Melodics.Ukrainian (convertToProperUkrainian) import System.Environment (getArgs) import MMSyn7.Syllable@@ -107,11 +107,11 @@ ; putStrLn "which shows what sound representations are needed to be created if every sound is unique; " ; putStrLn " the other beginning is equivalent to the \"0\" behaviour." }- "-v" -> putStrLn "mmsyn7s: version 0.6.3.0"+ "-v" -> putStrLn "mmsyn7s: version 0.6.4.0" "-s" -> let ys = unwords . drop 1 $ texts in do { putStrLn $ "Uniqueness periods: " ++ (show . uniquenessPeriods $ ys) ; putStrLn $ "Possibly unique sounds representations density: " ++ (show . sndsDensity $ ys)- ; putStrLn $ "Number of sounds representation that are enough to cover the text: " ++ (show . countSnds2 $ ys)+ ; putStrLn $ "Number of sounds representations that are enough to cover the text: " ++ (show . countSnds2 $ ys) ; putStrLn $ "Mean for the uniqueness periods list: " ++ (show . uniqPeriodsMean $ ys) ; putStrLn $ "Dispersion for the uniqueness periods list: " ++ (show . uniqPeriodsDispersion $ ys) ; putStrLn $ "Standard quadratic deviation for the uniqueness periods list: " ++ (show . uniqStdQDeviation $ ys)@@ -119,22 +119,21 @@ ; putStrLn $ "The minimum element in the uniqueness periods list: " ++ (show . uniqMin $ ys) } "-s2" -> let n = concat . drop 1 . take 2 $ texts in exceptRead n (drop 2 texts)- "1" -> putStrLn . show . fst . show7s5 . unwords . drop 1 $ texts+ "1" -> print . fst . show7s5 . unwords . drop 1 $ texts "-1" -> putStrLn . snd . show7s5 . unwords . drop 1 $ texts "0" -> putStrLn . show7s2 . unwords . drop 1 $ texts- "2" -> putStrLn . show . show7s8 . unwords . drop 1 $ texts- "3" -> putStrLn . show . show7s6 . unwords . drop 1 $ texts+ "2" -> print . show7s8 . unwords . drop 1 $ texts+ "3" -> print . show7s6 . unwords . drop 1 $ texts _ -> putStrLn . show7s2 . unwords $ texts -- | Is used internally in the 'exceptRead' function. printStatSyl :: String -> [String] -> IO () printStatSyl xs yss = do { let m = read xs :: Int- zss = takeWordS m . unwords $ yss- tss = sylLengths zss - ; putStrLn $ "Syllables in the text: " ++ show zss- ; putStrLn "number of Ukrainian letters (except 'ь') in the syllables in the text "- ; putStrLn $ "needed to represent a sounding of the text: " ++ show tss+ zss = takeWordSP m . unwords $ yss+ tss = sylLengthsP2 zss + ; putStrLn $ "Syllables in the text: " ++ (show . fmap (fmap (concatMap show)) $ zss)+ ; putStrLn $ "Number of the Ukrainian sounds in the syllables in the text: " ++ show tss ; putStrLn "" } @@ -149,18 +148,18 @@ -- | Function takes a Ukrainian text being a @String@ and returns a sorted list of the Ukrainian sounds representations that can be used further in mmsyn7 series of -- programs. show7s :: String -> [String]-show7s xs = sort . nub . V.toList . V.filter (\x -> x /= "-" && x /= "1" && x /= "0") . convertToProperUkrainian $ xs+show7s = sort . nub . V.toList . V.filter (\x -> x /= "-" && x /= "1" && x /= "0") . convertToProperUkrainian -- | Function takes a Ukrainian text being a @String@ and returns a @String@ that shows a sorted list of the Ukrainian sounds representations that can be used further -- in mmsyn7 series of programs. show7s2 :: String -> String-show7s2 xs = show . sort . nub . V.toList . V.filter (\x -> x /= "-" && x /= "1" && x /= "0") . convertToProperUkrainian $ xs+show7s2 = show . sort . nub . V.toList . V.filter (\x -> x /= "-" && x /= "1" && x /= "0") . convertToProperUkrainian -- | Function 'show7s3' takes a Ukrainian text being a @String@ and returns a tuple, the first element of which is a list of Strings that correspond to the Ukrainian -- sounds representations that (except pauses) are unique and are not repeated starting from the beginning of the given text, and the second one is a remainder -- list of Strings starting from the first duplicated non-silent Ukrainian sound representation. show7s3 :: String -> ([String], [String])-show7s3 xs = show7s' . V.toList . convertToProperUkrainian $ xs+show7s3 = show7s' . V.toList . convertToProperUkrainian -- | Function 'eqSnds' compares two non-silent Strings representations for Ukrainian sounds by equality. If one of them is a representation for silence (e. g. pause), -- then the predicate is @False@.@@ -172,7 +171,7 @@ show7s' :: [String] -> ([String],[String]) show7s' zss = let (xss, yss) = splitAt 68 zss- uss = xss \\ (nubBy eqSnds xss)+ uss = xss \\ nubBy eqSnds xss (wss, vss) = if null uss then (xss,[]) else (takeWhile (/= head uss) xss ++ head uss:(takeWhile (/= head uss) . tail . dropWhile (/= head uss) $ xss), dropWhile (/= head uss) . tail . dropWhile (/= head uss) $ xss) in (wss, vss ++ yss)@@ -182,7 +181,7 @@ show7s'' :: [String] -> ([String],[String]) show7s'' zss = let (xss, yss) = splitAt 68 zss- uss = xss \\ (nubBy eqSnds xss)+ uss = xss \\ nubBy eqSnds xss (wss,vss) = if null uss then (xss,[]) else (takeWhile (/= head uss) xss ++ head uss:(takeWhile (/= head uss) . tail . dropWhile (/= head uss) $ xss), dropWhile (/= head uss) . tail . dropWhile (/= head uss) $ xss) in (sort . filter (\x -> x /= "-" && x /= "1" && x /= "0") $ wss,vss ++ yss)@@ -192,25 +191,25 @@ -- the representations for the silence and then sorted in the ascending order), and the second one is a remainder -- list of Strings starting from the first duplicated non-silent Ukrainian sound representation. show7s4 :: String -> ([String], [String])-show7s4 xs = show7s'' . V.toList . convertToProperUkrainian $ xs+show7s4 = show7s'' . V.toList . convertToProperUkrainian -- | Function 'listToString' converts the list of Strings being the sequential Ukrainian sounds representations into the Ukrainian text with whitespaces -- (whitespaces are substituted instead of punctuation symbols, too) and some phonetical conversions. listToString :: [String] -> String-listToString xss =+listToString = concatMap (\t -> case t of "0" -> " " "1" -> " " "-" -> " "- x -> x) xss+ x -> x) -- | The same as @show7s''@, but the second element in the resulting tuple is again the Ukrainian text with whitespaces (whitespaces are substituted -- instead of punctuation symbols, too) and some phonetical conversions. show7s''' :: [String] -> ([String],String) show7s''' zss = let (xss, yss) = splitAt 68 zss- uss = xss \\ (nubBy eqSnds xss)+ uss = xss \\ nubBy eqSnds xss (wss,vss) = if null uss then (xss,[]) else (takeWhile (/= head uss) xss ++ head uss:(takeWhile (/= head uss) . tail . dropWhile (/= head uss) $ xss), dropWhile (/= head uss) . tail . dropWhile (/= head uss) $ xss) in (sort . filter (\x -> x /= "-" && x /= "1" && x /= "0") $ wss, listToString $ vss ++ yss)@@ -221,7 +220,7 @@ -- list of Strings starting from the first duplicated non-silent Ukrainian sound representation with whitespaces (whitespaces are substituted -- instead of punctiuation symbols, too) and some phonetical conversions. show7s5 :: String -> ([String], String)-show7s5 xs = show7s''' . V.toList . convertToProperUkrainian $ xs+show7s5 = show7s''' . V.toList . convertToProperUkrainian -- | Function 'show7s6' takes a Ukrainian text being a @String@ and returns a list of lists of Strings, each latter one of which is obtained for the unique parts of -- the text from the Ukrainian sounds representations point of view. It can show how many and what sound representations are needed to be created to completely cover@@ -233,11 +232,11 @@ -- | Function 'countSnds' counts total number of Strings in the list of list of Strings. It can be successfully used to count how many Ukrainian sounds representations -- are needed to be created to completely cover the given Ukrainian text. It can be used as a some statistics parameter for the text. countSnds :: [[String]] -> Int-countSnds xss = sum . map length $ xss+countSnds = sum . map length -- | Function 'countSnds2' gives the same result as (countSnds . show7s6), but may be is sligtly more efficient in calculation. countSnds2 :: String -> Int-countSnds2 xss = length . filter (\x -> x /= "-" && x /= "1" && x /= "0") . V.toList . convertToProperUkrainian $ xss+countSnds2 = length . filter (\x -> x /= "-" && x /= "1" && x /= "0") . V.toList . convertToProperUkrainian -- | Function 'sndsDensity' counts the ratio of total number of Ukrainian sounds representations (each of which gives an opportunity to use unique ones) to the -- total number of the Ukrainian sounds representations if all the non-silent sounds in the text are the same for the one sound representation no matter where it is@@ -245,7 +244,7 @@ -- is needed to be created for the text to create a unique sound for every location alongside the text. If it is equal to 1.0, then every non-silent sound -- in the text appears just once (if at all appears). sndsDensity :: String -> Double-sndsDensity xs | null . filter (not . isSpace) $ xs = 1.0+sndsDensity xs | not . any (not . isSpace) $ xs = 1.0 | otherwise = let x = countSnds . show7s6 $ xs y = length . show7s $ xs in fromIntegral x / fromIntegral y@@ -273,14 +272,14 @@ -- the Ukrainian sounds representations (non-silent ones) being unique and not duplicated alongside the given text starting from the beginning to the end. -- This function provides some important information about the phonetical and in some cases semantical structures of the text. uniquenessPeriods :: String -> [Int]-uniquenessPeriods xs | not . null . filter (not . isSpace) $ xs = map length . show7s6 $ xs+uniquenessPeriods xs | any (not . isSpace) xs = map length . show7s6 $ xs | otherwise = [0::Int] -- | Function 'uniqPeriodsMean' is a mathematical expectation for the list obtained by 'uniquenessPeriods' function. It is a statistic metric. -- It is a mean for the quantities of the unique (not duplicated, not repeated) Ukrainian sounds in the given Ukrainian text as a @String@. -- If there are no Ukrainian letters in the text, it is equal to 0.0. The greater it is, the more diverse (phonetically) the text is. uniqPeriodsMean :: String -> Double-uniqPeriodsMean xs | not . null . filter (not . isSpace) $ xs = let ys = uniquenessPeriods xs in (fromIntegral . sum $ ys) / (fromIntegral . length $ ys)+uniqPeriodsMean xs | any (not . isSpace) xs = let ys = uniquenessPeriods xs in (fromIntegral . sum $ ys) / (fromIntegral . length $ ys) | otherwise = 0.0 -- | Function 'uniqPeriodsDispersion' is a dispersion for the list obtained by 'uniquenessPeriods' function. It is a statistic metric.@@ -288,7 +287,7 @@ -- If there are no Ukrainian letters in the text, it is equal to 0.0. The greater it is, the more suitable for changing pronunciation for the sounds -- (and may be for intonation changes, too) the text is. uniqPeriodsDispersion :: String -> Double-uniqPeriodsDispersion xs | not . null . filter (not . isSpace) $ xs =+uniqPeriodsDispersion xs | any (not . isSpace) xs = let ys = uniquenessPeriods xs z = uniqPeriodsMean xs l = length ys in@@ -300,16 +299,16 @@ -- If there are no Ukrainian letters in the text, it is equal to 0.0. The greater it is, the more suitable for changing pronunciation for the sounds -- (and may be for intonation changes, too) the text is. uniqStdQDeviation :: String -> Double-uniqStdQDeviation xs = sqrt . uniqPeriodsDispersion $ xs+uniqStdQDeviation = sqrt . uniqPeriodsDispersion -- | Function 'uniqMax' is a maximum element in the 'uniquenessPeriods' function for the same argument. It is provided as a standard element for the -- descriptive statistics. uniqMax :: String -> Int-uniqMax xs | not . null . filter (not . isSpace) $ xs = maximum . uniquenessPeriods $ xs+uniqMax xs | any (not . isSpace) xs = maximum . uniquenessPeriods $ xs | otherwise = 0::Int -- | Function 'uniqMin' is a minimum element in the 'uniquenessPeriods' function for the same argument. It is provided as a standard element for the -- descriptive statistics. uniqMin :: String -> Int-uniqMin xs | not . null . filter (not . isSpace) $ xs = minimum . uniquenessPeriods $ xs+uniqMin xs | any (not . isSpace) xs = minimum . uniquenessPeriods $ xs | otherwise = 0::Int
mmsyn7s.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: mmsyn7s-version: 0.6.3.0+version: 0.6.4.0 synopsis: Shows a sorted list of the Ukrainian sounds representations that can be used by mmsyn7 series of programs description: A program and a library that show a sorted list of the Ukrainian sounds representations that can be used by mmsyn7 series of programs homepage: https://hackage.haskell.org/package/mmsyn7s