uniqueness-periods-vector-examples 0.6.1.0 → 0.7.0.0
raw patch · 3 files changed
+75/−64 lines, 3 filesdep ~uniqueness-periods-vector-commondep ~uniqueness-periods-vector-general
Dependency ranges changed: uniqueness-periods-vector-common, uniqueness-periods-vector-general
Files
- ChangeLog.md +23/−17
- Proportion/Main.hs +46/−41
- uniqueness-periods-vector-examples.cabal +6/−6
ChangeLog.md view
@@ -6,24 +6,24 @@ ## 0.1.2.0 -- 2020-09-11 -* First version revised B. Changed the dependency boundaries for the uniqueness-periods-vector-general package. +* First version revised B. Changed the dependency boundaries for the uniqueness-periods-vector-general package. ## 0.1.3.0 -- 2020-09-12 -* First version revised C. Changed the dependency boundaries for some changed packages from the uniqueness-periods-vector series. Made the needed code changes. +* First version revised C. Changed the dependency boundaries for some changed packages from the uniqueness-periods-vector series. Made the needed code changes. ## 0.2.0.0 -- 2020-09-13 -* Second version. Changed the dependency boundaries of the uniqueness-periods-vector-general package. Added a new executable uniqVec02. +* Second version. Changed the dependency boundaries of the uniqueness-periods-vector-general package. Added a new executable uniqVec02. ## 0.3.0.0 -- 2020-09-15 -* Third version. Added a new executable uniqVec03. It tests a hypothesis that for many Ukrainian poems (for example, by Oleksandr Oles) the actual -diverse2 output lies close between midpoint between the minimum and maximum possible for that line values. +* Third version. Added a new executable uniqVec03. It tests a hypothesis that for many Ukrainian poems (for example, by Oleksandr Oles) the actual+diverse2 output lies close between midpoint between the minimum and maximum possible for that line values. ## 0.3.1.0 -- 2020-09-15 -* Third version revised A. Some code improvements for uniqVec03 executable for filtering non-Ukrainian texts parts that must not be inlined. +* Third version revised A. Some code improvements for uniqVec03 executable for filtering non-Ukrainian texts parts that must not be inlined. ## 0.3.1.1 -- 2020-09-16 @@ -31,32 +31,38 @@ ## 0.4.0.0 -- 2020-09-17 -* Fourth version. Added a README.md file. Changed the behaviour of the uniqVec03 executable so that it is more accurate and gives more output information. -Added links to results of the processment for the Ukrainian poetic original and translated-into texts. +* Fourth version. Added a README.md file. Changed the behaviour of the uniqVec03 executable so that it is more accurate and gives more output information.+Added links to results of the processment for the Ukrainian poetic original and translated-into texts. ## 0.5.0.0 -- 2020-09-19 -* Fifth version. Added more information to the uniqVec03 output. Now it shows additionally the matrix of the words-per-line x number-of-the-interval in two different ways (the first one is -just a simple visualization in ASCII). Besides, it counts totals on the words-per-line and prints it, added the possibility to change the number of the intervals as the second -command line argument, and made some dependency changing related changes. Changed the dependency bounds for uniqueness-periods-vector-filters package. Added new dependency -of uniqueness-periods-vector-stats package. +* Fifth version. Added more information to the uniqVec03 output. Now it shows additionally the matrix of the words-per-line x number-of-the-interval in two different ways (the first one is+just a simple visualization in ASCII). Besides, it counts totals on the words-per-line and prints it, added the possibility to change the number of the intervals as the second+command line argument, and made some dependency changing related changes. Changed the dependency bounds for uniqueness-periods-vector-filters package. Added new dependency+of uniqueness-periods-vector-stats package. ## 0.5.1.0 -- 2020-09-19 -* Fifth version revised A. Changed the dependency bounds of uniqueness-periods-vector-stats and used function from there in uniqVec03 executable. +* Fifth version revised A. Changed the dependency bounds of uniqueness-periods-vector-stats and used function from there in uniqVec03 executable. ## 0.5.2.0 -- 2020-09-19 -* Fifth version revised B. Fixed issue with parse error for the uniqVec03 executable in the CPP preprocessor. +* Fifth version revised B. Fixed issue with parse error for the uniqVec03 executable in the CPP preprocessor. ## 0.5.3.0 -- 2020-09-20 -* Fifth version revised C. Fixed issue with parsing empty second command line argument (or its absense, actually). +* Fifth version revised C. Fixed issue with parsing empty second command line argument (or its absense, actually). ## 0.6.0.0 -- 2020-09-25 -* Sixth version. Changed dependency boundaries. Added parallel as a new dependency. Switched to parallel version of the uniqVec03 program. Added ghc-options section to the uniqVec03 executable. +* Sixth version. Changed dependency boundaries. Added parallel as a new dependency. Switched to parallel version of the uniqVec03 program. Added ghc-options section to the uniqVec03 executable. ## 0.6.1.0 -- 2020-09-25 -* Sixth version revised A. Changed dependency boundaries. Fixed so issues with the wrong text subpartitions. +* Sixth version revised A. Changed dependency boundaries. Fixed by this issues with the wrong text subpartitions.++## 0.7.0.0 -- 2020-09-28++* Seventh version. Changed dependency boundaries. Fixed multiple issues with the uniqVec03 executable.+Some comments in the code improvements. Introduced two more command line options -- the third and the fourth ones to control whether to print the line of+the text being analyzed and whether to transform the text into a monolythic one-line String before processment respectively.
Proportion/Main.hs view
@@ -5,19 +5,19 @@ -- Stability : Experimental -- Maintainer : olexandr543@yahoo.com ----- Analyzes a poetic text in Ukrainian, for every line prints statistic data and --- then for the whole poem prints the hypothesis evaluation information. Since the 0.4.0.0 version --- the program tries to be more accurate in cases of the lines consisting entirely of the words --- which are unique in phonetic meaning alongside the line. Another hypothesis is that the distribution --- of the placement of the actual poetic text in Ukrainian is not one of the standard distributions. +-- Analyzes a poetic text in Ukrainian, for every line prints statistic data and+-- then for the whole poem prints the hypothesis evaluation information. Since the 0.4.0.0 version+-- the program tries to be more accurate in cases of the lines consisting entirely of the words+-- which are unique in phonetic meaning alongside the line. Another hypothesis is that the distribution+-- of the placement of the actual poetic text in Ukrainian is not one of the standard distributions. -- It can probably have approximately a form of and is different for different authors:--- +-- -- > -- -- -- -- > / \_/ \_/ \--- +-- -- To enable parallel computations (potentially, they can speed up the work), please, run the @uniqVec03@ executable with--- @+RTS -threaded -RTS@ command line options.--- +-- @+RTS -threaded -RTS@ command line options with possibly @-N@ option inside.+-- {-# OPTIONS_GHC -threaded -rtsopts #-} @@ -48,8 +48,8 @@ import Languages.UniquenessPeriods.Vector.Filters import GHC.Float (int2Float) import Data.List (sort)+import Data.Char (isAlpha) import Numeric.Stats- #ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__==708 /* code that applies only to GHC 7.8.* */@@ -60,39 +60,44 @@ main :: IO () main = do args <- getArgs- let file = concat . take 1 $ args- gz = fromMaybe 9 (readMaybe (concat . take 1 . drop 1 $ args)::(Maybe Int))+ let !file = concat . take 1 $ args -- The first command line arguments except those ones that are RTS arguments+ !gz = fromMaybe 9 (readMaybe (concat . take 1 . drop 1 $ args)::(Maybe Int)) -- The second command line arguments except those ones that are RTS arguments+ !printLine = fromMaybe 0 (readMaybe (concat . take 1 . drop 2 $ args)::(Maybe Int)) -- The third command line arguments except those ones that are RTS arguments. Set to 1 if you would like to print the current line within the information+ !toOneLine = fromMaybe 0 (readMaybe (concat . take 1 . drop 3 $ args)::(Maybe Int)) -- The fourth command line arguments except those ones that are RTS arguments. Seti to 1 if you would like to convert the text into one single line before applying to it the processment (it can be more conceptually consistent in such a case) contents <- readFile file- let flines = filter (not . null . filter isUkrainian) . prepareText $ contents- data3 <- mapM (\ts -> do- let (maxE,minE,data2) = runEval ((parTuple3 rpar rseq rseq) ((\k -> if k == 0 then 1 else k) . (\rs -> if null rs then 0 else head rs) . firstFrom3 . maximumElBy 1 (V.singleton (oneProperty)) $ UL2 ([],uniquenessVariants2GN " 01-" (V.singleton (oneProperty)) (uniquenessPeriodsVector3 " 01-" . - aux0 . convertToProperUkrainian) (justOneValue2Property . diverse2) $ ts),- (\k -> if k == 0 then 1 else k) . abs . (\rs -> if null rs then 0 else head rs) . firstFrom3 . maximumElBy 1 (V.singleton (oneProperty)) $ UL2 ([],uniquenessVariants2GN " 01-" (V.singleton (oneProperty)) (uniquenessPeriodsVector3 " 01-" . - aux0 . convertToProperUkrainian) (justOneValue2Property . negate . diverse2) $ ts),- (\k -> if k == 0 then 1 else k) . diverse2 . uniquenessPeriodsVector3 " 01-" . aux0 . convertToProperUkrainian $ ts))- ratio = if maxE == 1 then 0.0 else 2.0 * fromIntegral data2 / fromIntegral (minE + maxE)- [intervalN,wordsN] = runEval ((parList rpar) [if maxE == 1 then 0 else intervalNRealFrac (int2Float minE) (int2Float maxE) gz (int2Float data2),- if maxE == 1 then 0 else length . words $ ts])- putStrLn $ mconcat [show (minE::Int), "\t", show (data2::Int), "\t", show (maxE::Int), "\t", - showFFloat (Just 4) (fromIntegral data2 / fromIntegral minE) "\t", showFFloat (Just 4) (fromIntegral maxE / fromIntegral data2) "\t", - showFFloat (Just 4) ratio "\t", show (wordsN::Int), "\t", show (intervalN::Int)]- return (ratio,(wordsN,intervalN))) $ flines- let (data31,wordsCnt0_data32) = unzip data3 - data4 = filter (/= 0) data31+ let !flines = fLines toOneLine contents+ data3 <- getData3 printLine gz flines+ let !(data31,wordsCnt0_data32) = unzip data3+ !data4 = filter (/= 0) data31 if null data4 then putStrLn (replicate 102 '-') >> putStrLn "1.000+-0.000\tALL!" >> putStrLn (replicate 102 '=') -- Well, this means that all the text consists of the unique (in phonetic meaning) words alongside every line. A rather rare occurrence.- else do + else do let (!mean1,!disp) = meanWithDisp data4- pairs = sort . filter ((/= 0) . snd) $ wordsCnt0_data32- g m n = (length . takeWhile (\(_,v) -> v == n) . dropWhile (\(_,v) -> v /= n) . takeWhile (\(u,_) -> u == m) . dropWhile (\(u,_) -> u /= m) $ pairs) `using` rdeepseq- putStrLn (replicate 102 '-')- mapM_ (\r -> putStr $ show r ++ "\t") [1..gz] >> putStrLn ""- mapM_ (\r -> putStr $ (show . length . takeWhile (== r) . dropWhile (/= r) . sort . map snd $ pairs) ++ "\t") [1..gz] >> putStrLn ""- putStrLn $ showFFloat (Just 4) mean1 "+-" ++ showFFloat (Just 4) (sqrt disp) "\t" ++ show (length . filter (== 0) $ data31) ++ "\t" ++ show (length data3)- mapM_ (\r -> putStr $ show r ++ "\t") [2..8] >> putStrLn ""- mapM_ (\r -> putStr $ (show . length . takeWhile (== r) . dropWhile (/= r) . map fst $ pairs) ++ "\t") [2..8] >> putStrLn ""- putStrLn (replicate 102 '*')- mapM_ (\m1 -> mapM_ (\n1 -> putStr $ (if g m1 n1 == 0 then "." else show (g m1 n1)) ++ "\t") [1..gz] >> putStrLn "") [2..8]+ !pairs = sort . filter ((/= 0) . snd) $ wordsCnt0_data32+ g !m !n = (length . takeWhile (\(_,v) -> v == n) . dropWhile (\(_,v) -> v /= n) . takeWhile (\(u,_) -> u == m) . dropWhile (\(u,_) -> u /= m) $ pairs) `using` rseq+ putStrLn . mconcat $ [replicate 102 '-', newLineEnding, mconcat . map (\r -> show r ++ "\t") $ [1..gz], newLineEnding, mconcat . map (\r -> (show . length . takeWhile (== r) . dropWhile (/= r) . sort . map snd $ pairs) ++ "\t") $ [1..gz], newLineEnding, mconcat $ [showFFloat (Just 4) mean1 "+-", showFFloat (Just 4) (sqrt disp) "\t", show (length . filter (== 0) $ data31), '\t':show (length data31)], newLineEnding, mconcat . map (\r -> show r ++ "\t") $ [2..7], newLineEnding, mconcat . map (\r -> (show . length . takeWhile (== r) . dropWhile (/= r) . map fst $ pairs) ++ "\t") $ [2..7], newLineEnding, replicate 102 '*']+ mapM_ (\m1 -> mapM_ (\n1 -> putStr $ (if g m1 n1 == 0 then "." else show (g m1 n1)) ++ "\t") [1..gz] >> putStrLn "") [2..7] putStrLn (replicate 102 '~')- mapM_ (\m1 -> mapM_ (\n1 -> putStr $ show (g m1 n1) ++ "\t") [1..gz] >> putStrLn "") [2..8]+ mapM_ (\m1 -> mapM_ (\n1 -> putStr $ show (g m1 n1) ++ "\t") [1..gz] >> putStrLn "") [2..7] putStrLn (replicate 102 '=')- ++getData3 :: Int -> Int -> [String] -> IO [(Float,(Int,Int))]+getData3 printLine gz = mapM (\ts -> do+ let (!maxE,!minE,!data2) = runEval ((parTuple3 rpar rseq rseq) ((\k -> if k == 0 then 1 else k) . (\rs -> if null rs then 0 else head rs) . firstFrom3 .+ maximumElBy 1 (V.singleton (oneProperty)) $ UL2 ([],uniquenessVariants2GN " 01-" (V.singleton (oneProperty)) (uniquenessPeriodsVector3 " 01-" .+ aux0 . convertToProperUkrainian) (justOneValue2Property . diverse2) $ ts), (\k -> if k == 0 then 1 else k) . abs . (\rs -> if null rs then 0 else head rs) .+ firstFrom3 . maximumElBy 1 (V.singleton (oneProperty)) $ UL2 ([],uniquenessVariants2GN " 01-" (V.singleton (oneProperty))+ (uniquenessPeriodsVector3 " 01-" . aux0 . convertToProperUkrainian) (justOneValue2Property . negate . diverse2) $ ts),+ (\k -> if k == 0 then 1 else k) . diverse2 . uniquenessPeriodsVector3 " 01-" . aux0 . convertToProperUkrainian $ ts))+ !ratio = if maxE == 1 then 0.0 else 2.0 * fromIntegral data2 / fromIntegral (minE + maxE)+ (!wordsN,!intervalN)+ | maxE == 1 = (0, 0)+ | otherwise = runEval ((parTuple2 rpar rpar) (length . words $ ts, intervalNRealFrac (int2Float minE) (int2Float maxE) gz (int2Float data2)))+ putStrLn . mconcat $ [show $ (minE::Int), '\t':show (data2::Int), '\t':show (maxE::Int), '\t':showFFloat (Just 4) (fromIntegral data2 / fromIntegral minE) "\t",+ showFFloat (Just 4) (fromIntegral maxE / fromIntegral data2) "\t", showFFloat (Just 4) ratio "\t", '\t':show (wordsN::Int), '\t':show (intervalN::Int),+ if printLine == 1 then '\t':ts else ""]+ return (ratio,(wordsN,intervalN)))+{-# INLINABLE getData3 #-}++fLines :: Int -> String -> [String]+fLines !toOneLine = filter (any (\x -> isUkrainian x && isAlpha x)) . prepareText . (\z -> if toOneLine == 1 then unwords . words $ z else z)+{-# INLINE fLines #-}
uniqueness-periods-vector-examples.cabal view
@@ -3,9 +3,9 @@ -- http://haskell.org/cabal/users-guide/ name: uniqueness-periods-vector-examples-version: 0.6.1.0-synopsis: Examples of usage for the uniqueness-periods-vector series of packages-description: Examples of usage for the uniqueness-periods-vector series of packages. Several executables are planned to demonstrate the libraries work.+version: 0.7.0.0+synopsis: Usage examples for the uniqueness-periods-vector series of packages+description: Usage examples for the uniqueness-periods-vector series of packages. Several executables are planned to demonstrate the libraries work. homepage: https://hackage.haskell.org/package/uniqueness-periods-vector-examples license: MIT license-file: LICENSE@@ -21,7 +21,7 @@ main-is: Main.hs -- other-modules: -- other-extensions:- build-depends: base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3 && <1, uniqueness-periods-vector-general >=0.4.2 && < 1, uniqueness-periods-vector-common >=0.3 && <1, uniqueness-periods-vector-properties >=0.3.1 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.2 && <1+ build-depends: base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3 && <1, uniqueness-periods-vector-general >=0.4.4 && < 1, uniqueness-periods-vector-common >=0.4 && <1, uniqueness-periods-vector-properties >=0.3.1 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.2 && <1 hs-source-dirs: Simple default-language: Haskell2010 @@ -29,7 +29,7 @@ main-is: Main.hs -- other-modules: -- other-extensions:- build-depends: base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3 && <1, uniqueness-periods-vector-general >=0.4.2 && < 1, uniqueness-periods-vector-common >=0.3 && <1, uniqueness-periods-vector-properties >=0.3.1 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.2 && <1+ build-depends: base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3 && <1, uniqueness-periods-vector-general >=0.4.4 && < 1, uniqueness-periods-vector-common >=0.4 && <1, uniqueness-periods-vector-properties >=0.3.1 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.2 && <1 hs-source-dirs: Lines default-language: Haskell2010 @@ -37,7 +37,7 @@ main-is: Main.hs -- other-modules: other-extensions: CPP, BangPatterns- build-depends: base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3 && <1, uniqueness-periods-vector-general >=0.4.2 && < 1, uniqueness-periods-vector-common >=0.3 && <1, uniqueness-periods-vector-properties >=0.3.1 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.2 && <1, uniqueness-periods-vector-filters >=0.2 && <1, uniqueness-periods-vector-stats >=0.1.2 && <1, parallel >=3.2.0.6 && <4+ build-depends: base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3 && <1, uniqueness-periods-vector-general >=0.4.4 && < 1, uniqueness-periods-vector-common >=0.4 && <1, uniqueness-periods-vector-properties >=0.3.1 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.2 && <1, uniqueness-periods-vector-filters >=0.2 && <1, uniqueness-periods-vector-stats >=0.1.2 && <1, parallel >=3.2.0.6 && <4 ghc-options: -threaded -rtsopts hs-source-dirs: Proportion default-language: Haskell2010