aftovolio 0.2.1.0 → 0.3.0.0
raw patch · 7 files changed
+134/−72 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Aftovolio.General.Distance: C1 :: [Word8] -> Compards
+ Aftovolio.General.Distance: C2 :: [Int8] -> Compards
+ Aftovolio.General.Distance: class DoubleFunc a b c d
+ Aftovolio.General.Distance: data Compards
+ Aftovolio.General.Distance: doubleFunc :: DoubleFunc a b c d => (a -> c) -> (b -> c) -> d -> c
+ Aftovolio.General.Distance: fromSmallWord8toInt8Diff :: [Word8] -> [Int8]
+ Aftovolio.General.Distance: instance Aftovolio.General.Distance.DoubleFunc [GHC.Word.Word8] [GHC.Int.Int8] Aftovolio.General.Distance.Compards Aftovolio.General.Distance.Compards
+ Aftovolio.General.Distance: instance Aftovolio.General.Distance.DoubleFunc [GHC.Word.Word8] [GHC.Int.Int8] GHC.Num.Integer.Integer Aftovolio.General.Distance.Compards
+ Aftovolio.General.Distance: instance Aftovolio.General.Distance.DoubleFunc [GHC.Word.Word8] [GHC.Int.Int8] GHC.Types.Bool Aftovolio.General.Distance.Compards
+ Aftovolio.General.Distance: instance Aftovolio.General.Distance.DoubleFunc [GHC.Word.Word8] [GHC.Int.Int8] GHC.Types.Int Aftovolio.General.Distance.Compards
+ Aftovolio.General.Distance: instance GHC.Classes.Eq Aftovolio.General.Distance.Compards
+ Aftovolio.General.Distance: isInt8Based :: Compards -> Bool
+ Aftovolio.General.Distance: isWord8Based :: Compards -> Bool
+ Aftovolio.General.Distance: sumAbsDistNormComp :: Compards -> Compards -> Integer
- Aftovolio.General.Distance: sumAbsDistNorm :: (Integral a, Ord a) => [a] -> [a] -> a
+ Aftovolio.General.Distance: sumAbsDistNorm :: (Integral a, Ord a) => [a] -> [a] -> Integer
- Aftovolio.General.Simple: argsProcessing :: GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> ([[[PRS]]] -> [[Word8]]) -> [[String]] -> [[String]] -> String -> IO (Int, Int, [Word8], Bool, FilePath, String, String, String, Int, Bool, Int8, FilePath, Int, Bool, String, [String])
+ Aftovolio.General.Simple: argsProcessing :: GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> ([[[PRS]]] -> [[Word8]]) -> [[String]] -> [[String]] -> String -> IO (Int, Int, Compards, Bool, FilePath, String, String, String, Int, Bool, Int8, FilePath, Int, Bool, String, [String])
- Aftovolio.General.Simple: generalF :: Int -> Int -> [Word8] -> Bool -> FilePath -> String -> (String -> String) -> (String, String) -> Int -> GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> ([[[PRS]]] -> [[Word8]]) -> Int -> HashCorrections -> (Int8, [Int8]) -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> Bool -> String -> [String] -> IO [String]
+ Aftovolio.General.Simple: generalF :: Int -> Int -> Compards -> Bool -> FilePath -> String -> (String -> String) -> (String, String) -> Int -> GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> ([[[PRS]]] -> [[Word8]]) -> Int -> HashCorrections -> (Int8, [Int8]) -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> Bool -> String -> [String] -> IO [String]
- Aftovolio.General.Simple: outputWithFile :: (Eq a1, Num a1) => ([[[PRS]]] -> [[Word8]]) -> GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> String -> [Word8] -> [AftovolioGen] -> Int -> a1 -> FilePath -> Int -> IO ()
+ Aftovolio.General.Simple: outputWithFile :: ([[[PRS]]] -> [[Word8]]) -> GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> String -> Compards -> [AftovolioGen] -> Int -> Int8 -> FilePath -> Int -> IO ()
- Aftovolio.General.Simple: testsOutput :: (Show a1, Integral a1) => Bool -> Int -> (p -> [a2] -> Int8 -> [Int8] -> String -> a1) -> p -> Int -> [String] -> IO [String]
+ Aftovolio.General.Simple: testsOutput :: (Show a1, Integral a1) => Bool -> Int -> (Int -> Compards -> Int8 -> [Int8] -> String -> a1) -> Int -> Int -> [String] -> IO [String]
- Aftovolio.Ukrainian.IO: generalF :: Int -> Int -> [Word8] -> Bool -> FilePath -> String -> (String, String) -> Int -> FilePath -> Int -> HashCorrections -> (Int8, [Int8]) -> Int -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> Bool -> String -> [String] -> IO [String]
+ Aftovolio.Ukrainian.IO: generalF :: Int -> Int -> Compards -> Bool -> FilePath -> String -> (String, String) -> Int -> FilePath -> Int -> HashCorrections -> (Int8, [Int8]) -> Int -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> Bool -> String -> [String] -> IO [String]
- Aftovolio.Ukrainian.IO: outputWithFile :: (Eq a1, Num a1) => String -> [Word8] -> [AftovolioUkr] -> FilePath -> [[[[Sound8]]] -> [[Word8]]] -> Int -> a1 -> Int -> FilePath -> Int -> IO ()
+ Aftovolio.Ukrainian.IO: outputWithFile :: String -> Compards -> [AftovolioUkr] -> FilePath -> [[[[Sound8]]] -> [[Word8]]] -> Int -> Int8 -> Int -> FilePath -> Int -> IO ()
- Aftovolio.Ukrainian.IO: testsOutput :: (Show a1, Integral a1) => Bool -> Int -> (p1 -> [a2] -> p2 -> Int8 -> [Int8] -> String -> a1) -> p1 -> p2 -> Int -> [String] -> IO [String]
+ Aftovolio.Ukrainian.IO: testsOutput :: (Show a1, Integral a1) => Bool -> Int -> (Int -> Compards -> p2 -> Int8 -> [Int8] -> String -> a1) -> Int -> p2 -> Int -> [String] -> IO [String]
Files
- Aftovolio/General/Distance.hs +55/−3
- Aftovolio/General/Simple.hs +34/−33
- Aftovolio/Ukrainian/IO.hs +17/−17
- CHANGELOG.md +3/−0
- README.md +6/−4
- aftovolio.cabal +1/−1
- src/Main.hs +18/−14
Aftovolio/General/Distance.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-} module Aftovolio.General.Distance where @@ -7,7 +9,9 @@ import GHC.Float (Floating(..),sqrt) import GHC.List import Data.List (replicate)-import GHC.Num ((*),(-),subtract,abs)+import GHC.Num ((*),(-),subtract,abs,Integer)+import GHC.Word+import GHC.Int -- | 'toEqLength' changes two given lists into two lists of equal -- minimal lengths and also returs its new length and initial lengths of the lists given.@@ -36,12 +40,24 @@ vs = concatMap (replicate (lx `quot` dc)) $ ys -- | Is also a simplified distance between the lists. Intended to be used with 'Word8'.-sumAbsDistNorm :: (Integral a, Ord a) => [a] -> [a] -> a+sumAbsDistNorm :: (Integral a, Ord a) => [a] -> [a] -> Integer sumAbsDistNorm xs ys | lc == 0 = 0- | otherwise = fromIntegral . sum . zipWith (\x y -> toInteger (if x > y then x-y else y-x)) ts $ vs+ | otherwise = sum . zipWith (\x y -> toInteger (if x > y then x-y else y-x)) ts $ vs where (ts, vs, lc, lx, ly) = toEqLength xs ys +-- | Intended to be used with 'Compards' of the same constructor in both arguments of the function. Otherwise returns -1.+sumAbsDistNormComp :: Compards -> Compards -> Integer+sumAbsDistNormComp x1s@(C1 xs) y1s@(C1 ys) + | lc == 0 = 0+ | otherwise = sum . zipWith (\x y -> toInteger (if x > y then x-y else y-x)) ts $ vs+ where (ts, vs, lc, lx, ly) = toEqLength xs ys +sumAbsDistNormComp x1s@(C2 xs) y1s@(C2 ys) + | lc == 0 = 0+ | otherwise = sum . zipWith (\x y -> toInteger (if x > y then x-y else y-x)) ts $ vs+ where (ts, vs, lc, lx, ly) = toEqLength xs ys +sumAbsDistNormComp _ _ = -1+ sumSqrDistNorm :: (Real a, Fractional a) => [a] -> [a] -> a sumSqrDistNorm xs ys | lc == 0 = 0@@ -84,4 +100,40 @@ dc = lc `quot` lr qs = concatMap (replicate dc) rs {-# INLINE distanceSqrG2 #-}++data Compards = C1 [Word8] | C2 [Int8] deriving (Eq)++isWord8Based :: Compards -> Bool+isWord8Based (C1 _) = True+isWord8Based _ = False++isInt8Based :: Compards -> Bool+isInt8Based (C2 _) = True+isInt8Based _ = False++{-| The elements in the first argument must not be greater than 127 though it is not checked. -}+fromSmallWord8toInt8Diff :: [Word8] -> [Int8]+fromSmallWord8toInt8Diff xs@(_:ys) = zipWith (\t u -> fromIntegral u - fromIntegral t) xs ys+fromSmallWord8toInt8Diff [] = []+{-# INLINE fromSmallWord8toInt8Diff #-}++class DoubleFunc a b c d where+ doubleFunc :: (a -> c) -> (b -> c) -> d -> c++instance (DoubleFunc [Word8] [Int8] Int) Compards where+ doubleFunc f g (C1 xs) = f xs+ doubleFunc f g (C2 ys) = g ys++instance (DoubleFunc [Word8] [Int8] Compards) Compards where+ doubleFunc f g (C1 xs) = f xs+ doubleFunc f g (C2 ys) = g ys++instance (DoubleFunc [Word8] [Int8] Bool) Compards where+ doubleFunc f g (C1 xs) = f xs+ doubleFunc f g (C2 ys) = g ys++instance (DoubleFunc [Word8] [Int8] Integer) Compards where+ doubleFunc f g (C1 xs) = f xs+ doubleFunc f g (C2 ys) = g ys+
Aftovolio/General/Simple.hs view
@@ -16,7 +16,8 @@ import Text.Read (readMaybe) import System.IO (putStrLn, FilePath,stdout,universalNewlineMode,hSetNewlineMode,getLine,appendFile,readFile,writeFile,putStr) import Rhythmicity.MarkerSeqs hiding (id) -import Data.List hiding (foldr)+import Data.List hiding (foldr,null)+import qualified Data.List as L (null) import Data.Ord (Down(..)) import Data.Maybe (fromMaybe, mapMaybe, catMaybes,isNothing,fromJust) import Data.Tuple (fst)@@ -46,7 +47,7 @@ generalF :: Int -- ^ A power of 10. The resulting distance using next ['Word8'] argument is quoted by 10 in this power. The default one is 0. The proper values are in the range [0..4]. -> Int -- ^ A 'length' of the next argument here.- -> [Word8] -- ^ A list of positive values normed by 255 (the greatest of which is 255) that the line options are compared with. If null, then the program works as for version 0.12.1.0 without this newly-introduced argument since the version 0.13.0.0. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. Is not used when the next 'FilePath' and 'String' arguments are not null.+ -> Compards -- ^ A value that the different options are compared with. If no command line argument \"+di\" was added, then this is a `C1` applied to the list of positive values normed by 255 (the greatest of which is 255) that the line options are compared with. If null, then the program works without comparison. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. Is not used when the next 'FilePath' and 'String' arguments are not null. If \"+di\" command line argument was provided, then this corresponds to the case of differentiation. -> Bool -- ^ If 'True' then adds \"<br>\" to line endings for double column output -> FilePath -- ^ A path to the file to save double columns output to. If empty then just prints to 'stdout'. -> String -- ^ If not null than instead of rhythmicity evaluation using hashes and and feets, there is computed a diversity property for the specified 'String' here using the 'selectSounds' function. For more information, see: 'https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#types'@@ -73,7 +74,7 @@ -> [String] -> IO [String] generalF power10 ldc compards html dcfile selStr selFun (prestr,poststr) lineNmb wrs ks arr gs us vs h numTest hc (grps,mxms) descending hashStep emptyline splitting (fs, code) concurrently initstr universalSet - | null universalSet = do+ | L.null universalSet = do let strOutput = ["You have specified the data and constraints on it that lead to no further possible options.", "Please, specify another data and constraints."] putStrLn . unlines $ strOutput return strOutput@@ -83,17 +84,17 @@ | otherwise = do let syllN = countSyll wrs arr us vs initstr f ldc compards grps mxms - | null selStr = (if null compards then (sum . countHashes2G hashStep hc grps mxms) else ((`quot` 10^power10) . fromIntegral . sumAbsDistNorm compards)) . read3 (not . null . filter (not . isSpace)) 1.0 (mconcat . h . createSyllablesPL wrs ks arr gs us vs)+ | L.null selStr = (if doubleFunc (L.null::[Word8]->Bool) (L.null::[Int8]->Bool) compards then (sum . countHashes2G hashStep hc grps mxms) else (`quot` 10^power10) . fromIntegral . sumAbsDistNormComp compards . (if isWord8Based compards then C1 else C2 . fromSmallWord8toInt8Diff)) . read3 (not . L.null . filter (not . isSpace)) 1.0 (mconcat . h . createSyllablesPL wrs ks arr gs us vs) | otherwise = fromIntegral . diverse2GGL (selectSounds selFun selStr) (us `mappend` vs) . concatMap string1 . stringToXG wrs . filter (\c -> not (isDigit c) && c /= '_' && c /= '=') hSetNewlineMode stdout universalNewlineMode- if numTest >= 0 && numTest <= 179 && numTest /= 1 && null compards then testsOutput concurrently syllN f ldc numTest universalSet + if numTest >= 0 && numTest <= 179 && numTest /= 1 && doubleFunc (L.null::[Word8]->Bool) (L.null::[Int8]->Bool) compards then testsOutput concurrently syllN f ldc numTest universalSet else let sRepresent = zipWith (\k (x, ys) -> S k x ys) [1..] . (if descending then sortOn (\(u,w) -> (Down u,w)) else sortOn id) . map (\xss -> (f ldc compards grps mxms xss, xss)) $ universalSet strOutput = force . (:[]) . halfsplit1G (\(S _ y _) -> y) (if html then "<br>" else "") (jjj splitting) $ sRepresent lns1 = unlines strOutput in do putStrLn lns1- if null dcfile then putStr "" + if L.null dcfile then putStr "" else do doesFileExist dcfile >>= \exist -> if exist then do getPermissions dcfile >>= \perms -> if writable perms then writeFile dcfile lns1 @@ -139,13 +140,13 @@ -> String -> Int countSyll wrs arr us vs xs = numUnderscoresSyll + (fromEnum . foldr (\x y -> if createsSyllable x then y + 1 else y) 0 . concatMap (str2PRSs arr) . words1 . mapMaybe g . concatMap string1 . stringToXG wrs $ xs)- where numUnderscoresSyll = length . filter (\xs -> let (ys,ts) = splitAt 1 xs in ys == "_" && all isDigit ts && not (null ts)) . groupBy (\x y -> x=='_' && isDigit y) $ xs+ where numUnderscoresSyll = length . filter (\xs -> let (ys,ts) = splitAt 1 xs in ys == "_" && all isDigit ts && not (L.null ts)) . groupBy (\x y -> x=='_' && isDigit y) $ xs g :: Char -> Maybe Char g x | x `elem` us = Nothing | x `notElem` vs = Just x | otherwise = Just ' '- words1 xs = if null ts then [] else w : words1 s'' -- Practically this is an optimized version for this case 'words' function from Prelude.+ words1 xs = if L.null ts then [] else w : words1 s'' -- Practically this is an optimized version for this case 'words' function from Prelude. where ts = dropWhile (== ' ') xs (w, s'') = break (== ' ') ts {-# NOINLINE words1 #-}@@ -185,15 +186,15 @@ -> [[String]] -> [[String]] -> String - -> IO (Int, Int, [Word8], Bool, FilePath, String, String, String, Int, Bool, Int8, FilePath, Int, Bool, String, [String]) -- ^ These ones are intended to be used inside 'generalF'.+ -> IO (Int, Int, Compards, Bool, FilePath, String, String, String, Int, Bool, Int8, FilePath, Int, Bool, String, [String]) -- ^ These ones are intended to be used inside 'generalF'. argsProcessing wrs ks arr gs us vs h ysss zsss xs = do args0 <- getArgs let (argsC, args) = takeCs1R ('+','-') cSpecs args0 (argsB, args11) = takeBsR bSpecs args compareByLinesFinalFile = concat . getB "-cm" $ argsB- if not . null $ compareByLinesFinalFile then do+ if not . L.null $ compareByLinesFinalFile then do compareFilesToOneCommon 14 args11 compareByLinesFinalFile- return (0,0,[],False,[],[],[],[],0,False,0,[],0,False,[],[]) + return (0,0,(C1 []),False,[],[],[],[],0,False,0,[],0,False,[],[]) else do let prepare = any (== "-p") args11 emptyline = any (== "+l") args11 @@ -201,7 +202,7 @@ concurrently = any (== "-C") args11 dcspecs = getB "+dc" argsB (html,dcfile) - | null dcspecs = (False, "")+ | L.null dcspecs = (False, "") | otherwise = (head dcspecs == "1",last dcspecs) selStr = concat . getB "+ul" $ argsB filedata = getB "+f" argsB@@ -219,7 +220,7 @@ | oneB "+m2" argsB = (getB "+m" argsB, max 1 (fromMaybe 1 (readMaybe (concat . getB "+m2" $ argsB)::Maybe Int))) | otherwise = (getB "+m" argsB, -1) (fileread,lineNmb)- | null multiline2 = ("",-1)+ | L.null multiline2 = ("",-1) | length multiline2 == 2 = (head multiline2, fromMaybe 1 (readMaybe (last multiline2)::Maybe Int)) | otherwise = (head multiline2, 1) (arg3s,prestr,poststr,linecomp3) <- do@@ -249,14 +250,15 @@ | otherwise = lns !! (ln1 - 1) return $ (words lineF, line_1F,line1F,linecomp3) else return (args11, [], [],[])- let line2comparewith- | oneC "+l2" argsC || null linecomp3 = unwords . getC "+l2" $ argsC+ let differentiate = any (== "+di") args11+ line2comparewith+ | oneC "+l2" argsC || L.null linecomp3 = unwords . getC "+l2" $ argsC | otherwise = linecomp3 basecomp - | oneC "+ln" argsC = force . catMaybes . map (\xs -> readMaybe xs::Maybe Word8) . getC "+ln" $ argsC -- to read positive Word8 values as a list of them.- | otherwise = force . read3 (not . null . filter (not . isSpace)) 1.0 (mconcat . h . createSyllablesPL wrs ks arr gs us vs) $ line2comparewith+ | oneC "+ln" argsC = (if differentiate then C2 . fromSmallWord8toInt8Diff else C1) . catMaybes . map (\xs -> readMaybe xs::Maybe Word8) . getC "+ln" $ argsC -- to read positive Word8 values as a list of them.+ | otherwise = (if differentiate then C2 . fromSmallWord8toInt8Diff else C1) . read3 (not . L.null . filter (not . isSpace)) 1.0 (mconcat . h . createSyllablesPL wrs ks arr gs us vs) $ line2comparewith (filesave,codesave)- | null filedata = ("",-1)+ | L.null filedata = ("",-1) | length filedata == 2 = (head filedata, fromMaybe 0 (readMaybe (last filedata)::Maybe Int)) | otherwise = (head filedata,0) ll = let maxWordsNum = (if any (== "+x") arg3s then 9 else 7) in take maxWordsNum . (if prepare then id else words . mconcat . prepareTextN maxWordsNum ysss zsss xs . unwords) $ arg3s@@ -264,18 +266,18 @@ argCs = catMaybes (fmap (readMaybeECG l) . getC "+a" $ argsC) argCBs = unwords . getC "+b" $ argsC -- If you use the parenthese with +b ... -b then consider also using the quotation marks for the whole algebraic constraint. At the moment though it is still not working properly for parentheses functionality. The issue should be fixed in the further releases. !perms - | not (null argCBs) = filterGeneralConv l argCBs . genPermutationsL $ l- | null argCs = genPermutationsL l+ | not (L.null argCBs) = filterGeneralConv l argCBs . genPermutationsL $ l+ | L.null argCs = genPermutationsL l | otherwise = decodeLConstraints argCs . genPermutationsL $ l basiclineoption = unwords arg3s- example = force . read3 (not . null . filter (not . isSpace)) 1.0 (mconcat . h . createSyllablesPL wrs ks arr gs us vs) . unwords $ arg3s- le = length example- lb = length basecomp+ example = (if differentiate then C2 . fromSmallWord8toInt8Diff else C1) . read3 (not . L.null . filter (not . isSpace)) 1.0 (mconcat . h . createSyllablesPL wrs ks arr gs us vs) . unwords $ arg3s+ le = doubleFunc (length::[Word8]->Int) (length::[Int8]->Int) example+ lb = doubleFunc (length::[Word8]->Int) (length::[Int8]->Int) basecomp gcd1 = gcd le lb ldc = le * lb `quot` gcd1 mulp = ldc `quot` lb -- max2 = maximum basecomp- compards = force . concatMap (replicate mulp) $ basecomp+ compards = let ff g1 g2 ks = if isWord8Based ks then C1 . g1 . (\(C1 us) -> us) $ ks else C2 . g2 . (\(C2 us) -> us)$ ks in ff (concatMap (replicate mulp)) (concatMap (replicate mulp)) basecomp variants1 = force . uniquenessVariants2GNBL ' ' id id id perms $ ll return (power10, ldc, compards, html, dcfile, selStr, prestr, poststr, lineNmb, emptyline, splitting, filesave, codesave, concurrently, basiclineoption, variants1) @@ -327,17 +329,17 @@ :: (Show a1, Integral a1) => Bool -> Int- -> (p -> [a2] -> Int8 -> [Int8] -> String -> a1)- -> p+ -> (Int -> Compards -> Int8 -> [Int8] -> String -> a1) -> Int+ -> Int -> [String] -> IO [String] testsOutput concurrently syllN f ldc numTest universalSet = do putStrLn "Feet Val Stat Proxim" (if concurrently then mapConcurrently else mapM) (\(q,qs) -> let m = stat1 syllN (q,qs)- (min1,max1) = force . fromJust . minMax11By (comparing (f ldc [] q qs)) $ universalSet - mx = f ldc [] q qs max1+ (min1,max1) = force . fromJust . minMax11By (comparing (f ldc (C1 []) q qs)) $ universalSet + mx = f ldc (C1 []) q qs max1 strTest = (show (fromEnum q) `mappend` " | " `mappend` show mx `mappend` " " `mappend` show m `mappend` " -> " `mappend` showFFloat (Just 3) (100 * fromIntegral mx / fromIntegral m) "%" `mappend` (if rem numTest 10 >= 4 then -- let min1 = minimumBy (comparing (f ldc [] q qs)) universalSet in ("\n" `mappend` min1 `mappend` "\n" `mappend` max1 `mappend` "\n") @@ -345,8 +347,7 @@ -- | Internal part of the 'generalF' for processment with a file. outputWithFile- :: (Eq a1, Num a1) =>- ([[[PRS]]] -> [[Word8]]) -- ^ Since the version 0.20.0.0, here there are 'Word8' instead of 'Double'. If this function is @g@, then the module 'Aftovolio.General.Datatype3' has corresponding function 'Aftovolio.General.Datatype3.zippedDouble2Word8' to transform the previously used function into the new one. If you have the function used inside the @f::[[[PRS]]]->[[Double]]@ with main conversion semantically similar to the one by the link: 'https://hackage.haskell.org/package/ukrainian-phonetics-basic-array-0.7.1.1/docs/Phladiprelio-Ukrainian-SyllableDouble.html#v:syllableDurationsD', then you can use 'zippedDouble2Word8' to transform the main semantic kernel of [(PRS, Double)] into [(PRS, Word8)].+ :: ([[[PRS]]] -> [[Word8]]) -- ^ Since the version 0.20.0.0, here there are 'Word8' instead of 'Double'. If this function is @g@, then the module 'Aftovolio.General.Datatype3' has corresponding function 'Aftovolio.General.Datatype3.zippedDouble2Word8' to transform the previously used function into the new one. If you have the function used inside the @f::[[[PRS]]]->[[Double]]@ with main conversion semantically similar to the one by the link: 'https://hackage.haskell.org/package/ukrainian-phonetics-basic-array-0.7.1.1/docs/Phladiprelio-Ukrainian-SyllableDouble.html#v:syllableDurationsD', then you can use 'zippedDouble2Word8' to transform the main semantic kernel of [(PRS, Double)] into [(PRS, Word8)]. -> GWritingSystemPRPLX -- ^ Data used to obtain the phonetic language representation of the text. -> [(Char, Char)] -- ^ The pairs of the 'Char' that corresponds to the similar phonetic languages consonant phenomenon (e. g. allophones). Must be sorted in the ascending order to be used correctly. -> CharPhoneticClassification@@ -354,17 +355,17 @@ -> String -- ^ Corresponds to the 100 delimiter in the @ukrainian-phonetics-basic-array@ package. -> String -- ^ Corresponds to the 101 delimiter in the @ukrainian-phonetics-basic-array@ package. -> String -- ^ If not null than instead of rhythmicity evaluation using hashes and and feets, there is computed a diversity property for the specified 'String' here using the 'selectSounds' function. For more information, see: 'https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#types'- -> [Word8] -- ^ A list of positive values normed by 255 (the greatest of which is 255) that the line options are compared with. If null, then the program works as for version 0.12.1.0 without this newly-introduced argument since the version 0.13.0.0. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. Is not used when the next 'FilePath' and 'String' arguments are not null.+ -> Compards -- ^ A value that the different options are compared with. If no command line argument \"+di\" was added, then this is a `C1` applied to the list of positive values normed by 255 (the greatest of which is 255) that the line options are compared with. If null, then the program works without comparison. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. Is not used when the next 'FilePath' and 'String' arguments are not null. If \"+di\" command line argument was provided, then this corresponds to the case of differentiation. -> [AftovolioGen] -> Int- -> a1+ -> Int8 -> FilePath -- ^ A file to be probably added output parts to. -> Int -> IO () outputWithFile h wrs ks arr gs us vs selStr compards sRepresent code grps fs num | mBool && code >= 10 && code <= 19 && grps == 2 = putStrLn (mconcat [textP, "\n", breaks, "\n", show rs]) >> appendF ((if code >= 15 then mconcat [show rs, "\n", breaks, "\n"] else "") `mappend` outputS) | otherwise = appendF outputS- where mBool = null selStr && null compards+ where mBool = L.null selStr && doubleFunc (L.null::[Word8]->Bool) (L.null::[Int8]->Bool) compards appendF = appendFile fs lineOption = head . filter (\(S k _ _) -> k == num) $ sRepresent textP = (\(S _ _ ts) -> ts) lineOption
Aftovolio/Ukrainian/IO.hs view
@@ -15,7 +15,8 @@ import Data.Char (isDigit,toLower,isSpace) import System.IO (putStrLn, FilePath,stdout,hSetNewlineMode,universalNewlineMode,getLine,appendFile,writeFile,putStr,readFile) import qualified Rhythmicity.MarkerSeqs as R --hiding (id)-import Data.List hiding (foldr)+import Data.List hiding (foldr,null)+import qualified Data.List as L (null) import Data.Foldable (mapM_) import Data.Maybe (isNothing,fromJust,fromMaybe) import Data.Tuple (fst,snd)@@ -42,7 +43,7 @@ generalF :: Int -- ^ A power of 10. The distance value is quoted by 10 in this power if the next ['Word8'] argument is not empty. The default one is 0. The right values are in the range [0..4]. -> Int -- ^ A 'length' of the next argument here.- -> [Word8] -- ^ A list of positive values normed by 255 (the greatest of which is 255) that the line options are compared with. If null, then the program works as for version 0.12.1.0 without this newly-introduced argument since the version 0.13.0.0. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. Is not used when the next 'FilePath' and 'String' arguments are not null.+ -> Compards -- ^ A value that the different options are compared with. If no command line argument \"+di\" was added, then this is a `C1` applied to the list of positive values normed by 255 (the greatest of which is 255) that the line options are compared with. If null, then the program works without comparison. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. Is not used when the next 'FilePath' and 'String' arguments are not null. If \"+di\" command line argument was provided, then this corresponds to the case of differentiation. -> Bool -- ^ If 'True' then adds \"<br>\" to line endings for double column output -> FilePath -- ^ A path to the file to save double columns output to. If empty then just prints to 'stdout'. -> String -- ^ If not null than instead of rhythmicity evaluation using hashes and and feets, there is computed a diversity property for the specified 'String' here using the 'selectSounds' function. For more information, see: 'https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#types'@@ -66,18 +67,18 @@ syllableDurationsDs <- readSyllableDurations file let syllN = countSyll initstr f ldc compards syllableDurationsDs grps mxms -- Since the version 0.12.0.0, has a possibility to evaluate diversity property.- | null selStr = (if null compards then (sum . R.countHashes2G hashStep hc grps mxms) else ((`quot` 10^power10) . fromIntegral . sumAbsDistNorm compards)) . read3 (not . null . filter (not . isSpace)) 1.0 (mconcat . (if null file then case k of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} + | L.null selStr = (if doubleFunc (L.null::[Word8]->Bool) (L.null::[Int8]-> Bool) compards then (sum . R.countHashes2G hashStep hc grps mxms) else (`quot` 10^power10) . fromIntegral . sumAbsDistNormComp compards . (if isWord8Based compards then C1 else C2 . fromSmallWord8toInt8Diff)) . read3 (not . L.null . filter (not . isSpace)) 1.0 (mconcat . (if L.null file then case k of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} else if length syllableDurationsDs >= k then syllableDurationsDs !! (k - 1) else syllableDurationsD2) . createSyllablesUkrS) | otherwise = fromIntegral . diverse2GGL (selectSounds selStr) [100,101] . convertToProperUkrainianI8 . filter (\c -> not (isDigit c) && c /= '_' && c/= '=') hSetNewlineMode stdout universalNewlineMode- if numTest >= 0 && numTest <= 179 && numTest /= 1 && null compards then testsOutput concurrently syllN f ldc syllableDurationsDs numTest universalSet+ if numTest >= 0 && numTest <= 179 && numTest /= 1 && doubleFunc (L.null::[Word8]->Bool) (L.null::[Int8]-> Bool) compards then testsOutput concurrently syllN f ldc syllableDurationsDs numTest universalSet else let sRepresent = zipWith (\k (x, ys) -> S k x ys) [1..] . (if descending then sortOn (\(u,w) -> (Down u, w)) else sortOn id) . map (\xss -> (f ldc compards syllableDurationsDs grps mxms xss, xss)) $ universalSet strOutput = force . (:[]) . halfsplit1G (\(S _ y _) -> y) (if html then "<br>" else "") (jjj splitting) $ sRepresent in do let lns1 = unlines strOutput putStrLn lns1- if null dcfile then putStr "" + if L.null dcfile then putStr "" else do exist <- doesFileExist dcfile if exist then do @@ -126,14 +127,14 @@ countSyll :: String -> Int countSyll xs = numUnderscoresSyll + (fromEnum . foldr (\x y -> if isVowel1 x then y + 1 else y) 0 . convertToProperUkrainianI8 $ xs)- where numUnderscoresSyll = length . filter (\xs -> let (ys,ts) = splitAt 1 xs in ys == "_" && all isDigit ts && not (null ts)) . groupBy (\x y -> x=='_' && isDigit y) $ xs+ where numUnderscoresSyll = length . filter (\xs -> let (ys,ts) = splitAt 1 xs in ys == "_" && all isDigit ts && not (L.null ts)) . groupBy (\x y -> x=='_' && isDigit y) $ xs stat1 :: Int -> (Int8,[Int8]) -> Int stat1 n (k, ks) = fst (n `quotRemInt` fromEnum k) * length ks parseHelp :: [String] -> (String,[String]) parseHelp xss - | null xss = ([],[])+ | L.null xss = ([],[]) | otherwise = (unwords rss, uss `mappend` qss) where (yss,tss) = break (== "-b") xss (uss,wss) = break (== "+b") yss@@ -172,8 +173,8 @@ :: (Show a1, Integral a1) => Bool -- ^ Whether to run tests concurrently or not. 'True' corresponds to concurrent execution that can speed up the getting results but use more resources. -> Int- -> (p1 -> [a2] -> p2 -> Int8 -> [Int8] -> String -> a1)- -> p1+ -> (Int -> Compards -> p2 -> Int8 -> [Int8] -> String -> a1)+ -> Int -> p2 -> Int -> [String]@@ -184,8 +185,8 @@ then mapConcurrently else mapM) (\(q,qs) -> let m = stat1 syllN (q,qs)- (min1, max1) = force . fromJust . minMax11By (comparing (f ldc [] syllableDurationsDs q qs)) $ universalSet - mx = f ldc [] syllableDurationsDs q qs max1 + (min1, max1) = force . fromJust . minMax11By (comparing (f ldc (C1 []) syllableDurationsDs q qs)) $ universalSet + mx = f ldc (C1 []) syllableDurationsDs q qs max1 strTest = (show (fromEnum q) `mappend` " | " `mappend` show mx `mappend` " " `mappend` show m `mappend` " -> " `mappend` showFFloat (Just 3) (100 * fromIntegral mx / fromIntegral m) "%" `mappend` (if rem numTest 10 >= 4 then ("\n" `mappend` min1 `mappend` "\n" `mappend` max1 `mappend` "\n")@@ -193,14 +194,13 @@ -- | Part of 'generalF' for processment with a file. outputWithFile- :: (Eq a1, Num a1) =>- String -- ^ If not null than instead of rhythmicity evaluation using hashes and and feets, there is computed a diversity property for the specified 'String' here using the 'selectSounds' function. For more information, see: 'https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#types'- -> [Word8] -- ^ A list of non-negative values normed by 255 (the greatest of which is 255) that the line options are compared with. If null, then the program works as for version 0.12.1.0 without this newly-introduced argument since the version 0.13.0.0. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. + :: String -- ^ If not null than instead of rhythmicity evaluation using hashes and and feets, there is computed a diversity property for the specified 'String' here using the 'selectSounds' function. For more information, see: 'https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#types'+ -> Compards -- ^ A value that the different options are compared with. If no command line argument \"+di\" was added, then this is a `C1` applied to the list of positive values normed by 255 (the greatest of which is 255) that the line options are compared with. If null, then the program works without comparison. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. Is not used when the next 'FilePath' and 'String' arguments are not null. If \"+di\" command line argument was provided, then this corresponds to the case of differentiation. -> [AftovolioUkr] -> FilePath -- ^ The file to read the sound representation durations from. -> [[[[Sound8]]] -> [[Word8]]] -> Int- -> a1+ -> Int8 -> Int -> FilePath -- ^ A file to be probably added output parts to. -> Int@@ -208,12 +208,12 @@ outputWithFile selStr compards sRepresent file syllableDurationsDs code grps k fs num | mBool && code >= 10 && code <= 19 && grps == 2 = putStrLn (mconcat [textP, "\n", breaks, "\n", show rs]) >> appendF ((if code >= 15 then mconcat [show rs, "\n", breaks, "\n"] else "") `mappend` outputS) | otherwise = appendF outputS- where mBool = null selStr && null compards + where mBool = L.null selStr && doubleFunc (L.null::[Word8]->Bool) (L.null::[Int8]-> Bool) compards appendF = appendFile fs lineOption = head . filter (\(S k _ _) -> k == num) $ sRepresent textP = (\(S _ _ ts) -> ts) lineOption -- sylls = createSyllablesUkrS textP outputS = outputSel lineOption code- qqs = readEq4 (mconcat . (if null file then case k of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} else if length syllableDurationsDs >= k then syllableDurationsDs !! (k - 1) else syllableDurationsD2) . createSyllablesUkrS) (map showFS . mconcat . createSyllablesUkrS) . basicSplit $ textP + qqs = readEq4 (mconcat . (if L.null file then case k of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} else if length syllableDurationsDs >= k then syllableDurationsDs !! (k - 1) else syllableDurationsD2) . createSyllablesUkrS) (map showFS . mconcat . createSyllablesUkrS) . basicSplit $ textP (breaks, rs) = R.showZerosFor2PeriodMusic qqs
CHANGELOG.md view
@@ -12,3 +12,6 @@ * Second version revised A. Updated dependencies. Some minor code usability improvements. +## 0.3.0.0 -- 2024-10-13++* Third version, Added a new possibility to compare lines using the "+di" command line argument. If present implies the "differentiation" mode of computation for the comparing options with the line in +l2 or +ln groups of command line arguments. Is useful mostly in case of the line to compare with has approximately the same number of syllables as the option lines.
README.md view
@@ -955,16 +955,16 @@ - aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+ul <diversity property encoding string>] [+n] [+l] [-p] [+w <splitting parameter>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>]] <Ukrainian textual line> OR:-- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+l2 <a Ukrainian text line to compare similarity with> -l2]] <Ukrainian textual line>+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+l2 <a Ukrainian text line to compare similarity with> -l2]] [+di] <Ukrainian textual line> OR:-- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+ln <a sequence of positive Word8 values not greater than 255 e. g. 24 157 45 68 45 56 59 to compare similarity with> -ln]] <Ukrainian textual line>+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+ln <a sequence of positive Word8 values not greater than 255 e. g. 24 157 45 68 45 56 59 to compare similarity with> -ln]] [+di] <Ukrainian textual line> OR:-- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+m <FilePath> <num1> +m2 <num2>]]+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+di] [+m <FilePath> <num1> +m2 <num2>]] OR:-- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+m3 <FilePath> <num1> <num2>]]+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+di] [+m3 <FilePath> <num1> <num2>]] OR: - aftovolioUkr [-cm <FilePath to write the resulting combined output to> <FilePaths of the files to be compared and chosen the resulting options line-by-line>]@@ -1003,6 +1003,8 @@ - +l2 \... -l2 — if present and has inside Ukrainian text then the line options are compared with it using the idea of lists similarity. The greater values correspond to the less similar and more different lines. Has no effect with +dc group of command line arguments. Has precedence over +t, +r, +k, +c etc. groups of command line options so that these latter ones have no effect when +l2 \... -l2 is present. - +ln \... -ln — if present and has inside a sequence of positive Word8 values not greater than 255 then the line options are compared with it using the idea of lists similarity. The greater values correspond to the less similar and more different lines. Has no effect with +dc group of command line arguments. Has precedence over +t, +r, +k, +c etc. groups of command line options so that these latter ones have no effect when +ln \... -ln is present.++- +di — if present implies the "differentiation" mode of computation for the comparing options with the line in +l2 or +ln groups of command line arguments. Is useful mostly in case of the line to compare with has approximately the same number of syllables as the option lines. - +q — if present with +l2 \... -l2 group of arguments then the next argument is a power of 10 which the distance between line option and the predefined line is quoted by. The default one is 0 (that means no change). You can specify not less than 0 and not greater than 4. Otherwise, these limit numbers are used instead. The greater value here leads to more groupped options output.
aftovolio.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: aftovolio-version: 0.2.1.0+version: 0.3.0.0 -- A short (one-line) description of the package. synopsis: An AFTOVolio implementation for creating texts with special phonetic / prosodic properties.
src/Main.hs view
@@ -7,7 +7,7 @@ import GHC.Base import GHC.Num (abs,(+),(-),(*)) import Text.Read (readMaybe)-import Text.Show (show) -- Added in 0.14.1.0+import Text.Show (show) import System.IO (putStrLn,readFile, hSetNewlineMode, stdout, universalNewlineMode) import qualified Rhythmicity.MarkerSeqs as R hiding (id) import Data.List hiding (foldr)@@ -26,12 +26,13 @@ import Aftovolio.StrictVG import Aftovolio.Ukrainian.IO import Aftovolio.General.Datatype3 (read3)+import Aftovolio.General.Distance import GHC.Real ((/),quot,gcd) import Aftovolio.Ukrainian.Syllable import Aftovolio.Ukrainian.SyllableWord8 import Aftovolio.Ukrainian.ReadDurations import Data.ChooseLine2-import Control.DeepSeq (force) +import Control.DeepSeq main :: IO () main = do@@ -106,23 +107,24 @@ | otherwise = lns !! (ln1 - 1) return $ (words lineF, line_1F,line1F,linecomp3) else return (arg2s, [], [],[])- let line2comparewith + let differentiate = oneA "+di" argsA+ line2comparewith | oneC "+l2" argsC || null linecomp3 = unwords . getC "+l2" $ argsC | otherwise = linecomp3 basecomp - | oneC "+ln" argsC = force . catMaybes . map (\xs -> readMaybe xs::Maybe Word8) . getC "+ln" $ argsC - | otherwise = force . read3 (not . null . filter (not . isSpace)) 1.0 (mconcat . (if null fileDu then case sylD of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} + | oneC "+ln" argsC = (if differentiate then C2 . fromSmallWord8toInt8Diff else C1) . catMaybes . map (\xs -> readMaybe xs::Maybe Word8) . getC "+ln" $ argsC + | otherwise = (if differentiate then C2 . fromSmallWord8toInt8Diff else C1) . read3 (not . null . filter (not . isSpace)) 1.0 (mconcat . (if null fileDu then case sylD of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} else if length syllableDurationsDs >= sylD then syllableDurationsDs !! (sylD - 1) else syllableDurationsD2) . createSyllablesUkrS) $ line2comparewith - example = force . read3 (not . null . filter (not . isSpace)) 1.0 (mconcat . (if null fileDu then case sylD of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} + example = (if differentiate then C2 . fromSmallWord8toInt8Diff else C1) . read3 (not . null . filter (not . isSpace)) 1.0 (mconcat . (if null fileDu then case sylD of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} else if length syllableDurationsDs >= sylD then syllableDurationsDs !! (sylD - 1) else syllableDurationsD2) . createSyllablesUkrS) $ (unwords arg3s)- le = length example- lb = length basecomp+ le = doubleFunc (length::[Word8]->Int) (length::[Int8]-> Int) example+ lb = doubleFunc (length::[Word8]->Int) (length::[Int8]-> Int) basecomp gcd1 = gcd le lb ldc = (le * lb) `quot` gcd1 mulp = ldc `quot` lb -- max2 = maximum basecomp- compards = force . concatMap (replicate mulp) $ basecomp+ compards = let ff g1 g2 ks = if isWord8Based ks then C1 . g1 . (\(C1 us) -> us) $ ks else C2 . g2 . (\(C2 us) -> us) $ ks in ff (concatMap (replicate mulp)) (concatMap (replicate mulp)) basecomp (filesave,codesave) | null filedata = ("",-1) | length filedata == 2 = (head filedata, fromMaybe 0 (readMaybe (last filedata)::Maybe Int))@@ -146,7 +148,7 @@ bSpecs = (zip ["+c","+d","+k","-h","+r","+s","-t","+ul","+w","+x","+q","+m2","-cm"] . cycle $ [1]) `mappend` [("+f",2),("+m",2),("+dc",2),("+m3",3)] aSpecs :: CLSpecifications-aSpecs = zip ["+l", "+n","-p", "-C"] . cycle $ [0]+aSpecs = zip ["+di", "+l", "+n","-p", "-C"] . cycle $ [0] cSpecs :: CLSpecifications cSpecs = [("+a",-1),("+l2",-1),("+ln",-1)]@@ -157,11 +159,11 @@ | xs == "1" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+c <HashCorrections encoded>] [+n] [+l] [+d <FilePath to file with durations>] [+k <number - hash step>] [+r <groupping info>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>]] <Ukrainian textual line>\n" | xs == "2" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+c <HashCorrections encoded>] [+n] [+l] [+d <FilePath to file with durations>] [+k <number - hash step>] [-t <number of the test or its absence if 1 is here> [-C +RTS -N -RTS]] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+x <maximum number of words taken>]] <Ukrainian textual line>\n" | xs == "3" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+ul <diversity property encoding string>] [+n] [+l] [-p] [+w <splitting parameter>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>]] <Ukrainian textual line>\n"- | xs == "4" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+l2 <a Ukrainian text line to compare similarity with> -l2]] <Ukrainian textual line>\n"- | xs == "5" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+m <FilePath> <num1> +m2 <num2>]]\n"- | xs == "6" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+m3 <FilePath> <num1> <num2>]]\n"+ | xs == "4" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+l2 <a Ukrainian text line to compare similarity with> -l2]] [+di] <Ukrainian textual line>\n"+ | xs == "5" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+di] [+m <FilePath> <num1> +m2 <num2>]]\n"+ | xs == "6" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+di] [+m3 <FilePath> <num1> <num2>]]\n" | xs == "7" = putStrLn "aftovolioUkr [-cm <FilePath to write the resulting combined output to> <FilePaths of the files to be compared and chosen the resulting options line-by-line>]\n"- | xs == "8" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+ln <a sequence of Word8 positive integer values not greater than 255 e. g. 24 54 57 159 45 39 to compare similarity with> -ln]] <Ukrainian textual line>\n"+ | xs == "8" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+n] [+l] [+d <FilePath to file with durations>] [+s <syllable durations function number>] [-p] [+w <splitting parameter>] [+q <power of 10 for multiplier in [2..6]>] [+f <FilePath to the file to be appended the resulting String> <control parameter for output parts>] [+x <maximum number of words taken>] [+dc <whether to print <br> tag at the end of each line for two-column output> <FilePath to the file where the two-column output will be written in addition to stdout>] [+ln <a sequence of Word8 positive integer values not greater than 255 e. g. 24 54 57 159 45 39 to compare similarity with> -ln]][+di] <Ukrainian textual line>\n" | xs == "OR" = putStrLn "OR:" | xs == "n" = putStrLn "+n \t— if specified then the order of sorting and printing is descending (the reverse one to the default otherwise). \n" | xs == "l" = putStrLn "+l \t— if specified then the output for one property (no tests) contains empty lines between the groups of the line option with the same value of property. \n"@@ -175,6 +177,7 @@ | xs == "b" = putStrLn "+b ... -b \t— if present takes precedence over those ones in the +a ... -a group (the latter ones have no effect). A group of constraints for AFTOVolio using some boolean-based algebra. If you use parentheses there, please, use quotation of the whole expression between the +b and -b (otherwise there will be issues with the shell or command line interpreter related to parentheses). For example, on Linux bash or Windows PowerShell: +b \'P45(A345 B32)\' -b. If you use another command line environment or interpreter, please, refer to the documentation for your case about the quotation and quotes. For more information, see: \nhttps://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioEng.7.pdf in English or: \nhttps://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioUkr.7.pdf in Ukrainian.\n" | xs == "l2" = putStrLn "+l2 ... -l2 \t— if present and has inside Ukrainian text then the line options are compared with it using the idea of lists similarity. The greater values correspond to the less similar and more different lines. Has no effect with +dc group of command line arguments. Has precedence over +t, +r, +k, +c etc. groups of command line options so that these latter ones have no effect when +l2 ... -l2 is present.\n" | xs == "ln" = putStrLn "+ln ... -ln \t— if present and has inside a sequence of Word8 values i. e. positive integer numbers less than 256 then the line options are compared with it using the idea of lists similarity. The greater values correspond to the less similar and more different lines. Has no effect with +dc group of command line arguments. Has precedence over +t, +r, +k, +c etc. groups of command line options so that these latter ones have no effect when +ln ... -ln is present.\n"+ | xs == "di" = putStrLn "+di \t— if present implies the \"differentiation\" mode of computation for the comparing options with the line in +l2 or +ln groups of command line arguments. Is useful mostly in case of the line to compare with has approximately the same number of syllables as the option lines." | xs == "q" = putStrLn "+q \t— if present with +l2 ... -l2 group of arguments then the next argument is a power of 10 which the distance between line option and the predefined line is quoted by. The default one is 0 (that means no change). You can specify not less than 0 and not greater than 4. Otherwise, these limit numbers are used instead. The greater value here leads to more groupped options output.\n" | xs == "ul" = putStrLn "+ul \t— afterwards there is a string that encodes which sounds are used for diversity property evaluation. If used, then +r group has no meaning and is not used. Unlike in the link, the argument \"1\" means computing the property for all the sound representations included (for all of the present representations, so the value is maximal between all other strings instead of \"1\"). For more information, see: https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#types\n" | xs == "r" = putStrLn "+r \t— afterwards are several unique digits not greater than 8 in the descending order — the first one is the length of the group of syllables to be considered as a period, the rest — positions of the maximums and minimums. Example: \"543\" means that the line is splitted into groups of 5 syllables starting from the beginning, then the positions of the most maximum (4 = 5 - 1) and the next (smaller) maximum (3 = 4 - 1). If there are no duplicated values then the lowest possible value here is 0, that corresponds to the lowest minimum. If there are duplicates then the lowest value here is the number of the groups of duplicates, e. g. in the sequence 1,6,3,3,4,4,5 that is one group there are two groups of duplicates — with 3 and 4 — and, therefore, the corresponding data after +r should be 7...2. The values less than the lowest minimum are neglected.\n"@@ -202,6 +205,7 @@ | xs == "+b" = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","b"] | xs == "+l2" = ["0","4","l2"] | xs == "+ln" = ["0","8","ln"] + | xs == "+di" = ["0","4","OR","5","OR","6","OR","7","OR","8","di"] | xs == "+q" = ["0","4","OR","5","OR","6","q"] | xs == "+ul" = ["0","3","ul"] | xs == "+r" = ["0","1","r"]