dobutokO-poetry 0.2.0.0 → 0.3.0.0
raw patch · 4 files changed
+65/−8 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ DobutokO.Poetry: norm6 :: [Int] -> Int
+ DobutokO.Poetry: uniqNPoetical :: Int -> Vector ([Int], Int, Int, Int, String) -> IO ()
+ DobutokO.Poetry: uniqNPoeticalG :: Int -> ([Int] -> Int) -> String -> IO ()
+ DobutokO.Poetry: uniqNPoeticalV :: Int -> Vector ([Int], Int, Int, Int, String) -> IO (Vector ([Int], Int, Int, Int, String))
+ DobutokO.Poetry: uniqNPoeticalVG :: Int -> ([Int] -> Int) -> String -> IO (Vector ([Int], Int, Int, Int, String))
Files
- ChangeLog.md +4/−0
- DobutokO/Poetry.hs +47/−4
- Main.hs +13/−3
- dobutokO-poetry.cabal +1/−1
ChangeLog.md view
@@ -8,3 +8,7 @@ * Second version. Fixed issue with the wrong convertion to the WAV sound file. Added mmsyn3 as an explicit dependency (it was implicit) and changed the number of the minimum mmsyn6ukr package version.++## 0.3.0.0 -- 2020-06-02++* Third version. Added new generalized functions to the DobutokO.Poetry module and extended with them the functionality in the Main module.
DobutokO/Poetry.hs view
@@ -15,6 +15,10 @@ uniq10Poetical4 , uniq10Poetical5 , uniq10PoeticalG+ , uniqNPoeticalG+ , uniqNPoetical+ , uniqNPoeticalV+ , uniqNPoeticalVG -- * Additional functions , uniquenessVariantsG , uniquenessVariants3@@ -27,11 +31,13 @@ , norm3 , norm4 , norm5+ , norm6 -- * Help functions , fourFrom5 , lastFrom5 ) where +import Control.Monad import Data.Char (isPunctuation) import qualified Data.Vector as V import Data.List ((\\))@@ -113,6 +119,10 @@ | null xs = 0 | otherwise = sum xs `quot` (minimum xs + minimum (xs \\ [minimum xs])) +-- | A sixth norm for the list of positive 'Int'.+norm6 :: [Int] -> Int+norm6 xs = floor (fromIntegral (norm5 xs * sum xs) / fromIntegral (norm3 xs))+ -- | Given a norm and a Ukrainian 'String' consisting of no more than 7 words (see also the information for 'uniquenessVariantG') returns the maximum by the -- specified norm element of the 'uniquenessVariantsG' applied to the same arguments. uniqMaxPoeticalG :: ([Int] -> Int) -> String -> ([Int],Int,Int,Int,String)@@ -132,11 +142,9 @@ putStrLn (filter (not . isPunctuation) . lastFrom5 $ uniq) >> print (fourFrom5 uniq) >> putStrLn "" return . V.filter (/= uniq) $ v --- | Recursive 10 times application of the 'uniqInMaxPoetical' function. Prints 10 (or less if there are less of them) maximum elements starting from --- the first and further to the rest. The norm given defines the way, in which the elements are considered the \"maximum\" ones.+-- | A variant of the 'uniqNPoeticalG' function with the @n@ equal to 10. uniq10PoeticalG :: ([Int] -> Int) -> String -> IO ()-uniq10PoeticalG g xs = let v = uniquenessVariantsG g xs in uniqInMaxPoetical v >>= uniqInMaxPoetical >>= uniqInMaxPoetical >>= uniqInMaxPoetical >>= uniqInMaxPoetical - >>= uniqInMaxPoetical >>= uniqInMaxPoetical >>= uniqInMaxPoetical >>= uniqInMaxPoetical >>= uniqInMaxPoetical >> return ()+uniq10PoeticalG = uniqNPoeticalG 10 -- | 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.@@ -148,3 +156,38 @@ -- thoughts. uniq10Poetical5 :: String -> IO () uniq10Poetical5 = uniq10PoeticalG norm5++-- | Recursive @n :: Int@ times application of the 'uniqInMaxPoetical' function. Prints @n@ (or less if there are less of them) maximum elements starting from +-- the first and further to the rest. The norm given defines the way, in which the elements are considered the \"maximum\" ones.+uniqNPoetical :: Int -> V.Vector ([Int],Int,Int,Int,String) -> IO ()+uniqNPoetical n v + | n == 0 = return ()+ | compare (V.length v) n == LT = print v+ | otherwise = (uniqInMaxPoetical v >>= uniqNPoetical (n - 1))++-- | The result of the recursive @n :: Int@ times application of the 'uniqInMaxPoetical' function. The norm given defines the way, in which the elements +-- are considered the \"maximum\" ones.+uniqNPoeticalV :: Int -> V.Vector ([Int],Int,Int,Int,String) -> IO (V.Vector ([Int],Int,Int,Int,String))+uniqNPoeticalV n v + | n == 0 || compare (V.length v) n == LT = return v+ | otherwise = (uniqInMaxPoetical v >>= uniqNPoeticalV (n - 1)) ++-- | Recursive @n :: Int@ times application of the 'uniqInMaxPoetical' function after the 'uniquenessVariantsG' application to the 'String'. +-- Prints @n@ (or less if there are less of them) maximum elements starting from the first and further to the rest. The norm given defines the way, +-- in which the elements are considered the \"maximum\" ones.+uniqNPoeticalG :: Int -> ([Int] -> Int) -> String -> IO ()+uniqNPoeticalG n g xs + | n == 0 = return ()+ | otherwise = do + let v = uniquenessVariantsG g xs+ if compare (V.length v) n == LT then print v else (uniqInMaxPoetical v >>= uniqNPoetical (n - 1))++-- | The result of the recursive @n :: Int@ times application of the 'uniqInMaxPoetical' function after the 'uniquenessVariantsG' application to the 'String'. +-- The norm given defines the way, in which the elements are considered the \"maximum\" ones.+uniqNPoeticalVG :: Int -> ([Int] -> Int) -> String -> IO (V.Vector ([Int],Int,Int,Int,String))+uniqNPoeticalVG n g xs + | n == 0 = return V.empty+ | otherwise = do + let v = uniquenessVariantsG g xs+ if compare (V.length v) n == LT then return v else uniqNPoeticalV n v+
Main.hs view
@@ -10,15 +10,17 @@ module Main where +import Control.Exception (onException) import System.IO-import DobutokO.Poetry (uniq10Poetical4,uniq10Poetical5)+import DobutokO.Poetry (uniq10Poetical4,uniq10Poetical5,norm4,norm5,uniqNPoeticalG) import System.Environment (getArgs) import Melodics.Executable (recFileName, printInfoF, rawToSoundFile) import Melodics.Ukrainian (appendS16LEFile, convertToProperUkrainian) import EndOfExe (showE) import Data.Maybe (fromJust,isJust) --- | The first command line argument specifies which function to run. If given \"4\" it runs 'uniq10Poetical4', otherwise 'uniq10Poetical5'. The next 7 +-- | The first command line argument specifies which function to run. If given \"4\" it runs 'uniqNPoeticalG norm4', otherwise 'uniqNPoeticalG norm5'. +-- The second command line argument (by default is considered equal to 10::Int) is an 'Int' number of the needed printed variants. The next 7 -- are treated as the Ukrainian words to be ordered accordingly to the norm. For more information, please, refer to the documentation for the abovementioned -- functions. -- @@ -27,8 +29,16 @@ main = do args <- getArgs let arg0 = concat . take 1 $ args+ arg01 = concat . drop 1 . take 2 $ args word1s = unwords . drop 1 $ args- if arg0 == "4" then uniq10Poetical4 word1s else uniq10Poetical5 word1s+ arg1 <- onException (do + let aa = read arg01::Int+ return aa) (return 10)+ case (arg0,arg1) of+ ("4",10) -> uniq10Poetical4 word1s + (_,10) -> uniq10Poetical5 word1s+ ("4",n) -> uniqNPoeticalG n norm4 word1s + ~(_,n) -> uniqNPoeticalG n norm5 word1s putStrLn "What string would you like to record as a Ukrainian text sounding by mmsyn6ukr package? " str <- getLine nameAndRec str
dobutokO-poetry.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: dobutokO-poetry-version: 0.2.0.0+version: 0.3.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.