packages feed

dobutokO-poetry 0.10.0.0 → 0.11.0.0

raw patch · 12 files changed

+361/−415 lines, 12 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- DobutokO.Poetry: uniq10Poetical4 :: String -> IO ()
- DobutokO.Poetry: uniq10Poetical5 :: String -> IO ()
- DobutokO.Poetry: uniq10PoeticalG :: ([Int] -> Int) -> String -> IO ()
- DobutokO.Poetry: uniqMaxPoetical2GN :: Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> Uniqueness
- DobutokO.Poetry: uniqMaxPoetical2GNL :: Vector ([Int] -> Int) -> (String -> [Int]) -> String -> Uniqueness
- DobutokO.Poetry: uniqMaxPoeticalGN :: Int -> Vector ([Int] -> Int) -> String -> Uniqueness
- DobutokO.Poetry: uniqMaxPoeticalGNL :: Vector ([Int] -> Int) -> String -> Uniqueness
- DobutokO.Poetry: uniqNPoetical2GN :: Int -> Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()
- DobutokO.Poetry: uniqNPoetical2GNL :: Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()
- DobutokO.Poetry: uniqNPoetical2GNLine :: Int -> Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()
- DobutokO.Poetry: uniqNPoetical2GNLineL :: Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()
- DobutokO.Poetry: uniqNPoetical2VGN :: Int -> Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO (Vector Uniqueness)
- DobutokO.Poetry: uniqNPoetical2VGNL :: Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO (Vector Uniqueness)
- DobutokO.Poetry: uniqNPoeticalG :: Int -> ([Int] -> Int) -> String -> IO ()
- DobutokO.Poetry: uniqNPoeticalGN :: Int -> Int -> Vector ([Int] -> Int) -> String -> IO ()
- DobutokO.Poetry: uniqNPoeticalGNL :: Int -> Vector ([Int] -> Int) -> String -> IO ()
- DobutokO.Poetry: uniqNPoeticalUGN :: Int -> Int -> Int -> Vector ([Int] -> Int) -> String -> IO (Vector Uniqueness)
- DobutokO.Poetry: uniqNPoeticalUGN51 :: Int -> Int -> String -> IO (Vector Uniqueness)
- DobutokO.Poetry: uniqNPoeticalUGN51_ :: Int -> Int -> String -> IO ()
- DobutokO.Poetry: uniqNPoeticalUGNL :: Int -> Int -> Vector ([Int] -> Int) -> String -> IO (Vector Uniqueness)
- DobutokO.Poetry: uniqNPoeticalUGNL_ :: Int -> Int -> Vector ([Int] -> Int) -> String -> IO ()
- DobutokO.Poetry: uniqNPoeticalUGN_ :: Int -> Int -> Int -> Vector ([Int] -> Int) -> String -> IO ()
- DobutokO.Poetry: uniqNPoeticalVGN :: Int -> Int -> Vector ([Int] -> Int) -> String -> IO (Vector Uniqueness)
- DobutokO.Poetry: uniqNPoeticalVGNL :: Int -> Vector ([Int] -> Int) -> String -> IO (Vector Uniqueness)
- DobutokO.Poetry: uniquenessVariantsGN :: Vector ([Int] -> Int) -> String -> Vector Uniqueness
- DobutokO.Poetry.Basic: type Uniqueness = ([Int], Vector Int, String)
- DobutokO.Poetry.Basic: uniqInMaxPoeticalN :: Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> IO (Vector Uniqueness)
- DobutokO.Poetry.Basic: uniqInMaxPoeticalNL :: Vector ([Int] -> Int) -> Vector Uniqueness -> IO (Vector Uniqueness)
- DobutokO.Poetry.Basic: uniqInMaxPoeticalNLine :: Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> IO (Vector Uniqueness)
- DobutokO.Poetry.Basic: uniqInMaxPoeticalNLineL :: Vector ([Int] -> Int) -> Vector Uniqueness -> IO (Vector Uniqueness)
- DobutokO.Poetry.Basic: uniqMaxPoeticalGNV :: Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> Uniqueness
- DobutokO.Poetry.Basic: uniqMaxPoeticalGNVL :: Vector ([Int] -> Int) -> Vector Uniqueness -> Uniqueness
- DobutokO.Poetry.Basic: uniqNPoeticalN :: Int -> Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> IO ()
- DobutokO.Poetry.Basic: uniqNPoeticalNL :: Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> IO ()
- DobutokO.Poetry.Basic: uniqNPoeticalNLine :: Int -> Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> IO ()
- DobutokO.Poetry.Basic: uniqNPoeticalNLineL :: Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> IO ()
- DobutokO.Poetry.Basic: uniqNPoeticalVN :: Int -> Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> IO (Vector Uniqueness)
- DobutokO.Poetry.Basic: uniqNPoeticalVNL :: Int -> Vector ([Int] -> Int) -> Vector Uniqueness -> IO (Vector Uniqueness)
- DobutokO.Poetry.General: K :: PreApp a
- DobutokO.Poetry.General: PA :: [a] -> [a] -> PreApp a
- DobutokO.Poetry.General: U :: b -> UniquenessG a b
- DobutokO.Poetry.General: UL :: ([a], b) -> UniquenessG a b
- DobutokO.Poetry.General: class G1 a b
- DobutokO.Poetry.General: data PreApp a
- DobutokO.Poetry.General: data UniquenessG a b
- DobutokO.Poetry.General: get1m :: G1 a b => a -> [b]
- DobutokO.Poetry.General: get2 :: UniqG -> (Maybe [String], Vector Uniqueness)
- DobutokO.Poetry.General: get2m :: G1 a b => a -> [b]
- DobutokO.Poetry.General: getm :: G1 a b => Bool -> a -> [b]
- DobutokO.Poetry.General: instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (DobutokO.Poetry.General.UniquenessG a b)
- DobutokO.Poetry.General: instance DobutokO.Poetry.General.G1 (DobutokO.Poetry.General.PreApp GHC.Types.Char) GHC.Types.Char
- DobutokO.Poetry.General: instance GHC.Classes.Eq a => GHC.Classes.Eq (DobutokO.Poetry.General.PreApp a)
- DobutokO.Poetry.General: instance GHC.Show.Show (DobutokO.Poetry.General.UniquenessG GHC.Base.String (Data.Vector.Vector DobutokO.Poetry.Basic.Uniqueness))
- DobutokO.Poetry.General: isK :: PreApp a -> Bool
- DobutokO.Poetry.General: isPA :: PreApp a -> Bool
- DobutokO.Poetry.General: isU :: UniqG -> Bool
- DobutokO.Poetry.General: isUL :: UniqG -> Bool
- DobutokO.Poetry.General: preapp :: G1 a b => a -> [[b]] -> [[b]]
- DobutokO.Poetry.General: set2 :: (Maybe [String], Vector Uniqueness) -> UniqG
- DobutokO.Poetry.General: setm :: G1 a b => [b] -> [b] -> a
- DobutokO.Poetry.General: type Preapp = PreApp Char
- DobutokO.Poetry.General: type UniqG = UniquenessG String (Vector Uniqueness)
+ DobutokO.Poetry.Auxiliary: firstFrom3 :: (a, b, c) -> a
+ DobutokO.Poetry.Auxiliary: secondFrom3 :: (a, b, c) -> b
+ DobutokO.Poetry.Data: K :: PreApp a
+ DobutokO.Poetry.Data: PA :: [a] -> [a] -> PreApp a
+ DobutokO.Poetry.Data: U :: b -> UniquenessG a b
+ DobutokO.Poetry.Data: UL :: ([a], b) -> UniquenessG a b
+ DobutokO.Poetry.Data: class G1 a b
+ DobutokO.Poetry.Data: data PreApp a
+ DobutokO.Poetry.Data: data UniquenessG a b
+ DobutokO.Poetry.Data: get1m :: G1 a b => a -> [b]
+ DobutokO.Poetry.Data: get2 :: UniqG -> (Maybe [String], Vector Uniqueness)
+ DobutokO.Poetry.Data: get2m :: G1 a b => a -> [b]
+ DobutokO.Poetry.Data: getm :: G1 a b => Bool -> a -> [b]
+ DobutokO.Poetry.Data: instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (DobutokO.Poetry.Data.UniquenessG a b)
+ DobutokO.Poetry.Data: instance DobutokO.Poetry.Data.G1 (DobutokO.Poetry.Data.PreApp GHC.Types.Char) GHC.Types.Char
+ DobutokO.Poetry.Data: instance GHC.Classes.Eq a => GHC.Classes.Eq (DobutokO.Poetry.Data.PreApp a)
+ DobutokO.Poetry.Data: instance GHC.Show.Show (DobutokO.Poetry.Data.UniquenessG GHC.Base.String (Data.Vector.Vector DobutokO.Poetry.Data.Uniqueness))
+ DobutokO.Poetry.Data: isK :: PreApp a -> Bool
+ DobutokO.Poetry.Data: isPA :: PreApp a -> Bool
+ DobutokO.Poetry.Data: isU :: UniqG -> Bool
+ DobutokO.Poetry.Data: isUL :: UniqG -> Bool
+ DobutokO.Poetry.Data: preapp :: G1 a b => a -> [[b]] -> [[b]]
+ DobutokO.Poetry.Data: set2 :: (Maybe [String], Vector Uniqueness) -> UniqG
+ DobutokO.Poetry.Data: setm :: G1 a b => [b] -> [b] -> a
+ DobutokO.Poetry.Data: type Preapp = PreApp Char
+ DobutokO.Poetry.Data: type UniqG = UniquenessG String (Vector Uniqueness)
+ DobutokO.Poetry.Data: type Uniqueness = ([Int], Vector Int, String)
+ DobutokO.Poetry.General.Debug: inner1 :: Int -> Vector ([Int] -> Int) -> UniqG -> IO ([Int], UniqG)
+ DobutokO.Poetry.General.Debug: uniq10Poetical4 :: Preapp -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniq10Poetical5 :: Preapp -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniq10PoeticalG :: Preapp -> ([Int] -> Int) -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqInMaxPoeticalN :: Int -> Vector ([Int] -> Int) -> UniqG -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqInMaxPoeticalNL :: Vector ([Int] -> Int) -> UniqG -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqMaxPoetical2GN :: Preapp -> Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> Uniqueness
+ DobutokO.Poetry.General.Debug: uniqMaxPoetical2GNL :: Preapp -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> Uniqueness
+ DobutokO.Poetry.General.Debug: uniqMaxPoeticalGN :: Preapp -> Int -> Vector ([Int] -> Int) -> String -> Uniqueness
+ DobutokO.Poetry.General.Debug: uniqMaxPoeticalGNL :: Preapp -> Vector ([Int] -> Int) -> String -> Uniqueness
+ DobutokO.Poetry.General.Debug: uniqMaxPoeticalGNV :: Int -> Vector ([Int] -> Int) -> UniqG -> Uniqueness
+ DobutokO.Poetry.General.Debug: uniqMaxPoeticalGNVL :: Vector ([Int] -> Int) -> UniqG -> Uniqueness
+ DobutokO.Poetry.General.Debug: uniqNPoetical2GN :: Preapp -> Int -> Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoetical2GNL :: Preapp -> Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoetical2VGN :: Preapp -> Int -> Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> UniqG -> String -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqNPoetical2VGNL :: Preapp -> Int -> Vector ([Int] -> Int) -> (String -> [Int]) -> UniqG -> String -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqNPoeticalG :: Preapp -> Int -> ([Int] -> Int) -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoeticalGN :: Preapp -> Int -> Int -> Vector ([Int] -> Int) -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoeticalGNL :: Preapp -> Int -> Vector ([Int] -> Int) -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoeticalN :: Int -> Int -> Vector ([Int] -> Int) -> UniqG -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoeticalNL :: Int -> Vector ([Int] -> Int) -> UniqG -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoeticalUGN :: Preapp -> Int -> Int -> Int -> Vector ([Int] -> Int) -> UniqG -> String -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqNPoeticalUGN51 :: Preapp -> Int -> Int -> UniqG -> String -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqNPoeticalUGN51_ :: Preapp -> Int -> Int -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoeticalUGNL :: Preapp -> Int -> Int -> Vector ([Int] -> Int) -> UniqG -> String -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqNPoeticalUGNL_ :: Preapp -> Int -> Int -> Vector ([Int] -> Int) -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoeticalUGN_ :: Preapp -> Int -> Int -> Int -> Vector ([Int] -> Int) -> String -> IO ()
+ DobutokO.Poetry.General.Debug: uniqNPoeticalVGN :: Preapp -> Int -> Int -> Vector ([Int] -> Int) -> UniqG -> String -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqNPoeticalVGNL :: Preapp -> Int -> Vector ([Int] -> Int) -> UniqG -> String -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqNPoeticalVN :: Int -> Int -> Vector ([Int] -> Int) -> UniqG -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniqNPoeticalVNL :: Int -> Vector ([Int] -> Int) -> UniqG -> IO UniqG
+ DobutokO.Poetry.General.Debug: uniquenessVariantsGN :: Preapp -> Vector ([Int] -> Int) -> String -> Vector Uniqueness
+ DobutokO.Poetry.Norms: combineNorms :: [Int] -> Vector ([Int] -> Int) -> [Int]

Files

ChangeLog.md view
@@ -62,3 +62,10 @@  * Tenth version. Added a new module DobutokO.Poetry.Norms.Extended, added a new possibility to split norms and to use more complex than just one norm evaluation  procedure on the each stage of evaluation. Added some new norms to the corresponding modules. Some minor code improvements. ++## 0.11.0.0 -- 2020-08-15++* Eleventh version. Rearranged the library and somewhat changed the executable. Removed deprecated modules DobutokO.Poetry.Basic and DobutokO.Poetry +(instead you can use a generalized variant DobutokO.Poetry.General). Added new modules DobutokO.Poetry.Data and DobutokO.Poetry.General.Debug. +Added more functions to DobutokO.Poetry.Auxiliary module. Fixed issue with norms combining in the DobutokO.Poetry.Norms module and added the new function +combineNorms with the needed functionality. Changed the norm7 function in the DobutokO.Poetry.Norms.Extended module. Some documentation improvements. 
− DobutokO/Poetry.hs
@@ -1,217 +0,0 @@--- |--- Module      :  DobutokO.Poetry--- Copyright   :  (c) OleksandrZhabenko 2020--- License     :  MIT--- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com------ Helps to order the 7 or less Ukrainian words (or their concatenations) --- to obtain (to some extent) suitable for poetry or music text. --module DobutokO.Poetry (-  -- * Main functions-  uniq10Poetical4-  , uniq10Poetical5-  , uniq10PoeticalG-  , uniqNPoeticalG-  , uniqNPoeticalGN-  , uniqNPoeticalVGN-  -- * Additional functions-  , uniquenessVariantsGN-  , uniqMaxPoeticalGN-  -- * Generalized variants-  -- ** Main ones-  , uniqNPoetical2GN-  , uniqNPoetical2VGN-  , uniqNPoeticalUGN_-  , uniqNPoeticalUGN-  , uniqNPoeticalUGN51_-  , uniqNPoeticalUGN51-  -- ** Additional functions-  , uniqMaxPoetical2GN-  -- * On one line output-  , uniqNPoetical2GNLine-  -- * With all the norms used-  , uniqMaxPoeticalGNL-  , uniqNPoeticalGNL-  , uniqNPoeticalVGNL-  , uniqMaxPoetical2GNL-  , uniqNPoetical2GNL-  , uniqNPoetical2GNLineL-  , uniqNPoetical2VGNL-  , uniqNPoeticalUGNL_-  , uniqNPoeticalUGNL-) where--import Data.Char (isPunctuation)-import qualified Data.Vector as V-import Data.List ((\\))-import MMSyn7s-import DobutokO.Poetry.Norms-import DobutokO.Poetry.Auxiliary-import DobutokO.Poetry.UniquenessPeriodsG-import DobutokO.Poetry.StrictV-import DobutokO.Poetry.Basic---- | Returns the 'V.Vector' of all possible permutations of the 'String' that represent the Ukrainian text and the linked information with them for --- analysis with usage of several norms (instead of one). They constitute a 'V.Vector' of functions --- @norm :: [Int] -> Int@. So the inner vector in the each resulting 'Uniqueness' has the same length as the vector of norms.-uniquenessVariantsGN :: V.Vector ([Int] -> Int) -> String -> V.Vector Uniqueness-uniquenessVariantsGN vN = uniquenessVariants2GN vN (uniquenessPeriods)-{-# INLINE uniquenessVariantsGN #-}---- | A variant of the 'uniqMaxPoetical2GN' with the several norms given as a 'V.Vector' of functions and an 'Int' parameter. The function evaluates --- the generated 'V.Vector' of 'Uniqueness' elements to retrieve the possibly maximum element in it with respect to the order and significance (principality) --- of the norms being evaluated. The most significant and principal is the norm, 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 norm and so on.-uniqMaxPoeticalGN :: Int -> V.Vector ([Int] -> Int) ->  String -> Uniqueness-uniqMaxPoeticalGN k vN = uniqMaxPoetical2GN k vN (uniquenessPeriods)-{-# INLINE uniqMaxPoeticalGN #-}---- | Variant of 'uniqMaxPoeticalGN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqMaxPoeticalGNL :: V.Vector ([Int] -> Int) ->  String -> Uniqueness-uniqMaxPoeticalGNL vN = uniqMaxPoeticalGN (V.length vN) vN-{-# INLINE uniqMaxPoeticalGNL #-}---- | A variant of the 'uniqNPoeticalGN' with only one norm.-uniqNPoeticalG :: Int -> ([Int] -> Int) -> String -> IO ()-uniqNPoeticalG n g = uniqNPoeticalGN n 1 (V.singleton g)-{-# INLINE uniqNPoeticalG #-}---- | A variant of the 'uniqNPoeticalG' function with the @n@ equal to 10.-uniq10PoeticalG :: ([Int] -> Int) -> String -> IO ()-uniq10PoeticalG = uniqNPoeticalG 10-{-# INLINE uniq10PoeticalG #-}---- | A variant of 'uniq10PoeticalG' with the 'norm4' applied. The list is (according to some model, not universal, but a reasonable one in the most cases) the --- most suitable for intonation changing and, therefore, for the accompaniment of the highly changable or variative melody.-uniq10Poetical4 :: String -> IO ()-uniq10Poetical4 = uniq10PoeticalG norm4-{-# INLINE uniq10Poetical4 #-}---- | A variant of 'uniq10PoeticalG' with the 'norm5' applied. The list is (according to some model, not universal, but a reasonable one in the most cases) the --- most suitable for rhythmic speech and two-syllabilistic-based poetry. Therefore, it can be used to create a poetic composition or to emphasize some --- thoughts.-uniq10Poetical5 :: String -> IO ()-uniq10Poetical5 = uniq10PoeticalG norm5-{-# INLINE uniq10Poetical5 #-}---- | Variant of 'uniqNPoeticalVN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoeticalVNL :: Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO (V.Vector Uniqueness)-uniqNPoeticalVNL n vN = uniqNPoeticalVN n (V.length vN) vN-{-# INLINE uniqNPoeticalVNL #-}- --- | A variant of the 'uniqNPoetical2GN' with the conversion (\"uniquenessPeriods\" function) function 'uniquenessPeriods'.-uniqNPoeticalGN :: Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO ()-uniqNPoeticalGN n k vN = uniqNPoetical2GN n k vN (uniquenessPeriods)-{-# INLINE uniqNPoeticalGN #-}---- | Variant of 'uniqNPoeticalGN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoeticalGNL :: Int -> V.Vector ([Int] -> Int) -> String -> IO ()-uniqNPoeticalGNL n vN = uniqNPoetical2GNL n vN (uniquenessPeriods)-{-# INLINE uniqNPoeticalGNL #-}---- | Generalized variant of the 'uniqNPoeticalVG' with usage of several norms. -uniqNPoeticalVGN :: Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO (V.Vector Uniqueness)-uniqNPoeticalVGN n k vN = uniqNPoetical2VGN n k vN (uniquenessPeriods)-{-# INLINE uniqNPoeticalVGN #-}---- | Variant of 'uniqNPoeticalVGN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoeticalVGNL :: Int -> V.Vector ([Int] -> Int) -> String -> IO (V.Vector Uniqueness)-uniqNPoeticalVGNL n vN = uniqNPoetical2VGN n (V.length vN) vN (uniquenessPeriods)-{-# INLINE uniqNPoeticalVGNL #-}---- | The function evaluates --- the generated 'V.Vector' of 'Uniqueness' elements to retrieve the possibly maximum element in it with respect to the order and significance (principality) --- of the norms being evaluated. The most significant and principal is the norm, 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 norm and so on.-uniqMaxPoetical2GN :: Int -> V.Vector ([Int] -> Int) ->  (String -> [Int]) -> String -> Uniqueness-uniqMaxPoetical2GN k vN g xs- | compare k (V.length vN) == GT = error "DobutokO.Poetry.uniqMaxPoetical2GN: undefined for that amount of norms. "- | compare k 0 == GT =-   let vM = uniquenessVariants2GN vN g xs-       maxK = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 (k - 1)) (V.unsafeIndex vN1 (k - 1))) vM-       vK = V.filter (\(_,vN2,_) -> V.unsafeIndex vN2 (k - 1) == ((\(_,vNk,_) -> V.unsafeIndex vNk (k - 1)) maxK)) vM in-         uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) vK- | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) . uniquenessVariantsGN vN $ xs---- | Variant of 'uniqMaxPoetical2GN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqMaxPoetical2GNL :: V.Vector ([Int] -> Int) ->  (String -> [Int]) -> String -> Uniqueness-uniqMaxPoetical2GNL vN = uniqMaxPoetical2GN (V.length vN) vN-{-# INLINE uniqMaxPoetical2GNL #-}---- | Prints @n@ (given as the first 'Int' argument) maximum elements with respect to the several norms (their quantity is the second 'Int' argument) starting --- from the right to the left. The last norm is the first element in the 'V.Vector' of norms (@[Int] -> Int@).-uniqNPoetical2GN :: Int -> Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()-uniqNPoetical2GN n k vN g xs- | n == 0 = return ()- | otherwise = do-   let v = uniquenessVariants2GN vN g xs-   if compare (V.length v) n == LT-     then V.mapM_ (\x -> putStr ((filter (not . isPunctuation) . lastFrom3 $ x)) >> putStrLn "" ) v-     else (uniqInMaxPoeticalN k vN v >>= uniqNPoeticalN (n - 1) k vN)---- | Variant of 'uniqNPoetical2GN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoetical2GNL :: Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()-uniqNPoetical2GNL n vN = uniqNPoetical2GN n (V.length vN) vN-{-# INLINE uniqNPoetical2GNL #-}- --- | A variant of the 'uniqNPoetical2GN', but prints its output on the same line. -uniqNPoetical2GNLine :: Int -> Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()-uniqNPoetical2GNLine n k vN g xs- | n == 0 = putStrLn ""- | otherwise = do-   let v = uniquenessVariants2GN vN g xs-   if compare (V.length v) n == LT-     then V.mapM_ (\x -> putStr ((filter (not . isPunctuation) . lastFrom3 $ x)) >> putStr " " ) v >> putStrLn ""-     else (uniqInMaxPoeticalNLine k vN v >>= uniqNPoeticalNLine (n - 1) k vN)---- | Variant of 'uniqNPoetical2GNLine' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoetical2GNLineL :: Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()-uniqNPoetical2GNLineL n vN = uniqNPoetical2GNLine n (V.length vN) vN-{-# INLINE uniqNPoetical2GNLineL #-}- --- | Prints @n@ (given as the first 'Int' argument) maximum elements with respect to the several norms (their quantity is the second 'Int' argument) starting --- from the right to the left. The last norm is the first element in the 'V.Vector' of norms (@[Int] -> Int@). Contrary to its pair function --- 'uniqNPoetical2GN' returns then the rest of the given 'V.Vector' 'Uniqueness' after filtering the printed elements 'String'.-uniqNPoetical2VGN :: Int -> Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO (V.Vector Uniqueness)-uniqNPoetical2VGN n k vN g xs- | n == 0 = return V.empty- | otherwise = do-   let v = uniquenessVariants2GN vN g xs-   if compare (V.length v) n == LT then return v else uniqNPoeticalVN n k vN v---- | Variant of 'uniqNPoetical2VGN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoetical2VGNL :: Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO (V.Vector Uniqueness)-uniqNPoetical2VGNL n vN = uniqNPoetical2VGN n (V.length vN) vN-{-# INLINE uniqNPoetical2VGNL #-}- --- | Variant of the 'uniqNPoetical2GN', which uses as a function 'uniquenessPeriods2' with the first argument equal to the first 'Int' argument.-uniqNPoeticalUGN_ :: Int -> Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO ()-uniqNPoeticalUGN_ x n k vN = uniqNPoetical2GN n k vN (uniquenessPeriods2 x)-{-# INLINE uniqNPoeticalUGN_ #-}---- | Variant of 'uniqNPoeticalUGN_' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoeticalUGNL_ :: Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO ()-uniqNPoeticalUGNL_ x n vN = uniqNPoetical2GNL n vN (uniquenessPeriods2 x)-{-# INLINE uniqNPoeticalUGNL_ #-}---- | Variant of the 'uniqNPoetical2VGN', which uses as a function 'uniquenessPeriods2' with the first argument equal to the first 'Int' argument.-uniqNPoeticalUGN :: Int -> Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO (V.Vector Uniqueness)-uniqNPoeticalUGN x n k vN = uniqNPoetical2VGN n k vN (uniquenessPeriods2 x)-{-# INLINE uniqNPoeticalUGN #-}---- | Variant of 'uniqNPoeticalUGN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoeticalUGNL :: Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO (V.Vector Uniqueness)-uniqNPoeticalUGNL x n vN = uniqNPoetical2VGN n (V.length vN) vN (uniquenessPeriods2 x)-{-# INLINE uniqNPoeticalUGNL #-}---- | Variant of the 'uniqNPoeticalUGN_', which uses as a single norm 'norm51'.-uniqNPoeticalUGN51_ :: Int -> Int -> String -> IO ()-uniqNPoeticalUGN51_ x n = uniqNPoeticalUGN_ x n 1 (V.singleton norm51)-{-# INLINE uniqNPoeticalUGN51_ #-}---- | Variant of the 'uniqNPoeticalUGN', which uses as a single norm 'norm51'.-uniqNPoeticalUGN51 :: Int -> Int -> String -> IO (V.Vector Uniqueness)-uniqNPoeticalUGN51 x n = uniqNPoeticalUGN x n 1 (V.singleton norm51)-{-# INLINE uniqNPoeticalUGN51 #-}
DobutokO/Poetry/Auxiliary.hs view
@@ -11,9 +11,18 @@ module DobutokO.Poetry.Auxiliary (   -- * Help functions   lastFrom3+  , firstFrom3+  , secondFrom3 ) where  lastFrom3 :: (a,b,c) -> c lastFrom3 (_,_,z) = z {-# INLINE lastFrom3 #-} +firstFrom3 :: (a, b, c) -> a+firstFrom3 (x, _, _) = x+{-# INLINE firstFrom3 #-}++secondFrom3 :: (a, b, c) -> b+secondFrom3 (_, y, _) = y+{-# INLINE secondFrom3 #-}
− DobutokO/Poetry/Basic.hs
@@ -1,119 +0,0 @@--- |--- Module      :  DobutokO.Poetry.Basic--- Copyright   :  (c) OleksandrZhabenko 2020--- License     :  MIT--- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com------ Helps to order the 7 or less Ukrainian words (or their concatenations) --- to obtain (to some extent) suitable for poetry or music text. --module DobutokO.Poetry.Basic (-  Uniqueness-  -- * Main functions-  , uniqNPoeticalN-  , uniqNPoeticalVN-  -- * Additional functions-  , uniqMaxPoeticalGNV-  , uniqInMaxPoeticalN-  -- * On one line output-  , uniqInMaxPoeticalNLine-  , uniqNPoeticalNLine-  -- * With all the norms used-  , uniqInMaxPoeticalNL-  , uniqInMaxPoeticalNLineL-  , uniqNPoeticalNL-  , uniqNPoeticalNLineL-  , uniqNPoeticalVNL-  , uniqMaxPoeticalGNVL-) where--import Data.Char (isPunctuation)-import qualified Data.Vector as V-import DobutokO.Poetry.Auxiliary--type Uniqueness = ([Int],V.Vector Int,String)---- | Prints the maximum element with respect of the @k@ norms (the most significant of which is the rightest one, then to the left less significant etc.), --- which is given as the first argument. The last norm is the first element in the 'V.Vector' of norms (@[Int] -> Int@). -uniqInMaxPoeticalN :: Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO (V.Vector Uniqueness)-uniqInMaxPoeticalN k vN v = do-  let uniq = uniqMaxPoeticalGNV k vN v-  let fsT = (\(ys,_,_) -> ys) uniq-  putStr (filter (not . isPunctuation) . lastFrom3 $ uniq) >> putStrLn ""-  return . V.filter (\(xs,_,_) -> xs /= fsT) $ v---- | Variant of 'uniqInMaxPoticalN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqInMaxPoeticalNL :: V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO (V.Vector Uniqueness)-uniqInMaxPoeticalNL vN = uniqInMaxPoeticalN (V.length vN) vN-{-# INLINE uniqInMaxPoeticalNL #-}---- | Generalized variant of the 'uniqInMaxPoeticalN' with usage of the several norms and all the information is printed on the same line. -uniqInMaxPoeticalNLine :: Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO (V.Vector Uniqueness)-uniqInMaxPoeticalNLine k vN v = do-  let uniq = uniqMaxPoeticalGNV k vN v-  let fsT = (\(ys,_,_) -> ys) uniq-  putStr (filter (not . isPunctuation) . lastFrom3 $ uniq) >> putStr " "-  return . V.filter (\(xs,_,_) -> xs /= fsT) $ v---- | Variant of 'uniqInMaxPoticalNLine' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqInMaxPoeticalNLineL :: V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO (V.Vector Uniqueness)-uniqInMaxPoeticalNLineL vN = uniqInMaxPoeticalNLine (V.length vN) vN-{-# INLINE uniqInMaxPoeticalNLineL #-}---- | Prints @n@ (given as the first argument) maximum elements with respect to the several norms (their quantity is the second argument) starting --- from the right to the left. The last norm is the first element in the 'V.Vector' of norms (@[Int] -> Int@). -uniqNPoeticalN :: Int -> Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO ()-uniqNPoeticalN n k vN v- | n == 0 = return ()- | compare (V.length v) n == LT = V.mapM_ (\x -> putStr (filter (not . isPunctuation) . lastFrom3 $ x) >> putStrLn "" ) v- | otherwise = (uniqInMaxPoeticalN k vN v >>= uniqNPoeticalN (n - 1) k vN)---- | Variant of 'uniqNPoeticalN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoeticalNL :: Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO ()-uniqNPoeticalNL n vN = uniqNPoeticalN n (V.length vN) vN-{-# INLINE uniqNPoeticalNL #-}---- | Variant of the 'uniqNPoeticalN' with its output being printed on the same line.-uniqNPoeticalNLine :: Int -> Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO ()-uniqNPoeticalNLine n k vN v- | n == 0 = putStrLn ""- | compare (V.length v) n == LT = V.mapM_ (\x -> putStr (filter (not . isPunctuation) . lastFrom3 $ x) >> putStr " " ) v  >> putStrLn ""- | otherwise = (uniqInMaxPoeticalNLine k vN v >>= uniqNPoeticalNLine (n - 1) k vN)---- | Variant of 'uniqNPoeticalNLine' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoeticalNLineL :: Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO ()-uniqNPoeticalNLineL n vN = uniqNPoeticalNLine n (V.length vN) vN-{-# INLINE uniqNPoeticalNLineL #-}---- | Prints @n@ (given as the first argument) maximum elements with respect to the several norms (their quantity is the second argument) starting --- from the right to the left. The last norm is the first element in the 'V.Vector' of norms (@[Int] -> Int@). Contrary to its pair function --- 'uniqNPoeticalN' returns then the rest of the given 'V.Vector' 'Uniqueness' after filtering the printed elements 'String'.-uniqNPoeticalVN :: Int -> Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO (V.Vector Uniqueness)-uniqNPoeticalVN n k vN v- | n == 0 || compare (V.length v) n == LT = return v- | otherwise = (uniqInMaxPoeticalN k vN v >>= uniqNPoeticalVN (n - 1) k vN)---- | Variant of 'uniqNPoeticalVN' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqNPoeticalVNL :: Int -> V.Vector ([Int] -> Int) -> V.Vector Uniqueness -> IO (V.Vector Uniqueness)-uniqNPoeticalVNL n vN = uniqNPoeticalVN n (V.length vN) vN-{-# INLINE uniqNPoeticalVNL #-}---- | The function evaluates the 'V.Vector' of 'Uniqueness' elements to retrieve the possibly maximum element in it with respect to the order --- and significance (principality)  of the norms being evaluated. The most significant and principal is the norm, 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 norm and so on. Is similar to 'DobutokO.Poetry.uniqMaxPoeticalGN' --- function.-uniqMaxPoeticalGNV :: Int -> V.Vector ([Int] -> Int) ->  V.Vector Uniqueness -> Uniqueness-uniqMaxPoeticalGNV k vN vM- | compare k (V.length vN) == GT = error "DobutokO.Poetry.Basic.uniqMaxPoeticalGNV: undefined for that amount of norms. "- | compare k 0 == GT =-   let maxK = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 (k - 1)) (V.unsafeIndex vN1 (k - 1))) vM-       vK = V.filter (\(_,vN2,_) -> V.unsafeIndex vN2 (k - 1) == ((\(_,vNk,_) -> V.unsafeIndex vNk (k - 1)) maxK)) vM in-         uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) vK- | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) vM---- | Variant of 'uniqMaxPoeticalGNV' where all the elements in the norms 'V.Vector' are used as norms from right to left.-uniqMaxPoeticalGNVL :: V.Vector ([Int] -> Int) ->  V.Vector Uniqueness -> Uniqueness-uniqMaxPoeticalGNVL vN = uniqMaxPoeticalGNV (V.length vN) vN-{-# INLINE uniqMaxPoeticalGNVL #-}-
+ DobutokO/Poetry/Data.hs view
@@ -0,0 +1,84 @@+-- |+-- Module      :  DobutokO.Poetry.Data+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Helps to order the 7 or less Ukrainian words (or their concatenations) +-- to obtain (to some extent) suitable for poetry or music text. +-- This module contains data types needed for some generalizations.+-- ++{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}++module DobutokO.Poetry.Data where++import Data.Maybe (fromJust)+import Data.Char (isPunctuation)+import qualified Data.Vector as V+import DobutokO.Poetry.Auxiliary (lastFrom3)++type Uniqueness = ([Int],V.Vector Int,String)++-- | The list in the 'PA' variant represent the prepending 'String' and the postpending one respectively. 'K' constuctor actually means no prepending and +-- postpending of the text. Are used basically to control the behaviour of the functions.+data PreApp a = K | PA [a] [a] deriving Eq++class G1 a b where+  get1m :: a -> [b]+  get2m :: a -> [b]+  getm :: Bool -> a -> [b]+  getm True = get1m+  getm _ = get2m+  preapp :: a -> [[b]] -> [[b]]+  setm :: [b] -> [b] -> a+  +instance G1 (PreApp Char) Char where+  get1m K = []+  get1m (PA xs _) = xs+  get2m K = []+  get2m (PA _ ys) = ys+  preapp K xss = xss+  preapp (PA xs ys) yss = xs:yss ++ [ys]+  setm [] [] = K+  setm xs ys = PA xs ys++type Preapp = PreApp Char++isPA :: PreApp a -> Bool+isPA K = False+isPA _ = True++isK :: PreApp a -> Bool+isK K = True+isK _ = False++-- | Is used to control whether to return data or only to print the needed information. The 'U' contstuctor corresponds to the information printing and 'UL' to +-- returning also data. The last one so can be further used.+data UniquenessG a b = U b | UL ([a],b) deriving Eq++instance Show (UniquenessG String (V.Vector Uniqueness)) where+  show (U v) = show . V.map (filter (not . isPunctuation) . lastFrom3) $ v+  show (UL (wss,_)) = show . map (filter (not . isPunctuation)) $ wss++type UniqG = UniquenessG String (V.Vector Uniqueness)  ++-- | Decomposes the data type 'UniqG' into its components. The inverse to the 'set2'.+get2 :: UniqG -> (Maybe [String], V.Vector Uniqueness)+get2 (U v) = (Nothing,v)+get2 (UL (wss,v)) = (Just wss,v)++-- | Compose the data type 'UniqG' from its components. The inverse to the 'get2'.+set2 :: (Maybe [String], V.Vector Uniqueness) -> UniqG+set2 (Just wss, v) = UL (wss,v)+set2 (Nothing, v) = U v++isU :: UniqG -> Bool+isU (U _) = True+isU _ = False++isUL :: UniqG -> Bool+isUL (UL _) = True+isUL _ = False+
DobutokO/Poetry/General.hs view
@@ -14,8 +14,6 @@ -- postpending 'String' in the 'PreApp' data type so that they are added  -- respectively to the beginning or to the end of the strings. -{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}- module DobutokO.Poetry.General where  import Data.Maybe (fromJust)@@ -27,68 +25,7 @@ import DobutokO.Poetry.Auxiliary import DobutokO.Poetry.UniquenessPeriodsG import DobutokO.Poetry.StrictV-import DobutokO.Poetry.Basic (Uniqueness)---- | The list in the 'PA' variant represent the prepending 'String' and the postpending one respectively. 'K' constuctor actually means no prepending and --- postpending of the text. Are used basically to control the behaviour of the functions.-data PreApp a = K | PA [a] [a] deriving Eq--class G1 a b where-  get1m :: a -> [b]-  get2m :: a -> [b]-  getm :: Bool -> a -> [b]-  getm True = get1m-  getm _ = get2m-  preapp :: a -> [[b]] -> [[b]]-  setm :: [b] -> [b] -> a-  -instance G1 (PreApp Char) Char where-  get1m K = []-  get1m (PA xs _) = xs-  get2m K = []-  get2m (PA _ ys) = ys-  preapp K xss = xss-  preapp (PA xs ys) yss = xs:yss ++ [ys]-  setm [] [] = K-  setm xs ys = PA xs ys--type Preapp = PreApp Char--isPA :: PreApp a -> Bool-isPA K = False-isPA _ = True--isK :: PreApp a -> Bool-isK K = True-isK _ = False---- | Is used to control whether to return data or only to print the needed information. The 'U' contstuctor corresponds to the information printing and 'UL' to --- returning also data. The last one so can be further used.-data UniquenessG a b = U b | UL ([a],b) deriving Eq--instance Show (UniquenessG String (V.Vector Uniqueness)) where-  show (U v) = show . V.map (filter (not . isPunctuation) . lastFrom3) $ v-  show (UL (wss,_)) = show . map (filter (not . isPunctuation)) $ wss--type UniqG = UniquenessG String (V.Vector Uniqueness)  ---- | Decomposes the data type 'UniqG' into its components. The inverse to the 'set2'.-get2 :: UniqG -> (Maybe [String], V.Vector Uniqueness)-get2 (U v) = (Nothing,v)-get2 (UL (wss,v)) = (Just wss,v)---- | Compose the data type 'UniqG' from its components. The inverse to the 'get2'.-set2 :: (Maybe [String], V.Vector Uniqueness) -> UniqG-set2 (Just wss, v) = UL (wss,v)-set2 (Nothing, v) = U v--isU :: UniqG -> Bool-isU (U _) = True-isU _ = False--isUL :: UniqG -> Bool-isUL (UL _) = True-isUL _ = False+import DobutokO.Poetry.Data  -- | Prints the maximum element with respect of the @k@ norms (the most significant of which is the rightest one, then to the left less significant etc.),  -- which is given as the first argument. The last norm is the first element in the 'V.Vector' of norms (@[Int] -> Int@). 
+ DobutokO/Poetry/General/Debug.hs view
@@ -0,0 +1,236 @@+-- |+-- Module      :  DobutokO.Poetry.General.Debug+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Helps to order the 7 or less Ukrainian words (or their concatenations) +-- to obtain (to some extent) suitable for poetry or music text. +-- Functions in this module behaves just like their corresponding from the +-- 'DobutokO.Poetry.General' module with that difference of being more +-- informative and printing more output with the lists and 'V.Vector'.+-- Because of that, printing the output on the one line is not needed and +-- therefore the corresponding one line functions are omitted.+-- Can be useful for debugging and exploration purposes. +-- ++module DobutokO.Poetry.General.Debug where++import Data.Maybe (fromJust)+import Data.Char (isPunctuation)+import qualified Data.Vector as V+import MMSyn7s+import DobutokO.Poetry.Norms+import DobutokO.Poetry.Norms.Extended+import DobutokO.Poetry.Auxiliary+import DobutokO.Poetry.UniquenessPeriodsG+import DobutokO.Poetry.StrictV+import DobutokO.Poetry.Data++-- | Behaves like the function 'DobutokO.Poetry.General.uniqInMaxPoeticalN', but prints more information for debugging and tuning purposes. +uniqInMaxPoeticalN :: Int -> V.Vector ([Int] -> Int) -> UniqG -> IO UniqG+uniqInMaxPoeticalN k vN x = do+  inner1 k vN x >>= \(fsT,x) -> +    if isU x then return (U (V.filter (\(xs,_,_) -> xs /= fsT) . snd . get2 $ x))+    else return (UL ((\(v1,v2) -> ((V.toList . V.map (filter (not . isPunctuation) . lastFrom3) $ v1) ++ (fromJust . fst . get2 $ x),v2)) . +      V.unstablePartition (\(xs,_,_) -> xs == fsT) . snd . get2 $ x))+{-# INLINE uniqInMaxPoeticalN #-}++-- | Behaves like the function 'DobutokO.Poetry.General.inner1', but prints more information for debugging and tuning purposes. +inner1 :: Int -> V.Vector ([Int] -> Int) -> UniqG -> IO ([Int],UniqG)+inner1 k vN x = do +  let uniq = uniqMaxPoeticalGNV k vN x+  let fsT = (\(ys,_,_) -> ys) uniq+  putStrLn (filter (not . isPunctuation) . lastFrom3 $ uniq)+  putStrLn . show . firstFrom3 $ uniq+  putStrLn . show . secondFrom3 $ uniq+  return (fsT,x)+{-# INLINE inner1 #-}  ++-- | Behaves like the function 'DobutokO.Poetry.General.uniqInMaxPoeticalNL', but prints more information for debugging and tuning purposes. +uniqInMaxPoeticalNL :: V.Vector ([Int] -> Int) -> UniqG -> IO UniqG+uniqInMaxPoeticalNL vN x = uniqInMaxPoeticalN (V.length vN) vN x+{-# INLINE uniqInMaxPoeticalNL #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalN', but prints more information for debugging and tuning purposes. +uniqNPoeticalN :: Int -> Int -> V.Vector ([Int] -> Int) -> UniqG -> IO ()+uniqNPoeticalN n k vN y  + | n <= 0 = return ()+ | compare (V.length . snd . get2 $ y) n == LT = V.mapM_ (\x -> do +   { putStrLn (filter (not . isPunctuation) . lastFrom3 $ x) +   ; putStrLn . show . firstFrom3 $ x+   ; putStrLn . show . secondFrom3 $ x}) . snd . get2 $ y+ | otherwise = (uniqInMaxPoeticalN k vN y >>= uniqNPoeticalN (n - 1) k vN)+{-# INLINE uniqNPoeticalN #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalNL', but prints more information for debugging and tuning purposes. +uniqNPoeticalNL :: Int -> V.Vector ([Int] -> Int) -> UniqG -> IO ()+uniqNPoeticalNL n vN = uniqNPoeticalN n (V.length vN) vN+{-# INLINE uniqNPoeticalNL #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalVN', but prints more information for debugging and tuning purposes. +uniqNPoeticalVN :: Int -> Int -> V.Vector ([Int] -> Int) -> UniqG -> IO UniqG+uniqNPoeticalVN n k vN y+ | n <= 0 || compare (V.length . snd . get2 $ y) n == LT = return y+ | otherwise = (uniqInMaxPoeticalN k vN y >>= uniqNPoeticalVN (n - 1) k vN)+{-# INLINE uniqNPoeticalVN #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalVNL', but prints more information for debugging and tuning purposes. +uniqNPoeticalVNL :: Int -> V.Vector ([Int] -> Int) -> UniqG -> IO UniqG+uniqNPoeticalVNL n vN = uniqNPoeticalVN n (V.length vN) vN+{-# INLINE uniqNPoeticalVNL #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqMaxPoeticalGNV', but prints more information for debugging and tuning purposes. +uniqMaxPoeticalGNV :: Int -> V.Vector ([Int] -> Int) ->  UniqG -> Uniqueness+uniqMaxPoeticalGNV k vN y+ | compare k (V.length vN) == GT = error "DobutokO.Poetry.General.Debug.uniqMaxPoeticalGNV: undefined for that amount of norms. "+ | compare k 0 == GT =+   let maxK = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 (k - 1)) (V.unsafeIndex vN1 (k - 1))) . snd . get2 $ y+       vK = V.filter (\(_,vN2,_) -> V.unsafeIndex vN2 (k - 1) == ((\(_,vNk,_) -> V.unsafeIndex vNk (k - 1)) maxK)) . snd . get2 $ y in+         if isU y then uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) (U vK)+         else uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) (UL (fromJust . fst . get2 $ y,vK))+ | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) . snd . get2 $ y+{-# INLINE uniqMaxPoeticalGNV #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqMaxPoeticalGNVL', but prints more information for debugging and tuning purposes. +uniqMaxPoeticalGNVL :: V.Vector ([Int] -> Int) ->  UniqG -> Uniqueness+uniqMaxPoeticalGNVL vN = uniqMaxPoeticalGNV (V.length vN) vN+{-# INLINE uniqMaxPoeticalGNVL #-}++---------------------------------------------------------------------------------++-- | Behaves like the function 'DobutokO.Poetry.General.uniquenessVariantsGN', but prints more information for debugging and tuning purposes. +uniquenessVariantsGN :: Preapp -> V.Vector ([Int] -> Int) -> String -> V.Vector Uniqueness+uniquenessVariantsGN (PA ts us) vN = uniquenessVariants2GNP ts us vN (uniquenessPeriods)+uniquenessVariantsGN K vN = uniquenessVariants2GN vN (uniquenessPeriods)+{-# INLINE uniquenessVariantsGN #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqMaxPoeticalGN', but prints more information for debugging and tuning purposes. +uniqMaxPoeticalGN :: Preapp -> Int -> V.Vector ([Int] -> Int) ->  String -> Uniqueness+uniqMaxPoeticalGN x k vN = uniqMaxPoetical2GN x k vN (uniquenessPeriods)+{-# INLINE uniqMaxPoeticalGN #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqMaxPoeticalGNL', but prints more information for debugging and tuning purposes. +uniqMaxPoeticalGNL :: Preapp -> V.Vector ([Int] -> Int) ->  String -> Uniqueness+uniqMaxPoeticalGNL x vN = uniqMaxPoeticalGN x (V.length vN) vN+{-# INLINE uniqMaxPoeticalGNL #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalG', but prints more information for debugging and tuning purposes. +uniqNPoeticalG :: Preapp -> Int -> ([Int] -> Int) -> String -> IO ()+uniqNPoeticalG x n g = uniqNPoeticalGN x n 1 (V.singleton g)+{-# INLINE uniqNPoeticalG #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniq10PoeticalG', but prints more information for debugging and tuning purposes. +uniq10PoeticalG :: Preapp -> ([Int] -> Int) -> String -> IO ()+uniq10PoeticalG x = uniqNPoeticalG x 10+{-# INLINE uniq10PoeticalG #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniq10Poetical4', but prints more information for debugging and tuning purposes. +uniq10Poetical4 :: Preapp -> String -> IO ()+uniq10Poetical4 x = uniq10PoeticalG x norm4+{-# INLINE uniq10Poetical4 #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniq10Poetical5', but prints more information for debugging and tuning purposes. +uniq10Poetical5 :: Preapp -> String -> IO ()+uniq10Poetical5 x = uniq10PoeticalG x norm5+{-# INLINE uniq10Poetical5 #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalGN', but prints more information for debugging and tuning purposes. +uniqNPoeticalGN :: Preapp -> Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO ()+uniqNPoeticalGN x n k vN = uniqNPoetical2GN x n k vN (uniquenessPeriods)+{-# INLINE uniqNPoeticalGN #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalGNL', but prints more information for debugging and tuning purposes. +uniqNPoeticalGNL :: Preapp -> Int -> V.Vector ([Int] -> Int) -> String -> IO ()+uniqNPoeticalGNL x n vN = uniqNPoetical2GNL x n vN (uniquenessPeriods)+{-# INLINE uniqNPoeticalGNL #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalVGN', but prints more information for debugging and tuning purposes. +uniqNPoeticalVGN :: Preapp -> Int -> Int -> V.Vector ([Int] -> Int) -> UniqG -> String -> IO UniqG+uniqNPoeticalVGN x n k vN = uniqNPoetical2VGN x n k vN (uniquenessPeriods)+{-# INLINE uniqNPoeticalVGN #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalVGNL', but prints more information for debugging and tuning purposes. +uniqNPoeticalVGNL :: Preapp -> Int -> V.Vector ([Int] -> Int) -> UniqG -> String -> IO UniqG+uniqNPoeticalVGNL x n vN = uniqNPoetical2VGN x n (V.length vN) vN (uniquenessPeriods)+{-# INLINE uniqNPoeticalVGNL #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqMaxPoetical2GN', but prints more information for debugging and tuning purposes. +uniqMaxPoetical2GN :: Preapp -> Int -> V.Vector ([Int] -> Int) ->  (String -> [Int]) -> String -> Uniqueness+uniqMaxPoetical2GN rr k vN g xs+ | compare k (V.length vN) == GT = error "DobutokO.Poetry.General.Debug.uniqMaxPoetical2GN: undefined for that amount of norms. "+ | compare k 0 == GT =+   let vM = uniquenessVariants2GNP (get1m rr) (get2m rr) vN g xs+       maxK = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 (k - 1)) (V.unsafeIndex vN1 (k - 1))) vM+       vK = V.filter (\(_,vN2,_) -> V.unsafeIndex vN2 (k - 1) == ((\(_,vNk,_) -> V.unsafeIndex vNk (k - 1)) maxK)) vM in+         uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) (U vK)+ | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) . uniquenessVariantsGN rr vN $ xs++-- | Behaves like the function 'DobutokO.Poetry.General.uniqMaxPoetical2GNL', but prints more information for debugging and tuning purposes. +uniqMaxPoetical2GNL :: Preapp -> V.Vector ([Int] -> Int) ->  (String -> [Int]) -> String -> Uniqueness+uniqMaxPoetical2GNL rr vN = uniqMaxPoetical2GN rr (V.length vN) vN+{-# INLINE uniqMaxPoetical2GNL #-}+  +-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoetical2GN', but prints more information for debugging and tuning purposes. +uniqNPoetical2GN :: Preapp -> Int -> Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()+uniqNPoetical2GN rr n k vN g xs+ | n <= 0 = return ()+ | otherwise = do+   let v = uniquenessVariants2GNP (get1m rr) (get2m rr) vN g xs+   if compare (V.length v) n == LT+     then V.mapM_ (\x -> do +       { putStrLn ((filter (not . isPunctuation) . lastFrom3 $ x)) +       ; putStrLn . show . firstFrom3 $ x+       ; putStrLn . show . secondFrom3 $ x}) v+     else (uniqInMaxPoeticalN k vN (U v) >>= uniqNPoeticalN (n - 1) k vN)++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoetical2GNL', but prints more information for debugging and tuning purposes. +uniqNPoetical2GNL :: Preapp -> Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> String -> IO ()+uniqNPoetical2GNL rr n vN = uniqNPoetical2GN rr n (V.length vN) vN+{-# INLINE uniqNPoetical2GNL #-}+ +-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoetical2VGN', but prints more information for debugging and tuning purposes. +uniqNPoetical2VGN :: Preapp -> Int -> Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> UniqG -> String -> IO UniqG+uniqNPoetical2VGN rr n k vN g y xs+ | n <= 0 = if isU y then return (U V.empty) else return (UL ([],V.empty))+ | otherwise = do+   let v = uniquenessVariants2GNP (get1m rr) (get2m rr) vN g xs+   if compare (V.length v) n == LT +     then if isU y then return (U v) else return (UL ([],v)) +     else if isU y then uniqNPoeticalVN n k vN (U v) else uniqNPoeticalVN n k vN (UL ([],v))++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoetical2VGNL', but prints more information for debugging and tuning purposes. +uniqNPoetical2VGNL :: Preapp -> Int -> V.Vector ([Int] -> Int) -> (String -> [Int]) -> UniqG -> String -> IO UniqG+uniqNPoetical2VGNL rr n vN = uniqNPoetical2VGN rr n (V.length vN) vN+{-# INLINE uniqNPoetical2VGNL #-}+ +-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalUGN_', but prints more information for debugging and tuning purposes. +uniqNPoeticalUGN_ :: Preapp -> Int -> Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO ()+uniqNPoeticalUGN_ rr x n k vN = uniqNPoetical2GN rr n k vN (uniquenessPeriods2 x)+{-# INLINE uniqNPoeticalUGN_ #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalUGNL_', but prints more information for debugging and tuning purposes. +uniqNPoeticalUGNL_ :: Preapp -> Int -> Int -> V.Vector ([Int] -> Int) -> String -> IO ()+uniqNPoeticalUGNL_ rr x n vN = uniqNPoetical2GNL rr n vN (uniquenessPeriods2 x)+{-# INLINE uniqNPoeticalUGNL_ #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalUGN', but prints more information for debugging and tuning purposes. +uniqNPoeticalUGN :: Preapp -> Int -> Int -> Int -> V.Vector ([Int] -> Int) -> UniqG -> String -> IO UniqG+uniqNPoeticalUGN rr x n k vN = uniqNPoetical2VGN rr n k vN (uniquenessPeriods2 x)+{-# INLINE uniqNPoeticalUGN #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalUGNL', but prints more information for debugging and tuning purposes. +uniqNPoeticalUGNL :: Preapp -> Int -> Int -> V.Vector ([Int] -> Int) -> UniqG -> String -> IO UniqG+uniqNPoeticalUGNL rr x n vN = uniqNPoetical2VGN rr n (V.length vN) vN (uniquenessPeriods2 x)+{-# INLINE uniqNPoeticalUGNL #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalUGN51_', but prints more information for debugging and tuning purposes. +uniqNPoeticalUGN51_ :: Preapp -> Int -> Int -> String -> IO ()+uniqNPoeticalUGN51_ rr x n = uniqNPoeticalUGN_ rr x n 1 (V.singleton norm51)+{-# INLINE uniqNPoeticalUGN51_ #-}++-- | Behaves like the function 'DobutokO.Poetry.General.uniqNPoeticalUGN51', but prints more information for debugging and tuning purposes. +uniqNPoeticalUGN51 :: Preapp -> Int -> Int -> UniqG -> String -> IO UniqG+uniqNPoeticalUGN51 rr x n = uniqNPoeticalUGN rr x n 1 (V.singleton norm51)+{-# INLINE uniqNPoeticalUGN51 #-}
DobutokO/Poetry/Norms.hs view
@@ -25,6 +25,8 @@   , norm8   -- * Norms combining   , splitNorm+  -- ** More complex combining+  , combineNorms   , flSplitNorms   , normSplit   , normSplitWeighted@@ -138,10 +140,16 @@     let (ys,zs) = break (== 0) xs          zzs = drop 1 zs         in (V.unsafeIndex vN (V.length vN - 1)) ys:splitNorm zzs (V.unsafeSlice 0 (V.length vN - 1) vN)+        +-- | Applies all the given norms in the 'V.Vector' to the first argument and collects the result as a list.+combineNorms :: [Int] -> V.Vector ([Int] -> Int) -> [Int]+combineNorms xs vN + | null xs = []+ | otherwise = V.toList . V.map (\f -> f xs) $ vN --- | The flipped variant of the 'splitNorm' (can be more convenient for applications).+-- | The flipped variant of the 'combineNorms' (can be more convenient for applications). flSplitNorms :: V.Vector ([Int] -> Int) -> [Int] -> [Int]-flSplitNorms = flip splitNorm+flSplitNorms = flip combineNorms {-# INLINE flSplitNorms #-}  -- | Using 'splitNorm' and given a group of norms (represented as a 'V.Vector') returns the sum of their applications. These norms are equally important 
DobutokO/Poetry/Norms/Extended.hs view
@@ -26,8 +26,8 @@ norm7 l xs   | null xs = 0  | otherwise = -    let n = ((abs l `rem` 101) * length xs) `quot` 10 -        m = abs (length xs - (24 `quot` n))+    let n = ((abs l `rem` 101) * length xs) `quot` 10+        m = abs ((length xs `quot` 3) - (n `quot` 2))         ys = if compare (minimum xs) 1 /= GT then filter (\t -> compare t 1 == GT) xs else xs \\ [minimum xs] in       if null ys then sum xs else (n * sum xs) `quot` ((sum . take n . sort $ xs) + m * maximum xs) {-# INLINE norm7 #-}   
Main.hs view
@@ -12,7 +12,8 @@  import Control.Exception (onException) import System.IO-import DobutokO.Poetry (uniqNPoeticalG)+import DobutokO.Poetry.General (uniqNPoeticalG)+import DobutokO.Poetry.Data (PreApp(K)) import DobutokO.Poetry.Norms (norm4,norm5,norm51,norm513,norm6) import System.Environment (getArgs) import Melodics.Executable (recFileName, printInfoF, rawToSoundFile)@@ -37,11 +38,11 @@     let aa = read arg01::Int     return aa) (return 10)   case (arg0,arg1) of-   ("4",n) -> uniqNPoeticalG n norm4 word1s-   ("51",n) -> uniqNPoeticalG n norm51 word1s -   ("513",n) -> uniqNPoeticalG n norm513 word1s-   ("6",n) -> uniqNPoeticalG n norm6 word1s -   ~(_,n) -> uniqNPoeticalG n norm5 word1s +   ("4",n) -> uniqNPoeticalG K n norm4 word1s+   ("51",n) -> uniqNPoeticalG K n norm51 word1s +   ("513",n) -> uniqNPoeticalG K n norm513 word1s+   ("6",n) -> uniqNPoeticalG K n norm6 word1s +   ~(_,n) -> uniqNPoeticalG K n norm5 word1s    putStrLn "What string would you like to record as a Ukrainian text sounding by mmsyn6ukr package? "   str <- getLine   nameAndRec str
README.md view
@@ -10,7 +10,7 @@ the words order and only with the most needed grammar  preserved (for example, the rule not to separate the preposition and  the next word is preserved). Understand just like you can -read the text (after some instruction and training might be) the text +read the text (after some instruction and training might be)  with the words where only the first and the last letters  are preserved on their places and the rest are interchangeably mixed.  So imagine, you can understand (and express your thoughts, @@ -38,4 +38,4 @@ where phonetics is of more importance than the grammar, then you  can evaluate the phonetic potential of the words used in the text  in producing specially sounding texts. This can also be helpful -in poetry writing and other probably related fields+in poetry writing and other probably related fields.
dobutokO-poetry.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                dobutokO-poetry-version:             0.10.0.0+version:             0.11.0.0 synopsis:            Helps to order the 7 or less Ukrainian words to obtain somewhat suitable for poetry or music text description:         Helps to order the 7 or less Ukrainian words (or their concatenations) to obtain somewhat suitable for poetry or music text. Can be also used as a research instrument with generalized functions. @@ -18,7 +18,7 @@ cabal-version:       >=1.10  library-  exposed-modules:     DobutokO.Poetry.Basic, DobutokO.Poetry, DobutokO.Poetry.StrictV, DobutokO.Poetry.Auxiliary, DobutokO.Poetry.Norms, DobutokO.Poetry.Norms.Extended, DobutokO.Poetry.UniquenessPeriodsG, Main, DobutokO.Poetry.General+  exposed-modules:     DobutokO.Poetry.StrictV, DobutokO.Poetry.Auxiliary, DobutokO.Poetry.Norms, DobutokO.Poetry.Norms.Extended, DobutokO.Poetry.UniquenessPeriodsG, Main, DobutokO.Poetry.General, DobutokO.Poetry.General.Debug, DobutokO.Poetry.Data   -- other-modules:   other-extensions:    BangPatterns, CPP, FlexibleInstances, MultiParamTypeClasses   build-depends:       base >=4.7 && <4.15, vector >=0.11 && <0.14, mmsyn3 >=0.1.5 && <1, mmsyn7s >=0.6.7 && <1, mmsyn6ukr >=0.7.3 && <1@@ -27,7 +27,7 @@  executable dobutokO-poetry   main-is:             Main.hs-  other-modules:       DobutokO.Poetry.Basic, DobutokO.Poetry, DobutokO.Poetry.StrictV, DobutokO.Poetry.Auxiliary, DobutokO.Poetry.Norms, DobutokO.Poetry.Norms.Extended, DobutokO.Poetry.UniquenessPeriodsG, DobutokO.Poetry.General+  other-modules:       DobutokO.Poetry.StrictV, DobutokO.Poetry.Auxiliary, DobutokO.Poetry.Norms, DobutokO.Poetry.Norms.Extended, DobutokO.Poetry.UniquenessPeriodsG, DobutokO.Poetry.General, DobutokO.Poetry.General.Debug, DobutokO.Poetry.Data   other-extensions:    BangPatterns, CPP, FlexibleInstances, MultiParamTypeClasses   build-depends:       base >=4.7 && <4.15, vector >=0.11 && <0.14, mmsyn3 >=0.1.5 && <1, mmsyn7s >=0.6.7 && <1, mmsyn6ukr >=0.7.3 && <1   -- hs-source-dirs: