packages feed

uniqueness-periods-vector-properties 0.1.1.1 → 0.2.0.0

raw patch · 3 files changed

+79/−4 lines, 3 filesdep ~uniqueness-periods-vectorPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: uniqueness-periods-vector

API changes (from Hackage documentation)

+ Languages.UniquenessPeriods.Vector.Properties: diverse1 :: Eq a => UniquenessGeneral2 a -> Int
+ Languages.UniquenessPeriods.Vector.Properties: diverse1s :: Eq a => UniquenessGeneral2 a -> Int
+ Languages.UniquenessPeriods.Vector.Properties: diverse2 :: Eq a => UniquenessGeneral2 a -> Int
+ Languages.UniquenessPeriods.Vector.Properties: sumPositiveAndMaxTuple :: (Num a, Ord a) => (a, a) -> [a] -> (a, a)
+ Languages.UniquenessPeriods.Vector.Properties: sumPositiveAndMaxTuple' :: (Num a, Ord a) => (a, a) -> [a] -> (a, a)
+ Languages.UniquenessPeriods.Vector.Properties: sumPositiveWithoutMax :: (Num a, Ord a) => [a] -> a
+ Languages.UniquenessPeriods.Vector.Properties: sumPositiveWithoutMax' :: (Num a, Ord a) => [a] -> a

Files

ChangeLog.md view
@@ -10,4 +10,9 @@  ## 0.1.1.1 -- 2020-09-01 -* First version revised B. Some minor documentation improvement.+* First version revised B. Some minor documentation improvements.++## 0.2.0.0 -- 2020-09-07++* Second version. Added new functions diverse1, diverse1s, diverse2 to the module. Changed the dependency boundaries for uniqueness-periods-vector. Some minor +documentation improvements.
Languages/UniquenessPeriods/Vector/Properties.hs view
@@ -9,6 +9,8 @@ -- and DobutokO.Poetry.Norms.Extended modules  -- from the @dobutokO-poetry@ package.  +{-# LANGUAGE BangPatterns #-}+ module Languages.UniquenessPeriods.Vector.Properties where  import qualified Data.Vector as V@@ -20,7 +22,7 @@ --  -- The maximum value of the function corresponds to possibly more smoothly changing and mixing elements in the list. If they are used to represent  -- sounds (especially some text, may be poetic) then the resulting maximum possible 'diverse' value corresponds to more \"diverse\" (phonetically) text intervals. --- Is somewhat similar to the @norm4@ function from the DobutokO.Poetyr.Norms module from @dobutokO-poetry@ package +-- Is somewhat similar to the @norm4@ function from the DobutokO.Poetry.Norms module from @dobutokO-poetry@ package  -- See: https://hackage.haskell.org/package/dobutokO-poetry-general-0.1.0.0/docs/DobutokO-Poetry-Norms.html. diverse ::    Eq a => UniquenessGeneral2 a -- ^ Is gotten after the application of the 'uniquenessPeriodsVector2'.@@ -28,3 +30,71 @@ diverse v    | V.null v = 0   | otherwise = V.sum . V.map (\(xs,_) -> if null xs then 0::Int else minimum xs) $ v++-- | The function is inteded to be used after 'uniquenessPeriodsVector2' application to obtain the first argument. So generally, it is used as follows:+--  +-- > diverse1 . uniquenessPeriodsVector2 y whspss $ v +-- +-- The maximum value of the function corresponds to possibly more smoothly changing and mixing elements in the list. If they are used to represent +-- sounds (especially some text, may be poetic) then the resulting maximum possible 'diverse' value corresponds to more \"diverse\" (phonetically) text intervals. +-- Is somewhat similar to the @norm4@ function from the DobutokO.Poetry.Norms module from @dobutokO-poetry@ package. Unlike the 'diverse' function 'diverse1' +-- takes into account that in the word possibly there can be doubled or prolonged sounds that can be represented by repetition of the same sound +-- representation (in some cases). These repetitions do not depend on the words order and, therefore, do not change with it so are not informative on the possible +-- words order rearrangement that is essential to the phonetic languages as the one important application. +-- See: https://hackage.haskell.org/package/dobutokO-poetry-general-0.1.0.0/docs/DobutokO-Poetry-Norms.html.+diverse1 :: +  Eq a => UniquenessGeneral2 a -- ^ Is gotten after the application of the 'uniquenessPeriodsVector2'.+  -> Int  -- ^ The resulting value.+diverse1 v +  | V.null v = 0+  | otherwise = V.sum . V.map (\(xs,_) -> if null (filter (/= 1) xs) then 0::Int else minimum (filter (/= 1) xs)) $ v++-- | Is used similarly to 'diverse1', but uses another approach based on the 'sumPositiveWithoutMax' application, so generally can give another result. +-- It computes sum of the lists of 'Int' where each one is without the maximum value respectively and is without the elements that equal to 1. +diverse1s :: +  Eq a => UniquenessGeneral2 a -- ^ Is gotten after the application of the 'uniquenessPeriodsVector2'.+  -> Int  -- ^ The resulting value.+diverse1s v +  | V.null v = 0+  | otherwise = V.sum . V.map (\(xs,_) -> if null (filter (/= 1) xs) then 0::Int else sumPositiveWithoutMax (filter (/= 1) xs)) $ v++-- | For the list of positive 'Num' elements (this is not checked so it is up to the user to check positiveness) finds out the sum of the list +-- and the maximum value if the first argument is in the form (0, 0). For the empty list returns (0, 0) in such a case. For another first +-- argument has more complex behaviour. Tries to be tail-recursive. +sumPositiveAndMaxTuple :: (Num a, Ord a) => (a, a) -> [a] -> (a, a)+sumPositiveAndMaxTuple (x1,x2) (x:xs)  +  | compare x2 x == GT = sumPositiveAndMaxTuple (x1 + x, x2) xs+  | otherwise = sumPositiveAndMaxTuple (x1 + x, x) xs+sumPositiveAndMaxTuple (x1, x2) [] = (x1, x2)++-- | Unlike 'sumPositiveAndMaxTuple', it is strict by its first argument's inner elements (by both of them). +sumPositiveAndMaxTuple' :: (Num a, Ord a) => (a, a) -> [a] -> (a, a)+sumPositiveAndMaxTuple' (!x1,!x2) (x:xs)  +  | compare x2 x == GT = sumPositiveAndMaxTuple' (x1 + x, x2) xs+  | otherwise = sumPositiveAndMaxTuple' (x1 + x, x) xs+sumPositiveAndMaxTuple' (!x1, !x2) [] = (x1, x2)++-- | For the list of positive 'Num' elements (this is not checked so it is up to the user to check positiveness) finds out the sum of the list +-- without the maximum value. +sumPositiveWithoutMax :: (Num a, Ord a) => [a] -> a+sumPositiveWithoutMax = uncurry (-) . sumPositiveAndMaxTuple (0, 0)++-- | The strict variant the of the 'sumPositiveWithoutMax' function.+sumPositiveWithoutMax' :: (Num a, Ord a) => [a] -> a+sumPositiveWithoutMax' = uncurry (-) . sumPositiveAndMaxTuple' (0, 0)++-- | The function is inteded to be used after 'uniquenessPeriodsVector3' application to obtain the first argument. So generally, it is used as follows:+--  +-- > diverse2 . uniquenessPeriodsVector3 whspss $ v +-- +-- The maximum value of the function corresponds to possibly more smoothly changing and mixing elements in the list. If they are used to represent +-- sounds (especially some text, may be poetic) then the resulting maximum possible 'diverse2' value corresponds to more \"diverse\" (phonetically) text intervals. +-- Is somewhat similar to the @norm4@ function from the DobutokO.Poetry.Norms module from @dobutokO-poetry@ package. Unlike the 'diverse' and 'diverse1' and +-- 'diverse1s' functions 'diverse2' depends much more significantly on the words order. Possibly, the most accurate among \"diverse\" functions in the module.+-- See: https://hackage.haskell.org/package/dobutokO-poetry-general-0.1.0.0/docs/DobutokO-Poetry-Norms.html.+diverse2 :: +  Eq a => UniquenessGeneral2 a -- ^ Is gotten after the application of the 'uniquenessPeriodsVector3'.+  -> Int  -- ^ The resulting value.+diverse2 v +  | V.null v = 0+  | otherwise = V.sum . V.map (sum . fst) $ v
uniqueness-periods-vector-properties.cabal view
@@ -3,7 +3,7 @@ -- http://haskell.org/cabal/users-guide/  name:                uniqueness-periods-vector-properties-version:             0.1.1.1+version:             0.2.0.0 synopsis:            Metrics for the maximum element for the uniqueness-periods-vector packages family. description:         Metrics for the maximum element for the uniqueness-periods-vector packages family. Generalization of the DobutokO.Poetry.Norms and DobutokO.Poetry.Norms.Extended modules from dobuotokO-poetry package. homepage:            https://hackage.haskell.org/package/uniqueness-periods-vector-properties@@ -21,6 +21,6 @@   exposed-modules:     Languages.UniquenessPeriods.Vector.Properties   -- other-modules:   -- other-extensions:-  build-depends:       base >=4.7 && <4.15, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.1 && <1+  build-depends:       base >=4.7 && <4.15, vector >=0.11 && <0.14, uniqueness-periods-vector >=0.2 && <1   -- hs-source-dirs:   default-language:    Haskell2010