packages feed

phonetic-languages-plus 0.1.2.0 → 0.2.0.0

raw patch · 5 files changed

+66/−28 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Statistics.RulesIntervalsPlus: getIntervalsN :: String -> [a] -> Int
+ Data.Statistics.RulesIntervalsPlus: getIntervalsNS :: Bool -> String -> [String] -> Int

Files

ChangeLog.md view
@@ -7,3 +7,9 @@ ## 0.1.2.0 -- 2020-12-07  * First version revised B. Fixed issues with being wrongly counted and displayed the number of one-word lines.++## 0.2.0.0 -- 2020-12-07++* Second version. Added the new library module  Data.Statistics.RulesIntervalsPlus.+Added the possibility to process in a special way the 'almost empty' lines of the input by the+distributionTextG executable that can be used by the other packages further.
Data/Statistics/RulesIntervals.hs view
@@ -14,6 +14,8 @@ import Data.Lists.FLines (newLineEnding) import GHC.Real (ceiling) import GHC.Float (int2Float)+import Data.Maybe (fromMaybe)+import Text.Read (readMaybe)  sturgesH :: Int -> Int sturgesH n
+ Data/Statistics/RulesIntervalsPlus.hs view
@@ -0,0 +1,32 @@+-- |+-- Module      :  Data.Statistics.RulesIntervalsPlus+-- 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.RulesIntervalsPlus where++import  Data.Statistics.RulesIntervals+import Data.Maybe (fromMaybe)+import Text.Read (readMaybe)++getIntervalsNS :: Bool -> String -> [String] -> Int+getIntervalsNS lstW xs yss+  | xs == "s" = sturgesH z+  | xs == "l" = levynskyiMod z+  | otherwise = fromMaybe 9 (readMaybe xs::(Maybe Int))+     where k = if lstW then 2 else 1+           z = length . filter ((> k) . length . words) $ yss+{-# INLINE getIntervalsNS #-}++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 #-}
Distribution/Main.hs view
@@ -44,6 +44,7 @@ import qualified Data.ByteString.Char8 as B import Data.Lists.FLines hiding (mconcat) import Data.Statistics.RulesIntervals+import Data.Statistics.RulesIntervalsPlus #ifdef __GLASGOW_HASKELL__ #if __GLASGOW_HASKELL__==708 /* code that applies only to GHC 7.8.* */@@ -53,20 +54,22 @@  main :: IO () main = do-  args <- getArgs-  let !gzS = concat . take 1 $ args+  args0 <- getArgs+  let !args = filter (/= "+W") args0+      !gzS = concat . take 1 $ args       !printInput = concat . drop 1 . take 2 $ args+      !whitelines = any (== "+W") args0 -- Usually, if specified -- the third argument   contents <- B.getContents-  innerProc gzS printInput contents+  innerProc whitelines gzS printInput contents -innerProc :: String -> String -> B.ByteString -> IO ()-innerProc gzS printInput contents = do+innerProc :: Bool -> String -> String -> B.ByteString -> IO ()+innerProc whitelines gzS printInput contents = do   if printInput == "1" then B.putStr contents else B.putStr B.empty-  (!data31,!wordsCnt0_data32) <- processContents contents+  (!data31,!wordsCnt0_data32) <- processContents whitelines contents   let !gz = getIntervalsN gzS data31 -- Obtained from the first command line argument except those ones that are for RTS       !pair2s = zip data31 wordsCnt0_data32       !data4 = mapMaybe (\(!x,(!y,_)) -> if y > 1 then Just x else Nothing) pair2s-  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 lines with no more than 1 word every one. A rather rare occurrence.+  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 lines that have no variativity from the program perspective and, therefore, they cannot be analyzed effectively by it. Nevertheless, you can accurately exclude them from the consideration. A rather rare occurrence.   else do       let (!mean1,!disp) = meanWithDispD2 data4           !pairs = sort . filter ((/= 0) . snd) $ wordsCnt0_data32@@ -76,24 +79,19 @@       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 ([Double],[(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 Double)) 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)+processContents :: Bool -> B.ByteString -> IO ([Double],[(Int,Int)])+processContents whitelines contents = do+    let !anlines = B.lines contents+        !anStrs+          | whitelines = filter (not . null) . map (drop 6 . take 9 . B.words) $ anlines+          | otherwise = 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 Double)) 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)] -> (Double,Double) -> [Double] -> String generalInfo1 gz pairs (mean1, disp) data31 =
phonetic-languages-plus.cabal view
@@ -3,7 +3,7 @@ -- http://haskell.org/cabal/users-guide/  name:                phonetic-languages-plus-version:             0.1.2.0+version:             0.2.0.0 synopsis:            Some common shared between different packages functions. description:         Among them are the uniqueness-periods-vector series. homepage:            https://hackage.haskell.org/package/phonetic-languages-plus@@ -18,7 +18,7 @@ cabal-version:       >=1.10  library-  exposed-modules:     Languages.UniquenessPeriods.Vector.AuxiliaryG, Data.Statistics.RulesIntervals+  exposed-modules:     Languages.UniquenessPeriods.Vector.AuxiliaryG, Data.Statistics.RulesIntervals,  Data.Statistics.RulesIntervalsPlus   -- other-modules:   other-extensions:    BangPatterns   build-depends:       base >=4.7 && <4.15, lists-flines >=0.1.1 && <1@@ -27,7 +27,7 @@  executable distributionTextG   main-is:             Main.hs-  other-modules:       Data.Statistics.RulesIntervals+  other-modules:       Data.Statistics.RulesIntervals, Data.Statistics.RulesIntervalsPlus   other-extensions:    CPP, BangPatterns   build-depends:       base >=4.7 && <4.15, bytestring >=0.10 && <0.13, lists-flines >=0.1.1 && <1, uniqueness-periods-vector-stats >=0.2.1 && <1, parallel >=3.2.0.6 && <4   ghc-options:         -threaded -rtsopts