packages feed

mmsyn7s 0.5.0.2 → 0.6.0.0

raw patch · 4 files changed

+94/−36 lines, 4 filesdep +mmsyn2dep +mmsyn5

Dependencies added: mmsyn2, mmsyn5

Files

CHANGELOG.md view
@@ -45,3 +45,9 @@ ## 0.5.0.2 -- 2020-02-26  * Fifth version revised B. Fixed issue with the version number.++## 0.6.0.0 -- 2020-02-28++* Sixth version. Added packages mmsyn2 and mmsyn5 as a dependencies explicitly (earlier they wele as implicit dependencies because they are dependencies for+mmsyn6ukr). Added the module MMSyn7.Syllable and the instruments to work with syllables. Added ghc-options for mmsyn7s.cabal file. Added some performance+improvements to the previous code. Some grammar issues fixed.
MMSyn7s.hs view
@@ -31,8 +31,9 @@   , eqSnds   -- *** Inner backward conversion function   , listToString-  -- * Some descriptive statistics metrics+  -- * Some descriptive statistics metrices   , countSnds+  , countSnds2   , sndsDensity   , uniquenessPeriods   , uniqMax@@ -44,9 +45,11 @@  import Data.Char (isSpace) import qualified Data.Vector as V-import Data.List (sort, nub,(\\),nubBy)+import Data.List (sort, nub,(\\),nubBy,groupBy) import Melodics.Ukrainian (convertToProperUkrainian) import System.Environment (getArgs)+import MMSyn7.Syllable+import Control.Exception (onException)  -- | Function takes the first command line argument and (may be) a Ukrainian text being written without quotes as the next command line arguments -- and prints the sorted list of the Ukrainian sounds representations that can be used further in mmsyn7 series of programs.@@ -58,17 +61,20 @@ -- \"-v\" -- prints version number and exits; -- -- \"-s\" -- prints some general descriptive statistics metrices for the given text; +--+-- \"-s2\" -- prints a syllable segmentation for the {number of words (or their parts) to be taken for statistics, which is a second command line argument} and +-- some information about its structure that can be interesting. --  -- \"1\"  -- prints the list of String being unique (without silence) and then the rest of the text with whitespaces and some phonetical conversions; --  -- \"-1\" -- prints the rest of the text after the first duplicated sound representation (except silent ones) including it with whitespaces and some phonetical conversions; -- --- \"0\"  -- prints the list of String for the whole text.+-- \"0\"  -- prints the list of String being the Ukrainian sounds representations for the whole text. ----- \"2\"  -- prints the list of String for the whole text where every sound representation is unique; +-- \"2\"  -- prints the list of String being the Ukrainian sounds representations for the whole text where every sound representation is unique;  ----- \"3\"  -- prints the list of lists of Strings for the whole text, which shows what sound representations are needed to be --- created if every sound is unique;+-- \"3\"  -- prints the list of lists of Strings being the Ukrainian sounds representations for the whole text, which shows what sound representations+-- are needed to be created if every sound is unique; --  -- All other variants of the beginning for the command line arguments are the same as \"0\" (the arguments are treated as a Ukrainian text -- and processed as a whole one object).@@ -82,6 +88,7 @@                  ; putStrLn "mmsyn7s -h      OR: "                  ; putStrLn "mmsyn7s -v      OR: "                  ; putStrLn "mmsyn7s -s {Ukrainian text}     OR: "+                 ; putStrLn "mmsyn7s -s2 {number of words (or their parts) to be taken for statistics} {Ukrainian text}     OR: "                  ; putStrLn "mmsyn7s 1 {Ukrainian text}     OR: "                  ; putStrLn "mmsyn7s -1 {Ukrainian text}     OR: "                  ; putStrLn "mmsyn7s 0 {Ukrainian text}     OR: "@@ -89,32 +96,55 @@                  ; putStrLn "where the first one prints this help message; "                  ; putStrLn "      the second one prints a version number; "                  ; putStrLn "      the third one prints some general descriptive statistics metrices for the given text; "-                 ; putStrLn "      the \"1\" option prints the list of String being unique (without silence);"+                 ; putStr "      the fourth one prints a syllable segmentation for the {number of words (or their parts) to be taken for statistics} and "+                 ; putStrLn "some information about its structure that can be interesting."+                 ; putStrLn "      the \"1\" option prints the list of String being the Ukrainian sounds representations and being unique alongside the text (without silence);"                  ; putStr   "      the \"-1\" option prints the rest of the text after the first duplicated sound representation (except silent ones); "                  ; putStrLn "including it with whitespaces and some phonetical conversions; "-                 ; putStrLn "      the \"0\" option prints the list of String for the whole text; "-                 ; putStrLn "      the \"2\" option prints the list of String for the whole text where every sound representation is unique; "-                 ; putStr "      the \"3\" option prints the list of lists of Strings for the whole text, which shows what sound representations are needed to be "-                 ; putStrLn "created if every sound is unique; "-                 ; putStrLn "      the other beginning is equivalent to the previous one behaviour."+                 ; putStrLn "      the \"0\" option prints the list of String  being the Ukrainian sounds representations for the whole text; "+                 ; putStrLn "      the \"2\" option prints the list of String  being the Ukrainian sounds representations for the whole text where every sound representation is unique; "+                 ; putStr "      the \"3\" option prints the list of lists of Strings  being the Ukrainian sounds representations for the whole text, "+                 ; 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.5.0.2"+      "-v" -> putStrLn "mmsyn7s: version 0.6.0.0"       "-s" -> let ys = unwords . drop 1 $ texts in-                do { putStrLn $ "Possibly unique sounds representations density:                      " ++ (show . sndsDensity $ ys)-                   ; putStrLn $ "Number of sounds representation that are enough to cover the text:   " ++ (show . countSnds . show7s6 $ ys)-                   ; putStrLn $ "Uniqueness periods:                                                  " ++ (show . uniquenessPeriods $ ys)-                   ; putStrLn $ "Mean for uniqueness periods list:                                    " ++ (show . uniqPeriodsMean $ ys)-                   ; putStrLn $ "Dispersion for uniqueness periods list:                              " ++ (show . uniqPeriodsDispersion $ ys)-                   ; putStrLn $ "Standard quadratic deviation for uniqueness periods list:            " ++ (show . uniqStdQDeviation $ ys)-                   ; putStrLn $ "The maximum element in the uniqueness periods list:                  " ++ (show . uniqMax $ ys)-                   ; putStrLn $ "The minimum element in the uniqueness periods list:                  " ++ (show . uniqMin $ ys)+                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 $ "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)+                   ; putStrLn $ "The maximum element in the uniqueness periods list:                      " ++ (show . uniqMax $ ys)+                   ; 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" -> 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       _    -> 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 . syllablesUkr $ 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+     ; putStrLn ""+     }++-- | Is used internally in the 'mmsyn7s' function.+exceptRead :: String -> [String] -> IO ()+exceptRead xs yss = onException (printStatSyl xs yss)+  (do { putStrLn "Please, specify a number of words (or their parts being created with apostrophe or dash (hyphen) signs (or both)) "+      ; ns <- getLine+      ; exceptRead ns yss+      })    -- | 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.@@ -165,7 +195,7 @@ show7s4 xs = show7s'' . V.toList . convertToProperUkrainian $ xs  -- | Function 'listToString' converts the list of Strings being the sequential Ukrainian sounds representations into the Ukrainian text with whitespaces--- (whitespaces are substituted instead of punctiuation symbols, too) and some phonetical conversions.+-- (whitespaces are substituted instead of punctuation symbols, too) and some phonetical conversions. listToString :: [String] -> String listToString xss =   concatMap (\t ->@@ -176,7 +206,7 @@       x   -> x) xss  -- | The same as @show7s''@, but the second element in the resulting tuple is again the Ukrainian text with whitespaces (whitespaces are substituted--- instead of punctiuation symbols, too) and some phonetical conversions.+-- instead of punctuation symbols, too) and some phonetical conversions. show7s''' :: [String] -> ([String],String) show7s''' zss =   let (xss, yss) = splitAt 68 zss@@ -205,11 +235,15 @@ countSnds :: [[String]] -> Int countSnds xss = sum . map length $ xss --- | Function 'sndsDensity' counts the ratio of total number of Ukrainian sounds representations (each of which gives an opportunity to use a unique ones) to the+-- | 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++-- | 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 -- located. It can be used as a some statistics parameter for the text. The greater is the result, the greater number of the Ukrainian sounds representations -- 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 any).+-- in the text appears just once (if at all appears). sndsDensity :: String -> Double sndsDensity xs | null . filter (not . isSpace) $ xs = 1.0                | otherwise =@@ -242,14 +276,14 @@ uniquenessPeriods xs | not . null . filter (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 metrics.+-- | 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) is the text.+-- 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)                    | otherwise = 0.0 --- | Function 'uniqPeriodsDispersion' is a dispersion for the list obtained by 'uniquenessPeriods' function. It is a statistic metrics.+-- | Function 'uniqPeriodsDispersion' is a dispersion for the list obtained by 'uniquenessPeriods' function. It is a statistic metric. -- It is a dispersion 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 suitable for changing pronunciation for the sounds  -- (and may be for intonation changes, too) the text is.@@ -261,7 +295,7 @@         (sum . map (\t -> (fromIntegral t - z) * (fromIntegral t - z)) $ ys) / fromIntegral l                          | otherwise = 0.0 --- | Function 'uniqStdQDeviation' is a standard quadratic deviation for the list obtained by 'uniquenessPeriods' function. It is a statistic metrics.+-- | Function 'uniqStdQDeviation' is a standard quadratic deviation for the list obtained by 'uniquenessPeriods' function. It is a statistic metric. -- It is a standard quadratic deviation 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 suitable for changing pronunciation for the sounds -- (and may be for intonation changes, too) the text is.
README.markdown view
@@ -1,18 +1,24 @@         ***** Usage *****         ----------------- -The package provides a library functions and the executable. The executable+The package provides library functions and an executable. The executable takes the first command line argument and (may be) a Ukrainian text being written without quotes as the next command line arguments and prints the sorted list of the Ukrainian sounds representations-that can be used further in mmsyn7 series of programs.+(or something equivalent, see command line arguments) that can be used+further in mmsyn7 series of programs (or independently).  Depending on the first command line argument the program behaves as follows:  "-h" -- prints help and exits; -"-s" -- prints some general descriptive statistics metrices for the given text; +"-s" -- prints some general descriptive statistics metrices for the given text; +"-s2" -- prints syllable segmentation for the {number of words+(or their parts) to be taken for statistics, which is a second+command line argument} and some information about its structure+that can be interesting;+ "-v" -- prints version number and exits;  "-1" -- prints the rest of the text after the first duplicated sound@@ -32,7 +38,17 @@  All other variants of the beginning for the command line arguments are the same as "0" (the arguments are treated as a Ukrainian text-and processed as a whole one object).        +and processed as a whole one object).++                  ***** Syllable Segmentation *****+                  ---------------------------------++The program (and the library) can be used to obtain information about+syllable segmentation of the Ukrainian text. For more information,+please, refer to the above information about the "-s2" first command+line argument and to the documentation for the MMSyn7.Syllable module.++ ________________  The resulting Strings and lists of Strings can be used further in the programs:
mmsyn7s.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mmsyn7s-version:             0.5.0.2+version:             0.6.0.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@@ -20,14 +20,16 @@   exposed-modules:     MMSyn7s, Main   -- other-modules:   -- other-extensions:-  build-depends:       base >=4.7 && <4.14, vector >=0.11 && <0.14, mmsyn6ukr >=0.6.2 && <1+  build-depends:       base >=4.7 && <4.14, vector >=0.11 && <0.14, mmsyn6ukr >=0.6.2 && <1, mmsyn2 >=0.1.7.0 && < 1, mmsyn5 >=0.4.2.2  && < 1   -- hs-source-dirs:   default-language:    Haskell2010+  ghc-options:         -O2  executable mmsyn7s   main-is:             Main.hs   -- other-modules:   -- other-extensions:-  build-depends:       base >=4.7 && <4.14, vector >=0.11 && <0.14, mmsyn6ukr >=0.6.2 && <1+  build-depends:       base >=4.7 && <4.14, vector >=0.11 && <0.14, mmsyn6ukr >=0.6.2 && <1, mmsyn2 >=0.1.7.0 && < 1, mmsyn5 >=0.4.2.2  && < 1   -- hs-source-dirs:   default-language:    Haskell2010+  ghc-options:         -O2