packages feed

uniqueness-periods-vector-examples 0.13.1.0 → 0.14.0.0

raw patch · 7 files changed

+30/−169 lines, 7 filesdep +phonetic-languages-plusdep −bytestringdep ~mmsyn6ukrdep ~uniqueness-periods-vector-generalPVP ok

version bump matches the API change (PVP)

Dependencies added: phonetic-languages-plus

Dependencies removed: bytestring

Dependency ranges changed: mmsyn6ukr, uniqueness-periods-vector-general

API changes (from Hackage documentation)

- Data.Statistics.RulesIntervals: levynskyiMod :: Int -> Int
- Data.Statistics.RulesIntervals: sturgesH :: Int -> Int

Files

ChangeLog.md view
@@ -156,3 +156,9 @@  * Thirteenth version revised A. Fixed issue with being ambiguous function mconcat for the distributionText executable code. Fixed issue with wrong numeration of the  command line arguments in the propertiesText executable code. ++## 0.14.0.0 -- 2020-10-30++* Fourteenth version. Moved some modules and a code for the executable distributionText to the other package that is planned to share its functionality with less dependencies.+Fixed issue with being not reavaluated in the code for the rewritePoem executable in the circle2I function that led to incorrect results. Updated the dependencies boundaries. +
− Data/Statistics/RulesIntervals.hs
@@ -1,39 +0,0 @@--- |--- Module      :  Data.Statistics.RulesIntervals--- Copyright   :  (c) OleksandrZhabenko 2020--- License     :  MIT--- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com------ Additional statistic rules to choose the number of the intervals.--{-# LANGUAGE BangPatterns #-}--module Data.Statistics.RulesIntervals where--import Data.Lists.FLines (newLineEnding)-import GHC.Real (ceiling)-import GHC.Float (int2Float)--sturgesH :: Int -> Int-sturgesH n-  | compare n 0 == GT = ceiling (logBase 2 (int2Float n))-  | otherwise = error $ "sturgesH: undefined for the argument " ++ show n ++ newLineEnding-{-# INLINE sturgesH #-}---- | According to @В. П. Левинський@ (V. P. Levynskyi) from @Опря А. Т. Статистика (модульний варіант з програмованою формою контролю знань).--- Навч. посіб. --- К.: Центр учбової літератури, 2012. --- 448 с. ISBN 978-611-01-0266-7@) page 60. Always return odd values.-levynskyiMod :: Int -> Int-levynskyiMod n-  | compare n 100 == LT = g n-  | compare n 200 == LT = 11-  | compare n 300 == LT = 13-  | compare n 400 == LT = 15-  | compare n 500 == LT = 17-  | otherwise = let !k = sturgesH n in if even k then k + 7 else k + 8-       where g n-              | compare n 60 == GT = 9-              | compare n 40 == GT = 7-              | compare n 20 == GT = 5-              | otherwise = 3-{-# INLINABLE levynskyiMod #-}
− Distribution/Main.hs
@@ -1,105 +0,0 @@--- |--- Module      :  Main--- Copyright   :  (c) OleksandrZhabenko 2020--- License     :  MIT--- 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 for the seventh command line--- argument (since the 0.12.0.0 version) equal to \"y0\" 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 @distributionText@ executable with--- @+RTS -threaded -RTS@ command line options with possibly @-N@ option inside.-----{-# OPTIONS_GHC -threaded -rtsopts #-}--{-# LANGUAGE CPP, BangPatterns #-}--module Main where--#ifdef __GLASGOW_HASKELL__-#if __GLASGOW_HASKELL__>=710-/* code that applies only to GHC 7.10.* and higher versions */-import GHC.Base (mconcat)-#endif-#endif-import Control.Parallel.Strategies-import Data.Maybe (fromMaybe)-import Text.Read (readMaybe)-import System.Environment-import Numeric (showFFloat)-import Data.List (sort)-import Numeric.Stats-import qualified Data.ByteString.Char8 as B-import Data.Lists.FLines hiding (mconcat)-import Data.Statistics.RulesIntervals-#ifdef __GLASGOW_HASKELL__-#if __GLASGOW_HASKELL__==708-/* code that applies only to GHC 7.8.* */-mconcat = concat-#endif-#endif--main :: IO ()-main = do-  args <- getArgs-  let !gzS = concat . take 1 $ args-      !printInput = concat . drop 1 . take 2 $ args-  contents <- B.getContents-  innerProc gzS printInput contents--innerProc :: String -> String -> B.ByteString -> IO ()-innerProc gzS printInput contents = do-  if printInput == "1" then B.putStr contents else B.putStr B.empty-  (!data31,!wordsCnt0_data32) <- processContents contents -  let !gz = getIntervalsN gzS data31 -- Obtained from the first command line argument except those ones that are for RTS-      !data4 = filter (/= 0.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-      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-          h !y !x = mconcat [mconcat . map (\m1 -> mconcat [mconcat . map (\n1 ->  (if y then show (g m1 n1) else if g m1 n1 == 0 then "." else show (g m1 n1)) ++ "\t") $ [1..gz],newLineEnding]) $ [2..7],replicate 102 x]-      putStrLn . generalInfo1 gz pairs (mean1, disp) $ data31-      putStrLn (h False '~')-      putStrLn (h True '=')--getIntervalsN :: String -> [a] -> Int-getIntervalsN xs yss-  | xs == "s" = sturgesH (length yss)-  | xs == "l" = levynskyiMod (length yss)-  | otherwise = fromMaybe 9 (readMaybe xs::(Maybe Int))-{-# INLINE getIntervalsN #-}--processContents :: B.ByteString -> IO ([Float],[(Int,Int)])-processContents contents = do-  let !anlines = B.lines contents-      !anStrs = map (drop 6 . take 9 . B.words) anlines-      !ratioStrs = map (B.unpack . head) anStrs-      !wordsNStrs = map (B.unpack . (!! 1)) anStrs-      !intervalNStrs = map (B.unpack . last) anStrs-      !ratios = map (\xs -> fromMaybe 1.0 (readMaybe xs::Maybe Float)) ratioStrs-      !wordsNs = map (\xs -> fromMaybe 0 (readMaybe xs::Maybe Int)) wordsNStrs-      !intervalNs = map (\xs -> fromMaybe 0 (readMaybe xs::Maybe Int)) intervalNStrs-  return (ratios,zip wordsNs intervalNs)-  -generalInfo1 :: Int -> [(Int,Int)] -> (Float,Float) -> [Float] -> String-generalInfo1 gz pairs (mean1, disp) data31 =- let !ks = map (\r -> length . takeWhile (== r) . dropWhile (/= r) . sort . map snd $ pairs) [1..gz]-     !s = sum ks in-       mconcat [replicate 102 '-', newLineEnding, mconcat . map (\r -> show r ++ "\t") $ [1..gz], newLineEnding, mconcat . map (\r ->  show r ++ "\t") $ ks,-         newLineEnding, mconcat . map (\r -> showFFloat (Just 2) (fromIntegral (r * 100) / fromIntegral s)  "%\t") $ ks,newLineEnding,-          mconcat [showFFloat (Just 4) mean1 "+-", showFFloat (Just 4) (sqrt disp) "\t", show (length . filter (== 0.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 '*']-{-# INLINE generalInfo1 #-}-
GetInfo/Main.hs view
@@ -45,8 +45,8 @@ import System.Environment import Languages.Phonetic.Ukrainian.PrepareText import Languages.UniquenessPeriods.Vector.Data-import Languages.UniquenessPeriods.Vector.Auxiliary-import Languages.UniquenessPeriods.Vector.StrictV +import Languages.UniquenessPeriods.Vector.AuxiliaryG+import Languages.UniquenessPeriods.Vector.StrictV import Numeric (showFFloat) import Languages.UniquenessPeriods.Vector.Filters import Data.Char (isAlpha)@@ -69,7 +69,7 @@ main = do   args <- getArgs   let !file = concat . take 1 $ args  -- The first command line arguments except those ones that are RTS arguments-      !gzS = concat . take 1 . drop 1 $ args -- The second command line argument that controls the choice of the number of intervals  +      !gzS = concat . take 1 . drop 1 $ args -- The second command line argument that controls the choice of the number of intervals       !printLine = fromMaybe 0 (readMaybe (concat . take 1 . drop 2 $ args)::(Maybe Int)) -- The third command line argument 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 argument except those ones that are RTS arguments. Set 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)       !compareMode = fromMaybe 0 (readMaybe (concat . take 1 . drop 4 $ args)::(Maybe Int)) -- The fifth command line argument except those ones that are RTS arguments. Set to 1 if you would like to print the original version and the concatenated one's (into one line) analyses.
Lines/Main.hs view
@@ -17,10 +17,8 @@ import Control.Parallel.Strategies import qualified Data.Vector as V import Data.List (sort)-import String.Languages.UniquenessPeriods.Vector import Languages.UniquenessPeriods.Vector.Properties import Languages.UniquenessPeriods.Vector.General.Debug-import Languages.UniquenessPeriods.Vector.PropertiesFuncRep import Languages.UniquenessPeriods.Vector.StrictV import Languages.UniquenessPeriods.Vector.Filters (unsafeSwapVecIWithMaxI) import Text.Read (readMaybe)@@ -28,8 +26,7 @@ import System.Environment import Languages.Phonetic.Ukrainian.PrepareText import Languages.UniquenessPeriods.Vector.Data-import Languages.UniquenessPeriods.Vector.Auxiliary-import GHC.Float (int2Float)+import Languages.UniquenessPeriods.Vector.AuxiliaryG import Data.Char (isDigit) import Languages.UniquenessPeriods.Vector.FuncRepRelated @@ -85,12 +82,23 @@ circle2I :: String -> String -> [String] -> Int -> V.Vector Int -> Float -> Float -> [String] -> [String] circle2I xs choice yss numberI vI minE maxE xss  | null xss = yss- | otherwise = circle2I (if null rs then [] else last rs) choice (ws:yss) numberI vI minE maxE tss+ | otherwise = circle2I (if null rs then [] else last rs) choice (ws:yss) numberI vI minE1 maxE1 tss       where (!zss,!tss) = splitAt 1 xss             !rs = words . concat $ zss+            !l3 = (subtract 3) . length $ rs             !ws = if compare (length rs) 3 == LT then unwords (xs:rs) else lastFrom3 . headU2 . fst . get22 .                     uniqNProperties2GN " 01-" (PA xs (if null rs then [] else last rs)) 1 1 (V.singleton (unsafeSwapVecIWithMaxI minE maxE numberI vI .                       oneProperty)) (chooseMax choice) . unwords . init $ rs+            (!maxE1,!minE1)+             | compare l3 0 /= LT =+              let !w2s = unwords . init . words . concat . take 1 $ tss in runEval (parTuple2 rpar rpar ((\k -> if k == 0.0 then 1.0 else k) .+                          (\ls -> if null ls then 0.0 else head ls) . firstFrom3 . maximumElBy 1 (V.singleton oneProperty) $ UL2 ([],+                            uniquenessVariants2GN " 01-" (V.singleton oneProperty) (chooseMax  choice) $ w2s),+                              (\k -> if k == 0.0 then 1.0 else k) . abs . (\ls -> if null ls then 0.0 else head ls) . firstFrom3 .+                                maximumElBy 1 (V.singleton oneProperty) $+                                  UL2 ([],uniquenessVariants2GN " 01-" (V.singleton oneProperty) (chooseMin choice) $ w2s)))+             | otherwise = (0.0,0.0)+  headU2 :: [UniquenessG1 a b] -> UniquenessG1 a b headU2 zs
Simple/Main.hs view
@@ -21,7 +21,7 @@ import Languages.UniquenessPeriods.Vector.General.Debug import Languages.UniquenessPeriods.Vector.PropertiesFuncRep import Languages.UniquenessPeriods.Vector.Properties-import Languages.UniquenessPeriods.Vector.Auxiliary+import Languages.UniquenessPeriods.Vector.AuxiliaryG import Languages.UniquenessPeriods.Vector.StrictV import Languages.UniquenessPeriods.Vector.Filters (unsafeSwapVecIWithMaxI) import Text.Read (readMaybe)
uniqueness-periods-vector-examples.cabal view
@@ -3,7 +3,7 @@ -- http://haskell.org/cabal/users-guide/  name:                uniqueness-periods-vector-examples-version:             0.13.1.0+version:             0.14.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@@ -18,10 +18,10 @@ cabal-version:       >=1.10  library-  exposed-modules:     Languages.UniquenessPeriods.Vector.FuncRepRelated, Data.Statistics.RulesIntervals+  exposed-modules:     Languages.UniquenessPeriods.Vector.FuncRepRelated   -- other-modules:   other-extensions:    BangPatterns-  build-depends:       base >=4.7 && <4.15, uniqueness-periods-vector >=0.3.1.1 && <1, uniqueness-periods-vector-common >=0.5.1.1 && <1, uniqueness-periods-vector-properties >=0.5.5 && <1, lists-flines >=0.1.1 && <1, vector >=0.11 && <0.14+  build-depends:       base >=4.7 && <4.15, uniqueness-periods-vector >=0.3.1.1 && <1, uniqueness-periods-vector-common >=0.5.1.1 && <1, uniqueness-periods-vector-properties >=0.5.5 && <1   -- hs-source-dirs:   default-language:    Haskell2010 @@ -29,7 +29,7 @@   main-is:             Main.hs   other-modules:       Languages.UniquenessPeriods.Vector.FuncRepRelated   other-extensions:    BangPatterns-  build-depends:       base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3.1.1 && <1, uniqueness-periods-vector-general >=0.5.1 && < 1, uniqueness-periods-vector-common >=0.5.1.1 && <1, uniqueness-periods-vector-properties >=0.5.5 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.3 && <1, parallel >=3.2.0.6 && <4, uniqueness-periods-vector-filters >=0.3 && <1, vector >=0.11 && <0.14+  build-depends:       base >=4.7 && <4.15, mmsyn6ukr >=0.8.3 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3.1.1 && <1, uniqueness-periods-vector-general >=0.5.2 && < 1, uniqueness-periods-vector-common >=0.5.1.1 && <1, uniqueness-periods-vector-properties >=0.5.5 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.3 && <1, parallel >=3.2.0.6 && <4, uniqueness-periods-vector-filters >=0.3 && <1, vector >=0.11 && <0.14, phonetic-languages-plus >=0.1 && <1   ghc-options:         -threaded -rtsopts   hs-source-dirs:      ., Simple   default-language:    Haskell2010@@ -38,25 +38,16 @@   main-is:             Main.hs   other-modules:       Languages.UniquenessPeriods.Vector.FuncRepRelated   other-extensions:    BangPatterns-  build-depends:       base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3.1.1 && <1, uniqueness-periods-vector-general >=0.5.1 && < 1, uniqueness-periods-vector-common >=0.5.1.1 && <1, uniqueness-periods-vector-properties >=0.5.5 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.3 && <1, parallel >=3.2.0.6 && <4, uniqueness-periods-vector-filters >=0.3 && <1, vector >=0.11 && <0.14+  build-depends:       base >=4.7 && <4.15, mmsyn6ukr >=0.8.3 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3.1.1 && <1, uniqueness-periods-vector-general >=0.5.2 && < 1, uniqueness-periods-vector-common >=0.5.1.1 && <1, uniqueness-periods-vector-properties >=0.5.5 && <1, print-info >=0.1.3 && <1, phonetic-languages-ukrainian >=0.2.3 && <1, parallel >=3.2.0.6 && <4, uniqueness-periods-vector-filters >=0.3 && <1, vector >=0.11 && <0.14, phonetic-languages-plus >=0.1 && <1   ghc-options:         -threaded -rtsopts   hs-source-dirs:      ., Lines   default-language:    Haskell2010  executable propertiesText   main-is:             Main.hs-  other-modules:       Languages.UniquenessPeriods.Vector.FuncRepRelated, Data.Statistics.RulesIntervals+  other-modules:       Languages.UniquenessPeriods.Vector.FuncRepRelated   other-extensions:    CPP, BangPatterns, FlexibleInstances, MultiParamTypeClasses-  build-depends:       base >=4.7 && <4.15, mmsyn6ukr >=0.8.1 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3.1.1 && <1, uniqueness-periods-vector-general >=0.5.1 && < 1, uniqueness-periods-vector-common >=0.5.1.1 && <1, uniqueness-periods-vector-properties >=0.5.5 && <1, phonetic-languages-ukrainian >=0.2.3 && <1, uniqueness-periods-vector-filters >=0.3 && <1, uniqueness-periods-vector-stats >=0.1.2 && <1, parallel >=3.2.0.6 && <4, lists-flines >=0.1.1 && <1+  build-depends:       base >=4.7 && <4.15, mmsyn6ukr >=0.8.3 && <1, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.3.1.1 && <1, uniqueness-periods-vector-general >=0.5.2 && < 1, uniqueness-periods-vector-common >=0.5.1.1 && <1, uniqueness-periods-vector-properties >=0.5.5 && <1, phonetic-languages-ukrainian >=0.2.3 && <1, uniqueness-periods-vector-filters >=0.3 && <1, uniqueness-periods-vector-stats >=0.1.2 && <1, parallel >=3.2.0.6 && <4, lists-flines >=0.1.1 && <1, phonetic-languages-plus >=0.1 && <1   ghc-options:         -threaded -rtsopts   hs-source-dirs:      ., GetInfo-  default-language:    Haskell2010--executable distributionText-  main-is:             Main.hs-  other-modules:       Data.Statistics.RulesIntervals-  other-extensions:    CPP, BangPatterns-  build-depends:       base >=4.7 && <4.15, bytestring >=0.10 && <0.13, parallel >=3.2.0.6 && <4, lists-flines >=0.1.1 && <1, uniqueness-periods-vector-stats >=0.1.2 && <1-  ghc-options:         -threaded -rtsopts-  hs-source-dirs:      ., Distribution   default-language:    Haskell2010