uniqueness-periods-vector-general 0.4.3.0 → 0.4.4.0
raw patch · 3 files changed
+87/−71 lines, 3 filesdep ~uniqueness-periods-vector-commonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: uniqueness-periods-vector-common
API changes (from Hackage documentation)
+ Languages.UniquenessPeriods.Vector.General.Debug: newLineEnding :: String
Files
- ChangeLog.md +16/−12
- Languages/UniquenessPeriods/Vector/General/Debug.hs +69/−57
- uniqueness-periods-vector-general.cabal +2/−2
ChangeLog.md view
@@ -6,7 +6,7 @@ ## 0.2.0.0 -- 2020-09-01 -* Second version. Added the possibility to define what output to be printed (but not its order) using the new imported dependency module Data.Print.Info +* Second version. Added the possibility to define what output to be printed (but not its order) using the new imported dependency module Data.Print.Info from print-info module. Some documentation improvements. ## 0.2.0.1 -- 2020-09-07@@ -15,12 +15,12 @@ ## 0.2.0.2 -- 2020-09-09 -* Second version revised B. Some documentation improvements. +* Second version revised B. Some documentation improvements. ## 0.2.1.0 -- 2020-09-09 -* Second version revised C. Fixed issues with wrong arguments order in the uniquenessVariants2GNP function application inside the uniqNPoetical2GN and uniqNPoetical2VGN -functions. +* Second version revised C. Fixed issues with wrong arguments order in the uniquenessVariants2GNP function application inside the uniqNPoetical2GN and uniqNPoetical2VGN+functions. ## 0.2.2.0 -- 2020-09-09 @@ -32,24 +32,28 @@ ## 0.3.0.0 -- 2020-09-11 -* Third version. Fixed issues with being not ordered printed information. Changed the names of the functions. Conversion tables of the changed names is -now given in the ConversionTable.txt file. Some documentation improvements. +* Third version. Fixed issues with being not ordered printed information. Changed the names of the functions. Conversion tables of the changed names is+now given in the ConversionTable.txt file. Some documentation improvements. ## 0.4.0.0 -- 2020-09-12 -* Fourth version. Changed dependency boundaries. Library is rewritten to avoid the redundant complexity of the algorithm realization, to make -the functions basically pure, to fix the issue with printing subsystem in case of the file output. Changes break the previous behaviour, so please, check the code. +* Fourth version. Changed dependency boundaries. Library is rewritten to avoid the redundant complexity of the algorithm realization, to make+the functions basically pure, to fix the issue with printing subsystem in case of the file output. Changes break the previous behaviour, so please, check the code. ## 0.4.1.0 -- 2020-09-12 -* Fourth version revised A. Changed the order of the elements in the list in the Languages.UniquenessPeriods.Vector.General.Debug.maximumElByVec function so that -being afterwards applied naturally Languages.UniquenessPeriods.Vector.General.Debug.printUniquenessG1List prints elements starting from the maximum one. +* Fourth version revised A. Changed the order of the elements in the list in the Languages.UniquenessPeriods.Vector.General.Debug.maximumElByVec function so that+being afterwards applied naturally Languages.UniquenessPeriods.Vector.General.Debug.printUniquenessG1List prints elements starting from the maximum one. ## 0.4.2.0 -- 2020-09-13 -* Fourth version revised B. Fixed issue with toFile function in being not written output for the complex second argument. +* Fourth version revised B. Fixed issue with toFile function in being not written output for the complex second argument. ## 0.4.3.0 -- 2020-09-28 * Fourth version revised C. Fixed issue with maximumElByVec function for situations with repeated distant groups of sounds (and probably other similar ones). Changed-the behaviour of the maximumElBy function so that it become strict in the inner maximum element. +the behaviour of the maximumElBy function so that it become strict in the inner maximum element.++## 0.4.4.0 -- 2020-09-28++* Fourth version revised D. Now uses new uniquenessPeriods2GNP variant from the renewed uniqueness-periods-vector-common package. Added newLineEnding function to the exported ones by the module. Some minor code improvements. Changed the maximumElByVec behaviour to more efficient one.
Languages/UniquenessPeriods/Vector/General/Debug.hs view
@@ -5,11 +5,11 @@ -- Stability : Experimental -- Maintainer : olexandr543@yahoo.com ----- Generalization of the functionality of the DobutokO.Poetry.General.Debug --- module from the @dobutokO-poetry-general-languages@ package. Since 0.3.0.0 version --- changed the names of most functions to more appropriate. The conversion table of --- the old to new names are given in a file ConversionTable.txt in the main source --- directory. +-- Generalization of the functionality of the DobutokO.Poetry.General.Debug+-- module from the @dobutokO-poetry-general-languages@ package. Since 0.3.0.0 version+-- changed the names of most functions to more appropriate. The conversion table of+-- the old to new names are given in a file ConversionTable.txt in the main source+-- directory. {-# LANGUAGE BangPatterns #-} @@ -31,6 +31,8 @@ , toFile , printUniquenessG1 , printUniquenessG1List+ -- *** Auxiliary function+ , newLineEnding ) where import Data.Print.Info@@ -41,12 +43,12 @@ import Languages.UniquenessPeriods.Vector.StrictV import Languages.UniquenessPeriods.Vector.Data --- | The function evaluates the 'V.Vector' of 'UniquenessG1' @a@ @b@ elements (related with the third argument) to retrieve the possibly maximum element --- in it with respect to the order and significance (principality) of the \"properties\" (represented as the functions @f :: [b] -> b@) being evaluated. --- The most significant and principal is the \"property\", which index in the 'V.Vector' of them is the 'Int' argument (so it is the first one) of the --- function minus 1, then less significant is the next to the left \"property\" and so on. --- The predefined library \"properties\" or related to them functions can be found in the package @uniqueness-periods-vector-properties@. -maximumElBy :: +-- | The function evaluates the 'V.Vector' of 'UniquenessG1' @a@ @b@ elements (related with the third argument) to retrieve the possibly maximum element+-- in it with respect to the order and significance (principality) of the \"properties\" (represented as the functions @f :: [b] -> b@) being evaluated.+-- The most significant and principal is the \"property\", which index in the 'V.Vector' of them is the 'Int' argument (so it is the first one) of the+-- function minus 1, then less significant is the next to the left \"property\" and so on.+-- The predefined library \"properties\" or related to them functions can be found in the package @uniqueness-periods-vector-properties@.+maximumElBy :: (Eq a, Ord b) => Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left. -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> UniqG2 a b -- ^ The data to be analyzed.@@ -61,20 +63,20 @@ {-# INLINE maximumElBy #-} -- | Prints every 'String' from the list on the new line to the file. Uses 'appendFile' function inside.-toFile :: +toFile :: FilePath -- ^ The 'FilePath' to the file to be written in the 'AppendMode' (actually appended with) the information output. -> [String] -- ^ Each 'String' is appended on the new line to the file. -> IO () toFile file xss = (mapM_ (appendFile file) . intersperse newLineEnding $ xss) >> appendFile file newLineEnding -- | Is used to print output specified to the 'stdout' or to the 'FilePath' specified as the inner argument in the 'Info2' parameter.-printUniquenessG1 +printUniquenessG1 :: (Show a, Show b) => Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file. -> UniquenessG1 a b -- ^ The element, for which the information is printed. -> IO ()-printUniquenessG1 info uni - | isI1 info = - case (\(I1 x) -> x) info of +printUniquenessG1 info uni+ | isI1 info =+ case (\(I1 x) -> x) info of A -> putStr "" -- nothing is printed B -> mapM_ putStrLn [show . lastFrom3 $ uni] C -> mapM_ putStrLn [show . firstFrom3 $ uni]@@ -84,8 +86,8 @@ G -> mapM_ putStrLn [show . firstFrom3 $ uni, show . secondFrom3 $ uni] _ -> mapM_ putStrLn [show . lastFrom3 $ uni, show . firstFrom3 $ uni, show. secondFrom3 $ uni] -- the most verbose output | otherwise =- case (\(I2 x) -> x) info of - Af xs -> putStr "" -- nothing is printed+ case (\(I2 x) -> x) info of+ Af _ -> putStr "" -- nothing is printed Bf xs -> toFile xs [show . lastFrom3 $ uni] Cf xs -> toFile xs [show . firstFrom3 $ uni] Df xs -> toFile xs [show . secondFrom3 $ uni]@@ -95,13 +97,13 @@ ~(Hf xs) -> toFile xs [show . lastFrom3 $ uni, show . firstFrom3 $ uni, show. secondFrom3 $ uni] -- the most verbose output -- | Is used to print output specified to the 'stdout' or to the 'FilePath' specified as the inner argument in the 'Info2' parameter.-printUniquenessG1List +printUniquenessG1List :: (Show a, Show b) => Info2 -- ^ A parameter to control the predefined behaviour of the printing. The 'I1' branch prints to the 'stdout' and the 'I2' - to the file. -> [UniquenessG1 a b] -- ^ The list of elements, for which the information is printed. -> IO () printUniquenessG1List info (y:ys)- | isI1 info = - case (\(I1 x) -> x) info of + | isI1 info =+ case (\(I1 x) -> x) info of A -> putStr "" -- nothing is printed B -> mapM_ putStrLn . map (show . lastFrom3) $ ys C -> mapM_ putStrLn . map (show . firstFrom3) $ ys@@ -111,44 +113,44 @@ G -> (putStrLn . show . firstFrom3 $ y) >> (putStrLn . show . secondFrom3 $ y) >> printUniquenessG1List info ys _ -> (putStrLn . show . lastFrom3 $ y) >> (putStrLn . show . firstFrom3 $ y) >> (putStrLn . show. secondFrom3 $ y) >> printUniquenessG1List info ys -- the most verbose output | otherwise =- case (\(I2 x) -> x) info of - Af xs -> putStr "" -- nothing is printed+ case (\(I2 x) -> x) info of+ Af _ -> putStr "" -- nothing is printed Bf xs -> toFile xs . map (show . lastFrom3) $ ys Cf xs -> toFile xs . map (show . firstFrom3) $ ys Df xs -> toFile xs . map (show . secondFrom3) $ ys Ef xs -> toFile xs . map (\t -> (show (lastFrom3 t) ++ newLineEnding ++ show (firstFrom3 t))) $ ys Ff xs -> toFile xs . map (\t -> (show (lastFrom3 t) ++ newLineEnding ++ show (secondFrom3 t))) $ ys Gf xs -> toFile xs . map (\t -> (show (firstFrom3 t) ++ newLineEnding ++ show (secondFrom3 t))) $ ys- ~(Hf xs) -> toFile xs . map (\t -> (show (lastFrom3 t) ++ newLineEnding ++ show (firstFrom3 t) ++ newLineEnding ++ show (secondFrom3 t))) $ ys -- the most verbose output -printUniquenessG1List info [] = return ()+ ~(Hf xs) -> toFile xs . map (\t -> (show (lastFrom3 t) ++ newLineEnding ++ show (firstFrom3 t) ++ newLineEnding ++ show (secondFrom3 t))) $ ys -- the most verbose output+printUniquenessG1List _ [] = return () --- | Auxiliary printing function to define the line ending needed to be printed by 'printUniquenessG1List' function in some cases. +-- | Auxiliary printing function to define the line ending needed to be printed by 'printUniquenessG1List' function in some cases. newLineEnding :: String-newLineEnding +newLineEnding | nativeNewline == LF = "\n" | otherwise = "\r\n" --- | Variant of the 'maximumElBy' function where all the given \"properties\" are used. +-- | Variant of the 'maximumElBy' function where all the given \"properties\" are used. -- The predefined library \"properties\" or related to them functions can be found in the package @uniqueness-periods-vector-properties@.-maximumElByAll :: +maximumElByAll :: (Eq a, Ord b, Show a, Show b) => V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> UniqG2 a b -- ^ The data to be analyzed. -> UniquenessG1 a b -- ^ The maximum element according to the given \"properties\". maximumElByAll vN = maximumElBy (V.length vN) vN {-# INLINE maximumElByAll #-} --- | The function evaluates --- the generated 'V.Vector' of 'UniquenessG1' @a@ @b@ elements to retrieve the possibly maximum element in it with respect to the order and significance (principality) --- of the \"properties\" being evaluated. The most significant and principal is the \"property\", which index in the 'V.Vector' of them is the 'Int' argument of the function +-- | The function evaluates+-- the generated 'V.Vector' of 'UniquenessG1' @a@ @b@ elements to retrieve the possibly maximum element in it with respect to the order and significance (principality)+-- of the \"properties\" being evaluated. The most significant and principal is the \"property\", which index in the 'V.Vector' of them is the 'Int' argument of the function -- minus 1, then less significant is the next to the left \"property\" and so on.-maximumElGBy :: +maximumElGBy :: (Eq a, Ord b, Show a, Show b) => [a] -- ^ A list of \"whitespace symbols\" that delimits the sublists in the list to be processed.- -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. + -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. -> Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left. -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> ([a] -> V.Vector c) -- ^ The first function that transforms the processed list into the form suitable for analyzing by the functions in the module. -> (V.Vector c -> [b]) -- ^ The second function that transforms the suitable form data representation obtained by the previous argument application into the data that can be evaluated to get the result.- -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text. + -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text. -> UniquenessG1 a b maximumElGBy whspss rr k vN g1 g2 xs | compare k (V.length vN) == GT = error "Languages.UniquenessPeriods.Vector.General.Debug.maximumElGBy: undefined for that amount of norms. "@@ -160,55 +162,65 @@ | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) . uniquenessVariantsGN whspss rr vN g1 g2 $ xs -- | A variant for 'uniquenessVariants2GN' and 'uniquenessVariants2GNP' with the second argument defining, which one is used.-uniquenessVariantsGN :: +uniquenessVariantsGN :: (Eq a, Ord b, Show a, Show b) => [a] -- ^ A list of \"whitespace symbols\" that delimits the sublists in the list to be processed.- -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. + -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> ([a] -> V.Vector c) -- ^ The first function that transforms the processed list into the form suitable for analyzing by the functions in the module. Usually it is one of the functions 'uniquenessPeriodsVector1', 'uniquenessPeriodsVector2', or 'uniquenessPeriodsVector2' from the @uniqueness-periods-vector@ package. Usually it is one of the functions 'uniquenessPeriodsVector1', 'uniquenessPeriodsVector2', or 'uniquenessPeriodsVector3' from the @uniqueness-periods-vector@ package. -> (V.Vector c -> [b]) -- ^ The second function that transforms the suitable form data representation obtained by the previous argument application into the data that can be evaluated to get the result. The predefined functions can be found in the package @uniqueness-periods-vector-properties@.- -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text. + -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text. -> V.Vector (UniquenessG1 a b) uniquenessVariantsGN whspss (PA ts us) vN g1 g2 = uniquenessVariants2GNP ts us whspss vN g1 g2 uniquenessVariantsGN whspss K vN g1 g2 = uniquenessVariants2GN whspss vN g1 g2 {-# INLINE uniquenessVariantsGN #-} --- | Finds out the maximum element with respect of the @k@ \"properties\" (the most significant of which is the rightest one, then to the left less significant etc.), --- which is given as the first argument, and then rearranges the input moving the elements equal by the first element in the triple to the maximum element --- to the first element in the tuple. --- --- The last \"property\" is the first element in the 'V.Vector' of \"properties\" (@[b] -> b@). -maximumElByVec :: +-- | Finds out the maximum element with respect of the @k@ \"properties\" (the most significant of which is the rightest one, then to the left less significant etc.),+-- which is given as the first argument, and then rearranges the input moving the elements equal by the first element in the triple to the maximum element+-- to the first element in the tuple.+--+-- The last \"property\" is the first element in the 'V.Vector' of \"properties\" (@[b] -> b@).+maximumElByVec :: (Eq a, Ord b, Show a, Show b) => Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left. -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> UniqG2 a b -- ^ The data to be analyzed. -> UniqG2 a b-maximumElByVec k vN x = let uniq = maximumElBy k vN x in let snD = secondFrom3 uniq in UL2 ((\(v1,v2) -> ((fst . get22 $ x) ++ V.toList v1,v2)) . - V.unstablePartition ((== snD) . secondFrom3) . snd . get22 $ x)+maximumElByVec k vN x = let !uniq = maximumElBy k vN x in let !snD = secondFrom3 uniq in UL2 ((\(!v1,!v2) -> ((fst . get22 $ x) ++ V.toList v1,v2)) .+ V.unstablePartition (equalSnDs snD . secondFrom3) . snd . get22 $ x) {-# INLINE maximumElByVec #-}- ++equalSnDs+ :: Ord b => V.Vector b+ -> V.Vector b+ -> Bool+equalSnDs v1 v2+ | V.null v1 = V.null v2+ | V.null v2 = False+ | V.unsafeIndex v1 0 == V.unsafeIndex v2 0 = equalSnDs (V.unsafeSlice 1 (V.length v1 - 1) v1) (V.unsafeSlice 1 (V.length v2 - 1) v2)+ | otherwise = False+ -- | A variant of the 'maximumElByVec' where all the given \"properties\" are used.-maximumElByVecAll :: +maximumElByVecAll :: (Eq a, Ord b, Show a, Show b) => V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> UniqG2 a b -- ^ The data to be analyzed. -> UniqG2 a b maximumElByVecAll vN = maximumElByVec (V.length vN) vN {-# INLINE maximumElByVecAll #-} --- | Finds out the @n@ (the first 'Int' argument) consequential maximum elements, and then rearranges the input moving the elements equal by the first element --- in the triple to the maximum element to the first element in the tuple. -uniqNPropertiesN :: +-- | Finds out the @n@ (the first 'Int' argument) consequential maximum elements, and then rearranges the input moving the elements equal by the first element+-- in the triple to the maximum element to the first element in the tuple.+uniqNPropertiesN :: (Eq a, Ord b, Show a, Show b) => Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed. -> Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left. -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> UniqG2 a b -- ^ The data to be analyzed. -> UniqG2 a b-uniqNPropertiesN n k vN y +uniqNPropertiesN n k vN y | n <= 0 = y | otherwise = uniqNPropertiesN (n - 1) k vN . maximumElByVec k vN $ y {-# INLINE uniqNPropertiesN #-} -- | A variant of the 'uniqNPropertiesN' where all the given \"properties\" are used.-uniqNPropertiesNAll :: +uniqNPropertiesNAll :: (Eq a, Ord b, Show a, Show b) => Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed. -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> UniqG2 a b -- ^ The data to be analyzed.@@ -218,16 +230,16 @@ -------------------------------------------------------------------------------------------- --- | The full analyzing and processment function. -uniqNProperties2GN :: +-- | The full analyzing and processment function.+uniqNProperties2GN :: (Eq a, Ord b, Show a, Show b) => [a] -- ^ A list of \"whitespace symbols\" that delimits the sublists in the list to be processed.- -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. + -> Preapp a -- ^ A parameter to specify the lists to be prepended and postpended to the given data to be processed before actual processment. -> Int -- ^ A quantity of the recursive calls that returns each one a new result from the rest of the data processed. -> Int -- ^ The quantity of the represented as functions \"properties\" to be applied from the second argument. The order is from the right to the left. -> V.Vector ([b] -> b) -- ^ 'V.Vector' of the represented as functions \"properties\" to be applied consequently. -> ([a] -> V.Vector c) -- ^ The first function that transforms the processed list into the form suitable for analyzing by the functions in the module. Usually it is one of the functions 'uniquenessPeriodsVector1', 'uniquenessPeriodsVector2', or 'uniquenessPeriodsVector3' from the @uniqueness-periods-vector@ package. -> (V.Vector c -> [b]) -- ^ The second function that transforms the suitable form data representation obtained by the previous argument application into the data that can be evaluated to get the result. The predefined functions can be found in the package @uniqueness-periods-vector-properties@.- -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text. + -> [a] -- ^ The data to be processed. Often it can be a 'String' of the text. -> UniqG2 a b uniqNProperties2GN whspss rr n k vN g1 g2 xs | n <= 0 = UL2 ([],V.empty)
uniqueness-periods-vector-general.cabal view
@@ -2,7 +2,7 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/ name: uniqueness-periods-vector-general-version: 0.4.3.0+version: 0.4.4.0 synopsis: Some kind of the optimization approach to data inner structure. description: Generalization of the functionality of the dobutokO-poetry-general-languages package homepage: https://hackage.haskell.org/package/uniqueness-periods-vector-general@@ -20,6 +20,6 @@ exposed-modules: Languages.UniquenessPeriods.Vector.General.Debug -- other-modules: other-extensions: BangPatterns- build-depends: base >=4.7 && <4.15, vector >=0.11 && <0.14, uniqueness-periods-vector-common >=0.3 && <1, print-info >=0.1.3 && <1+ build-depends: base >=4.7 && <4.15, vector >=0.11 && <0.14, uniqueness-periods-vector-common >=0.4 && <1, print-info >=0.1.3 && <1 -- hs-source-dirs: default-language: Haskell2010