aftovolio 0.5.1.1 → 0.6.0.0
raw patch · 8 files changed
+177/−34 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Aftovolio.PermutationsArrMini2: genDoublePermutations2 :: Int -> Array Int [Int]
+ Aftovolio.PermutationsArrMini2: genDoublePermutationsArr2 :: Array Int (Array Int [Int])
+ Aftovolio.PermutationsArrMini2: genDoublePermutationsArrL2 :: Array Int [Array Int Int]
+ Aftovolio.PermutationsArrMini2: genDoublePermutationsArrLN2 :: Int -> Array Int [Array Int Int]
+ Aftovolio.PermutationsArrMini2: genDoublePermutationsArrN2 :: Int -> Array Int (Array Int [Int])
+ Aftovolio.PermutationsArrMini2: genDoublePermutationsL2 :: [Array Int Int]
+ Aftovolio.PermutationsArrMini2: genDoublePermutationsLN2 :: Int -> [Array Int Int]
+ Aftovolio.PermutationsArrMini2: pairsSwapP2 :: [Int] -> [[Int]]
+ Aftovolio.PermutationsRepresent: permChoose :: PermutationsType -> Int -> [Array Int Int]
Files
- Aftovolio/General/Simple.hs +10/−4
- Aftovolio/PermutationsArr.hs +1/−1
- Aftovolio/PermutationsArrMini2.hs +115/−0
- Aftovolio/PermutationsRepresent.hs +16/−1
- CHANGELOG.md +4/−0
- README.md +12/−12
- aftovolio.cabal +3/−3
- src/Main.hs +16/−13
Aftovolio/General/Simple.hs view
@@ -12,8 +12,12 @@ import Aftovolio.General.PrepareText import Aftovolio.General.Syllables import Aftovolio.Halfsplit-import Aftovolio.PermutationsArr import Aftovolio.StrictVG+import Aftovolio.PermutationsArr+import Aftovolio.PermutationsArrMini1+import Aftovolio.PermutationsArrMini2+import Aftovolio.PermutationsArrMini+import Aftovolio.PermutationsRepresent import Aftovolio.Tests import Aftovolio.UniquenessPeriodsG import CLI.Arguments@@ -445,10 +449,11 @@ l = length ll 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.+ permutationsType = bTransform2Perms . getB "+P" $ argsB !perms- | not (L.null argCBs) = filterGeneralConv l argCBs . genPermutationsL $ l- | L.null argCs = genPermutationsL l- | otherwise = decodeLConstraints argCs . genPermutationsL $ l+ | not (L.null argCBs) = filterGeneralConv l argCBs . permChoose permutationsType $ l+ | L.null argCs = permChoose permutationsType l+ | otherwise = decodeLConstraints argCs . permChoose permutationsType $ l basiclineoption = unwords arg3s example = (if differentiate then C2 . fromSmallWord8toInt8Diff else C1)@@ -583,6 +588,7 @@ , ("+dc", 2) , ("+q", 1) , ("-cm", 1)+ , ("+P", 1) ] -- | 'selectSounds' converts the argument after \"+ul\" command line argument into a list of sound representations that is used for evaluation of \'uniqueness periods\' properties of the line. Is a modified Phonetic.Languages.Simplified.Array.General.FuncRep2RelatedG2.parsey0Choice from the @phonetic-languages-simplified-generalized-examples-array-0.19.0.1@ package.
Aftovolio/PermutationsArr.hs view
@@ -64,7 +64,7 @@ #-} genPermutations :: (Ord a, Enum a, Num a) => Int -> Array Int [a]-genPermutations n = listArray (0, L.product [1 .. (n - 1)]) . L.permutations . take n $ [0 ..]+genPermutations n = listArray (0, L.product [1 .. n] - 1) . L.permutations . take n $ [0 ..] {-# INLINE genPermutations #-} {-# SPECIALIZE genPermutations :: Int -> Array Int [Int] #-}
+ Aftovolio/PermutationsArrMini2.hs view
@@ -0,0 +1,115 @@+{-# LANGUAGE Strict #-}+{-# LANGUAGE NoImplicitPrelude #-}++{- |+Module : Aftovolio.PermutationsArrMini2+Copyright : (c) OleksandrZhabenko 2024+License : MIT+Stability : Experimental+Maintainer : oleksandr.zhabenko@yahoo.com++Special permutations functions for the AFTOVolio. This+module uses no vectors, but instead uses arrays.+-}+module Aftovolio.PermutationsArrMini2 (+ genDoublePermutations2,+ pairsSwapP2,+ genDoublePermutationsArrN2,+ genDoublePermutationsArr2,+ genDoublePermutationsLN2,+ genDoublePermutationsL2,+ genDoublePermutationsArrLN2,+ genDoublePermutationsArrL2,+) where++import GHC.Arr+import GHC.Base+import GHC.Enum+import GHC.List+import Data.List ((\\),nub)+import GHC.Num (Num, abs, (+), (-), (*))++genDoublePermutations2 :: Int -> Array Int [Int]+genDoublePermutations2 n = listArray (0, l - 1) xs+ where+ xs = pairsSwapP2 . take n $ [0 ..]+ l = length xs+{-# INLINE genDoublePermutations2 #-}+--{-# SPECIALIZE genDoublePermutations2 :: Int -> Array Int [Int] #-}++pairsSwapP2 :: [Int] -> [[Int]]+pairsSwapP2 xs = nub $+ xs+ : cuts+ where l = length xs+ indices = [(i,j) | i <- xs, j <- xs, j /= i]+ cuts = concatMap (\(i, j) -> + let idxs = filter (\x -> x /= i && x /= j) xs+ in map (\(i', j') -> + let (mn, mx) = if j' > i' then (i', j') else (j', i')+ (ks, us) = splitAt mn idxs + idx1 = ks ++ (i : us) + (rs, qs) = splitAt mx idx1+ in rs ++ (j : qs)) . filter (/= (i, j)) $ indices) indices+--{-# SPECIALIZE pairsSwapP2 :: [Int] -> [[Int]] #-}++-- | The second argument is greater than the first, the third is not equal to the first, the fourth is not equal to the second, and all five of the arguments are considered greater or equal to 0, though it is not checked.+swap2ns2 :: (Ord a, Num a) => a -> a -> a -> a -> a -> a+swap2ns2 k n m j i+ | q > 0 && p > 0 = i+ | i == j = n+ | i == m = k --+ | q > 0 && p < 0 = if j > n then i + 1 else i - 1+ | q < 0 && p > 0 = if m > k then i + 1 else i - 1+ | q < 0 && p < 0 = if (k - m)*(n - j) > 0 + then if m > k then i + 2 else i - 2+ else i+ | i == n = if m == n then k else if j > n then n + 1 else n - 1+ | i == k = if j == k then n else if m > k then k + 1 else k - 1+ where q = (i - k)*(i - m)+ p = (i - n)*(i - j)+{-# INLINE swap2ns2 #-}+{-# SPECIALIZE swap2ns2 :: Int -> Int -> Int -> Int -> Int -> Int #-}++swap2Ls2 :: (Ord a, Num a) => a -> a -> a -> a -> [a] -> [a]+swap2Ls2 k n m j = map (swap2ns2 k n m j)+{-# INLINE swap2Ls2 #-}+{-# SPECIALIZE swap2Ls2 :: Int -> Int -> Int -> Int -> [Int] -> [Int] #-}++genDoublePermutationsArrN2 ::+ Int -> Array Int (Array Int [Int])+genDoublePermutationsArrN2 n = amap genDoublePermutations2 . listArray (0, n - 2) $ [2 .. n]+{-# INLINE genDoublePermutationsArrN2 #-}+--{-# SPECIALIZE genDoublePermutationsArrN2 ::+-- Int -> Array Int (Array Int [Int])+-- #-}++genDoublePermutationsArr2 ::+ Array Int (Array Int [Int])+genDoublePermutationsArr2 = genDoublePermutationsArrN2 10+{-# INLINE genDoublePermutationsArr2 #-}+--{-# SPECIALIZE genDoublePermutationsArr2 :: Array Int (Array Int [Int]) #-}++genDoublePermutationsLN2 :: Int -> [Array Int Int]+genDoublePermutationsLN2 n = map (\xs -> listArray (0, n - 1) xs) . pairsSwapP2 . take n $ [0 ..]+{-# INLINE genDoublePermutationsLN2 #-}+--{-# SPECIALIZE genDoublePermutationsLN2 :: Int -> [Array Int Int] #-}++genDoublePermutationsL2 :: [Array Int Int]+genDoublePermutationsL2 = genDoublePermutationsLN2 10+{-# INLINE genDoublePermutationsL2 #-}+--{-# SPECIALIZE genDoublePermutationsL2 :: [Array Int Int] #-}++genDoublePermutationsArrLN2 ::+ Int -> Array Int [Array Int Int]+genDoublePermutationsArrLN2 n = amap genDoublePermutationsLN2 . listArray (0, n - 2) $ [2 .. n]+{-# INLINE genDoublePermutationsArrLN2 #-}+--{-# SPECIALIZE genDoublePermutationsArrLN2 ::+-- Int -> Array Int [Array Int Int]+-- #-}++genDoublePermutationsArrL2 ::+ Array Int [Array Int Int]+genDoublePermutationsArrL2 = genDoublePermutationsArrLN2 10+{-# INLINE genDoublePermutationsArrL2 #-}+--{-# SPECIALIZE genDoublePermutationsArrL2 :: Array Int [Array Int Int] #-}
Aftovolio/PermutationsRepresent.hs view
@@ -13,18 +13,33 @@ module Aftovolio.PermutationsRepresent ( PermutationsType (..), bTransform2Perms,+ permChoose ) where import GHC.Base import Text.Show+import Aftovolio.PermutationsArr+import Aftovolio.PermutationsArrMini1+import Aftovolio.PermutationsArrMini2+import Aftovolio.PermutationsArrMini+import GHC.Arr data PermutationsType = P Int deriving (Eq, Ord) instance Show PermutationsType where- show (P x) = "+p " `mappend` show x+ show (P x) = "+P " `mappend` show x bTransform2Perms :: [String] -> PermutationsType bTransform2Perms ys | ys == ["1"] = P 1 | ys == ["2"] = P 2+ | ys == ["3"] = P 3 | otherwise = P 0++permChoose :: PermutationsType -> Int -> [Array Int Int]+permChoose permType+ | permType == P 0 = genPermutationsL+ | permType == P 1 = genElementaryPermutationsLN1+ | permType == P 2 = genPairwisePermutationsLN+ | permType == P 3 = genDoublePermutationsLN2+
CHANGELOG.md view
@@ -40,3 +40,7 @@ * Fifth version revised B. Fixed documentation to reveal the latest changes. +## 0.6.0.0 -- 2024-11-21++* Sixth version. Added new module Aftovolio.PermutationsArrMini2. Added new command line argument "+P <non-negative Int, presumably in the range 0..3>", which specifies the general type of permutations of the words and their concatenations. +P 0 corresponds the full set of all possible permutations (the default behaviour, also in case of no specification at all), +P 1 corresponds to the set of permutations, where just one word can change its position (the elementary, the least possible permutation), +P 2 corresponds to the set of permutations, where two words can be swapped one with another, +P 3 corresponds to the set of permutations, where no more than two words can change their positions, including the cases of no changes at all and just one word changes its position. All, except +P 0 provide less permutations in general and are quicker to be computed and displayed. This one is more useful in case of extended sets of words, e. g. when there are 8 or 9 words in the line. Fixed issue with genPermutations function. Some minor code and documentation improvements.+
README.md view
@@ -6,7 +6,7 @@ # Introduction -Here is a brief introduction of AFTOVolio ideas and usage (that is Dutch 'Aanpak van Fonetische Talen voor het Ontdekken van de VOorkeursLIjnOpties' (Dutch people consider ij as a one letter and consequently one sound, but we use just first one for good readability) — 'Phonetic Languages Approach for Discovering the Preferred Line Options').+Here is a brief introduction of AFTOVolio ideas and usage (that is Dutch 'Aanpak van Fonetische Talen voor het Ontdekken van de VOorkeursLIjnOpties' (Dutch people consider ij as a letter and consequently one sound, but we use just first one for good readability) — 'Phonetic Languages Approach for Discovering the Preferred Line Options'). Using AFTOVolio lets a person learn how to write the texts with the desired properties in pronunciation. @@ -47,10 +47,8 @@ science, as a certain component of phonetics, but are the subject of a broader study of phonetics. Moreover, there are no restrictions and bindings of the proposed approach to the actual syllables, which is more-typical for the subject of the study of prosody. Generalizations in the-package-[aftovolio-general](https://hackage.haskell.org/package/aftovolio-general)-can be made for more general cases.+typical for the subject of the study of prosody. Generalizations can +be made for more general cases. However, at this stage of development, the vast majority of information here relates to or is directly related to syllables and prosody.@@ -980,25 +978,25 @@ SYNOPSIS: -- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+c <HashCorrections encoded>] [-e] [+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+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [+c <HashCorrections encoded>] [-e] [+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 OR:-- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+c <HashCorrections encoded>] [-e] [+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+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [+c <HashCorrections encoded>] [-e] [+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 OR:-- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+ul <diversity property encoding string>] [+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+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [+ul <diversity property encoding string>] [+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] [-e] [+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+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [-e] [+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] [-e] [+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+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [-e] [+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] [-e] [+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>]]+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [-e] [+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] [-e] [+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>]]+- aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [-e] [+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>]@@ -1023,6 +1021,8 @@ - +a \... -a — if present contains a group of constraints for AFTOVolio. For more information, see above. - +b \... -b — 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 above.++- +P — if specified with the following non-negative Int from 0 to 3 including then specifies the general type of permutations of the words and their concatenations. +P 0 corresponds the full set of all possible permutations (the default behaviour, also in case of no specification at all), +P 1 corresponds to the set of permutations, where just one word can change its position (the elementary, the least possible permutation), +P 2 corresponds to the set of permutations, where two words can be swapped one with another, +P 3 corresponds to the set of permutations, where no more than two words can change their positions, including the cases of no changes at all and just one word changes its position. All, except +P 0 provide less permutations in general and are quicker to be computed and displayed. This one is more useful in case of extended sets of words, e. g. when there are 8 or 9 words in the line. - +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.
aftovolio.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: aftovolio-version: 0.5.1.1+version: 0.6.0.0 -- A short (one-line) description of the package. synopsis: An AFTOVolio implementation for creating texts with special phonetic / prosodic properties.@@ -24,7 +24,7 @@ library -- Modules included in this executable, other than Main.- exposed-modules: Aftovolio.Ukrainian.Common2, Aftovolio.Ukrainian.IO, Aftovolio.Ukrainian.PrepareText, Aftovolio.Ukrainian.ReverseConcatenations, Aftovolio.DataG, Aftovolio.StrictVG, Aftovolio.Partir, Data.ChooseLine2, Aftovolio.PermutationsArr, Aftovolio.PermutationsArrMini, Aftovolio.PermutationsArrMini1, Aftovolio.PermutationsRepresent, Aftovolio.Constraints, Aftovolio.ConstraintsEncoded, Aftovolio.Tests, Aftovolio.Ukrainian.Syllable, Aftovolio.Ukrainian.Melodics, Aftovolio.Ukrainian.SyllableWord8, Aftovolio.Basis, Aftovolio.UniquenessPeriodsG, Aftovolio.Coeffs, Aftovolio.Ukrainian.ReadDurations, Aftovolio.General.Datatype3, Aftovolio.General.Distance, Aftovolio.Halfsplit, Aftovolio.General.Parsing, Aftovolio.General.Base, Aftovolio.General.PrepareText, Aftovolio.General.Simple, Aftovolio.General.SpecificationsRead, Aftovolio.General.Syllables, Aftovolio.RGLPK.General + exposed-modules: Aftovolio.Ukrainian.Common2, Aftovolio.Ukrainian.IO, Aftovolio.Ukrainian.PrepareText, Aftovolio.Ukrainian.ReverseConcatenations, Aftovolio.DataG, Aftovolio.StrictVG, Aftovolio.Partir, Data.ChooseLine2, Aftovolio.PermutationsArr, Aftovolio.PermutationsArrMini, Aftovolio.PermutationsArrMini2, Aftovolio.PermutationsArrMini1, Aftovolio.PermutationsRepresent, Aftovolio.Constraints, Aftovolio.ConstraintsEncoded, Aftovolio.Tests, Aftovolio.Ukrainian.Syllable, Aftovolio.Ukrainian.Melodics, Aftovolio.Ukrainian.SyllableWord8, Aftovolio.Basis, Aftovolio.UniquenessPeriodsG, Aftovolio.Coeffs, Aftovolio.Ukrainian.ReadDurations, Aftovolio.General.Datatype3, Aftovolio.General.Distance, Aftovolio.Halfsplit, Aftovolio.General.Parsing, Aftovolio.General.Base, Aftovolio.General.PrepareText, Aftovolio.General.Simple, Aftovolio.General.SpecificationsRead, Aftovolio.General.Syllables, Aftovolio.RGLPK.General -- LANGUAGE extensions used by modules in this package. other-extensions: NoImplicitPrelude, BangPatterns, DeriveGeneric, StrictData@@ -36,7 +36,7 @@ main-is: Main.hs -- Modules included in this executable, other than Main.- other-modules: Aftovolio.Ukrainian.Common2, Aftovolio.Ukrainian.IO, Aftovolio.Ukrainian.PrepareText, Aftovolio.Ukrainian.ReverseConcatenations, Aftovolio.DataG, Aftovolio.StrictVG, Aftovolio.Partir, Data.ChooseLine2, Aftovolio.PermutationsArr, Aftovolio.PermutationsArrMini, Aftovolio.PermutationsArrMini1, Aftovolio.PermutationsRepresent, Aftovolio.Constraints, Aftovolio.ConstraintsEncoded, Aftovolio.Tests, Aftovolio.Ukrainian.Syllable, Aftovolio.Ukrainian.Melodics, Aftovolio.Ukrainian.SyllableWord8, Aftovolio.Basis, Aftovolio.UniquenessPeriodsG, Aftovolio.Coeffs, Aftovolio.Ukrainian.ReadDurations, Aftovolio.General.Datatype3, Aftovolio.General.Distance, Aftovolio.Halfsplit, Aftovolio.General.Parsing, Aftovolio.General.Base, Aftovolio.General.PrepareText, Aftovolio.General.Simple, Aftovolio.General.SpecificationsRead, Aftovolio.General.Syllables, Aftovolio.RGLPK.General+ other-modules: Aftovolio.Ukrainian.Common2, Aftovolio.Ukrainian.IO, Aftovolio.Ukrainian.PrepareText, Aftovolio.Ukrainian.ReverseConcatenations, Aftovolio.DataG, Aftovolio.StrictVG, Aftovolio.Partir, Data.ChooseLine2, Aftovolio.PermutationsArr, Aftovolio.PermutationsArrMini, Aftovolio.PermutationsArrMini2, Aftovolio.PermutationsArrMini1, Aftovolio.PermutationsRepresent, Aftovolio.Constraints, Aftovolio.ConstraintsEncoded, Aftovolio.Tests, Aftovolio.Ukrainian.Syllable, Aftovolio.Ukrainian.Melodics, Aftovolio.Ukrainian.SyllableWord8, Aftovolio.Basis, Aftovolio.UniquenessPeriodsG, Aftovolio.Coeffs, Aftovolio.Ukrainian.ReadDurations, Aftovolio.General.Datatype3, Aftovolio.General.Distance, Aftovolio.Halfsplit, Aftovolio.General.Parsing, Aftovolio.General.Base, Aftovolio.General.PrepareText, Aftovolio.General.Simple, Aftovolio.General.SpecificationsRead, Aftovolio.General.Syllables, Aftovolio.RGLPK.General ghc-options: -threaded -rtsopts -- LANGUAGE extensions used by modules in this package. other-extensions: NoImplicitPrelude, BangPatterns, DeriveGeneric, StrictData
src/Main.hs view
@@ -22,7 +22,6 @@ import CLI.Arguments.Get import CLI.Arguments.Parsing import Aftovolio.ConstraintsEncoded-import Aftovolio.PermutationsArr import Aftovolio.StrictVG import Aftovolio.Ukrainian.IO import Aftovolio.General.Datatype3 (read3)@@ -33,6 +32,7 @@ import Aftovolio.Ukrainian.ReadDurations import Data.ChooseLine2 import Control.DeepSeq+import Aftovolio.PermutationsRepresent main :: IO () main = do@@ -132,10 +132,11 @@ ll = take maxNumWords . (if prepare then id else words . mconcat . prepareTextN3 maxNumWords . unwords) $ arg3s l = length ll argCs = catMaybes (fmap (readMaybeECG l) . getC "+a" $ argsC)+ permutationsType = bTransform2Perms . getB "+P" $ argsB !perms - | not (null argCBs) = filterGeneralConv l argCBs . genPermutationsL $ l- | null argCs = genPermutationsL l- | otherwise = decodeLConstraints argCs . genPermutationsL $ l + | not (null argCBs) = filterGeneralConv l argCBs . permChoose permutationsType $ l+ | null argCs = permChoose permutationsType l+ | otherwise = decodeLConstraints argCs . permChoose permutationsType $ l variants1 = force . uniquenessVariants2GNBL ' ' id id id perms $ ll if helpMessage then do hSetNewlineMode stdout universalNewlineMode@@ -144,7 +145,7 @@ bSpecs :: CLSpecifications-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)] +bSpecs = (zip ["+c","+d","+k","-h","+r","+s","-t","+ul","+w","+x","+q","+m2","-cm","+P"] . cycle $ [1]) `mappend` [("+f",2),("+m",2),("+dc",2),("+m3",3)] aSpecs :: CLSpecifications aSpecs = zip ["+di", "-e", "+l", "-p", "-C"] . cycle $ [0]@@ -155,14 +156,14 @@ helpPrint :: String -> IO () helpPrint xs | xs == "0" = putStrLn "SYNOPSIS:\n"- | xs == "1" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+c <HashCorrections encoded>] [-e] [+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>] [-e] [+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>] [+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] [-e] [+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] [-e] [+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] [-e] [+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 == "1" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [+c <HashCorrections encoded>] [-e] [+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] [+P <non-negative Int>] [+c <HashCorrections encoded>] [-e] [+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] [+P <non-negative Int>] [+ul <diversity property encoding string>] [+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] [+P <non-negative Int>] [-e] [+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] [+P <non-negative Int>] [-e] [+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] [+P <non-negative Int>] [-e] [+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] [-e] [+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 == "8" = putStrLn "aftovolioUkr [[+a <AFTOVolio constraints> -a] [+b <extended algebraic AFTOVolio constraints> -b] [+P <non-negative Int>] [-e] [+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 == "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" | xs == "w" = putStrLn "+w \t— if specified with the next Int8 number then the splitting of the output for non-testing options is used. Is used when no \"-t\" argument is given. The output is split into two columns to improve overall experience. The parameter after the \"+w\" is divided by 10 (-10 for negative numbers) to obtain the quotient and remainder (Int8 numbers). The quotient specifies the number of spaces or tabular characters to be used between columns (if the parameter is positive then the spaces are used, otherwise tabular characters). The remainder specifies the option of displaying. If the absolute value of the remainder (the last digit of the parameter) is 1 then the output in the second column is reversed; if it is in the range [2..5] then the output is groupped by the estimation values: if it is 2 then the first column is reversed; if it is 3 then the second column is reversed; if it is 4 then like 2 but additionally the empty line is added between the groups; if it is 5 then like for 3 and additionally the empty line is added between the groups. Otherwise, the second column is reversed. The rules are rather complex, but you can give a try to any number (Int8, [129..128] in the fullscreen terminal). The default value is 54 that corresponds to some reasonable layout.\n"@@ -173,6 +174,7 @@ | xs == "dc" = putStrLn "+dc \t— if specified with two further arguments then the first one can be 1 or something else. If it is 1 then additionally to every line as usual there is printed also <br> html tag at the end of the line for the two-columns output. Otherwise, nothing is added to each line. The second argument further is a FilePath to the writable existing file or to the new file that will be located in the writable by the user directory. The two-column output will be additionally written to this file if it is possible, otherwise the program will end with an exception.\n" | xs == "a" = putStrLn "+a ... -a \t— if present contains a group of constraints for AFTOVolio. For more information, see: \nhttps://hackage.haskell.org/package/aftovolio-0.5.1.1/src/README.md in English or in Ukrainian: \nhttps://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Ukr.21.html#%D0%BE%D0%B1%D0%BC%D0%B5%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F-constraints\n" | 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://hackage.haskell.org/package/aftovolio-0.5.1.1/src/README.md in English or: \nhttps://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioUkr.7.pdf in Ukrainian.\n"+ | xs == "P" = putStrLn "+P \t— if specified with the following non-negative Int from 0 to 3 including then specifies the general type of permutations of the words and their concatenations. +P 0 corresponds the full set of all possible permutations (the default behaviour, also in case of no specification at all), +P 1 corresponds to the set of permutations, where just one word can change its position (the elementary, the least possible permutation), +P 2 corresponds to the set of permutations, where two words can be swapped one with another, +P 3 corresponds to the set of permutations, where no more than two words can change their positions, including the cases of no changes at all and just one word changes its position. All, except +P 0 provide less permutations in general and are quicker to be computed and displayed. This one is more useful in case of extended sets of words, e. g. when there are 8 or 9 words in the line." | 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."@@ -201,6 +203,7 @@ | xs == "+dc" = ["0","1","OR","3","OR","4","OR","5","OR","6","OR","8","dc"] | xs == "+a" = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","OR","8","a"] | xs == "+b" = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","OR","8","b"] + | xs == "+P" = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","OR","8","P"] | xs == "+l2" = ["0","4","l2"] | xs == "+ln" = ["0","8","ln"] | xs == "+di" = ["0","1", "OR", "2", "OR","4","OR","5","OR","6","OR","8","di"]@@ -216,5 +219,5 @@ | xs == "+m" = ["0","5","m"] | xs == "+m2" = ["0","5","m2"] | xs == "+m3" = ["0","6","m3"] - | otherwise = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","OR","7","OR","8","l","w","s","d","p","f","dc","a","b","l2","q","ul","r","c","t","C","k","x","m","m2","cm"]+ | otherwise = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","OR","7","OR","8","l","w","s","d","p","f","dc","a","b","P","l2","q","ul","r","c","t","C","k","x","m","m2","cm"]