phladiprelio-ukrainian-simple 0.5.3.0 → 0.6.0.0
raw patch · 4 files changed
+120/−26 lines, 4 filesdep ~phonetic-languages-constraints-array
Dependency ranges changed: phonetic-languages-constraints-array
Files
- CHANGELOG.md +7/−1
- README.md +7/−4
- app/Main.hs +104/−19
- phladiprelio-ukrainian-simple.cabal +2/−2
CHANGELOG.md view
@@ -94,7 +94,13 @@ * Fifth version revised E. Fixed issue with incorrect work with spaces inside the +b ... -b algebraic constraints arguments. The parentheses usage inside the +b ... -b is still not working--- it is a known issue to be fixed in the further releeases. It is alse an intermediate release +-- it is a known issue to be fixed in the further releases. It is also an intermediate release for testing. +## 0.6.0.0 -- 2023-06-02++* Sixth version. Fixed issues with the incorrect work of the parentheses inside the +b ... -b +command line arguments group. Added much more tests to -t parameters. Some performance improvements. Updated the+documentation of the help menu and general documentation. Updated the dependecy boundaries for the+new version of phonetic-languages-constraints-array to fix functionality.
README.md view
@@ -1,6 +1,6 @@ The executable is the new implementation of the ideas related to PhLADiPreLiO (Phonetic Languages Approach to Discovering the Preferred Line Options) for Ukrainian language. It uses hashes and-has at the moment (as of the version 0.5.2.0) not the full functionality. The previous implementation +has at the moment (as of the version 0.6.0.0) not the full functionality. The previous implementation and its documentation are at the links: https://hackage.haskell.org/package/phonetic-languages-simplified-examples-array@@ -14,7 +14,7 @@ [New implementation](https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioEng.5.2.pdf) -Examples of the new functionality in the version 0.5.1.0 is in the video:+Examples of the new functionality in the version 0.5.1.1 are in the videos: https://www.facebook.com/Oleksandr.S.Zhabenko/posts/pfbid033gzq8MCRQsm65mPrzJL25MZNgvW7mezQSywULiVMnqmTBMtSW2jW4ABh6HVMWZNLl @@ -31,6 +31,9 @@ phladiprelioUkr -h +For the list of bash aliases a few of which are used in the videos, see:+https://github.com/Oleksandr-Zhabenko/phladiprelio-alias/blob/main/.bashrc+ Devotion ======== @@ -48,9 +51,9 @@ On the 14/05/2023 there is Mother's Day. It is also a good opportunity to support the foundation. -On the 25/05/2023 there is Ascension Day according to the Julian Greek Orthodox calendar. +On the 25/05/2023 there is Ascension Day according to the Julian Greek Orthodox calendar. -On the 01/06/2023 there is Children's Day in many countries including Ukraine and the Netherlands.+On the 01/06/2023 many countries including Ukraine and the Netherlands celebrate Children's Day. If you would like to share some financial support, please, contact the foundation using the URL:
app/Main.hs view
@@ -4,8 +4,8 @@ import GHC.Base import GHC.Num ((+),(-),(*))-import GHC.Real (fromIntegral,(/))-import GHC.Enum (fromEnum)+import GHC.Real (fromIntegral,(/),quot,rem)+import GHC.Enum (fromEnum,toEnum) import Text.Show (show) import Text.Read (readMaybe) import System.IO (putStrLn, FilePath,stdout,hSetNewlineMode,universalNewlineMode)@@ -32,35 +32,107 @@ import Numeric (showFFloat) generalF :: FilePath -> Int -> HashCorrections -> (Int8,[Int8]) -> Int -> Bool -> Int -> Bool -> [String] -> IO [()]-generalF file numTest hc (grps,mxms) k descending hashStep emptyline universalSet - | null universalSet = mapM putStrLn ["You have specified the data and constraints on it that lead to no further possible options.", "Please, specify another data and constraints."]- | otherwise = do+generalF file numTest hc (grps,mxms) k descending hashStep emptyline universalSet@(u1:u2:us) = do syllableDurationsDs <- readSyllableDurations file let syllN = countSyll . concat . take 1 $ universalSet -- universalSet = map unwords . permutations . words $ rs f syllableDurationsDs grps mxms = sum . countHashes2G hashStep hc grps mxms . 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- if numTest `elem` (0:[2..9]) then do+ if numTest >= 0 && numTest <= 179 && numTest /= 1 then do hSetNewlineMode stdout universalNewlineMode putStrLn "Feet Val Stat Proxim" - mapM (\(q,qs) -> let m = stat1 syllN (q,qs) in let max1 = maximumBy (comparing (f syllableDurationsDs q qs)) universalSet in let mx = f syllableDurationsDs q qs max1 in - putStrLn (show (fromEnum q) `mappend` " | " `mappend` show mx `mappend` " " `mappend` show m `mappend` " -> " `mappend` - showFFloat (Just 3) (100 * fromIntegral mx / fromIntegral m) "%" `mappend` (if numTest >= 4 - then let min1 = minimumBy (comparing (f syllableDurationsDs q qs)) universalSet in - ("\n" `mappend` min1 `mappend` "\n" `mappend` max1 `mappend` "\n") - else ""))) . zip [2..7] $ (sel numTest) + mapM (\(q,qs) -> let m = stat1 syllN (q,qs)+ (min1, max1) = minMax11ByCList (comparing (f syllableDurationsDs q qs)) universalSet + mx = f syllableDurationsDs q qs max1 in + putStrLn (show (fromEnum q) `mappend` " | " `mappend` show mx `mappend` " " `mappend` show m `mappend` " -> " `mappend` + showFFloat (Just 3) (100 * fromIntegral mx / fromIntegral m) "%" `mappend` (if quot numTest 10 >= 4 + then ("\n" `mappend` min1 `mappend` "\n" `mappend` max1 `mappend` "\n")+ else ""))) . zip (sel2 numTest) $ (sel numTest) else (if emptyline then mapM (\tss -> mapM (\(x, y) -> putStrLn (show x `mappend` (' ':y))) tss >> putStrLn "") . groupBy (\(x1,_) (x2,_) -> x1 == x2) else mapM (\(x,y) -> putStrLn (show x `mappend` (' ':y)))) . (let h1 = if descending then (\(u,w) -> ((-1) * u, w)) else id in sortOn h1) . map (\xss -> (f syllableDurationsDs grps mxms xss, xss)) $ universalSet where sel x - | x == 0 || x == 4 = [[1],[2,1],[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]]+ | x == 1 || x < 0 || x > 179 = []+ | x == 0 || x == 4 = [[1],[2,1],[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]] -- all cases are present: 2, 3, 4, 5, 6, 7. Therefore, the slowest ones. | x == 2 || x == 5 = [[1],[2],[3],[4,3],[5,4],[6,5,4]] | x == 7 = [[0],[1,0],[1,0],[1,0],[1,0],[1,0]] | x == 8 = [[0],[1,0],[1,0],[2,1,0],[2,1,0],[2,1,0]] | x == 9 = [[0],[1,0],[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]]+-----------------------------------------------------------------------------+ | x >= 20 && x <= 26 && x /= 21 = [[1]] -- at least 7 is omitted, but probably 6, or even 5, or even 4, or even 3. 2 is however present.+ | x >= 27 && x <= 29 = [[0]]+ | x == 30 || x == 34 = [[1],[2,1]]+ | x == 32 || x == 35 = [[1],[2]]+ | x >= 37 && x <= 39 = [[0],[1,0]]+ | x == 40 || x == 44 = [[1],[2,1],[3,2]]+ | x == 42 || x == 45 = [[1],[2],[3]]+ | x >= 47 && x <= 49 = [[0],[1,0],[1,0]]+ | x == 50 || x == 54 = [[1],[2,1],[3,2],[4,3,2]]+ | x == 52 || x == 55 = [[1],[2],[3],[4,3]]+ | x == 57 = [[0],[1,0],[1,0],[1,0]]+ | x == 58 || x == 59 = [[0],[1,0],[1,0],[2,1,0]]+ | x == 60 || x == 64 = [[1],[2,1],[3,2],[4,3,2],[5,4,3]]+ | x == 62 || x == 65 = [[1],[2],[3],[4,3],[5,4]]+ | x == 67 = [[0],[1,0],[1,0],[1,0],[1,0]]+ | x == 68 = [[0],[1,0],[1,0],[2,1,0],[2,1,0]]+ | x == 69 = [[0],[1,0],[1,0],[2,1,0],[3,2,1,0]]+-----------------------------------------------------------------+ | x == 70 || x == 74 = [[2,1],[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]] -- at least 2 is omitted, but probably 3 and even 4. 5, 6 and 7 are present.+ | x == 72 || x == 75 = [[2],[3],[4,3],[5,4],[6,5,4]]+ | x == 77 = [[1,0],[1,0],[1,0],[1,0],[1,0]]+ | x == 78 = [[1,0],[1,0],[2,1,0],[2,1,0],[2,1,0]]+ | x == 79 = [[1,0],[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]]+ | x == 80 || x == 84 = [[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]]+ | x == 82 || x == 85 = [[3],[4,3],[5,4],[6,5,4]]+ | x == 87 = [[1,0],[1,0],[1,0],[1,0]]+ | x == 88 = [[1,0],[2,1,0],[2,1,0],[2,1,0]]+ | x == 89 = [[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]]+ | x == 90 || x == 94 = [[4,3,2],[5,4,3],[6,5,4,3,2]]+ | x == 92 || x == 95 = [[4,3],[5,4],[6,5,4]]+ | x == 97 = [[1,0],[1,0],[1,0]]+ | x == 98 = [[2,1,0],[2,1,0],[2,1,0]]+ | x == 99 = [[2,1,0],[3,2,1,0],[3,2,1,0]]+-----------------------------------------------------------------------------------+ | x == 100 || x == 104 = [[1],[2,1],[4,3,2],[6,5,4,3,2]] -- 4 and 6 are omitted, just present the ones from: 2, 3, 5, 7.+ | x == 102 || x == 105 = [[1],[2],[4,3],[6,5,4]]+ | x == 107 = [[0],[1,0],[1,0],[1,0]]+ | x == 108 = [[0],[1,0],[2,1,0],[2,1,0]]+ | x == 109 = [[0],[1,0],[2,1,0],[3,2,1,0]]+-----------------------------------------------------------------------------+ | x == 150 || x == 154 = [[1],[2,1],[4,3,2]] -- 4, 6, 7 are omitted but 2, 3, 5 are present.+ | x == 152 || x == 155 = [[1],[2],[4,3]]+ | x == 157 = [[0],[1,0],[1,0]]+ | x == 158 || x == 159 = [[0],[1,0],[2,1,0]]+-----------------------------------------------------------------+ | x == 170 || x == 174 = [[2,1],[4,3,2],[6,5,4,3,2]] -- just 3, 5 and 7 are present+ | x == 172 || x == 175 = [[2],[4,3],[6,5,4]]+ | x == 177 = [[1,0],[1,0],[1,0]]+ | x == 178 = [[1,0],[2,1,0],[2,1,0]]+ | x == 179 = [[1,0],[2,1,0],[3,2,1,0]]+---------------------------------------------------------------------------------- | otherwise = [[1],[1],[2,1],[3,2,1],[3,2],[4,3,2]]+--------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------+ sel2 y + | y == 1 || y < 0 || y > 179 = []+ | (rem y 10 `elem` [1,3,6]) || y >= 0 && y <= 9 = [2..7]+ | y >= 20 && y <= 69 = [2..toEnum (y `quot` 10)]+ | y >= 70 && y <= 99 = [toEnum (y `quot` 10) - 4..7]+ | y >= 100 && y <= 109 = [2,3,5,7]+ | y >= 150 && y <= 159 = [2,3,5]+ | y >= 170 && y <= 179 = [3,5,7]+ | otherwise = [2..7]+ minMax11ByCList :: Ord a => (a -> a -> Ordering) -> [a] -> (a, a) -- Is rewritten from the 'Data.MinMax.Preconditions.minMax11ByC' from @subG@ package.+ minMax11ByCList g xs@(x:y:ys) = foldr f (if x > y then (y, x) else (x, y)) ys+ where f z (x,y)+ | g z x == LT = (z,y)+ | g z y == GT = (x,z)+ | otherwise = (x,y)+ minMax11ByCList _ _ = undefined -- Is not intended to be used for lists with less than two elements.+generalF file numTest hc (grps,mxms) k descending hashStep emptyline [u1] = mapM putStrLn [u1]+generalF _ _ _ _ _ _ _ _ _ = mapM putStrLn ["You have specified the data and constraints on it that lead to no further possible options.", "Please, specify another data and constraints."] countSyll :: String -> Int countSyll xs = fromEnum . foldr (\x y -> if isVowel1 x then y + 1 else y) 0 . convertToProperUkrainianI8 $ xs@@ -68,10 +140,20 @@ stat1 :: Int -> (Int8,[Int8]) -> Int stat1 n (k, ks) = fst (n `quotRemInt` fromEnum k) * length ks +parseHelp :: [String] -> (String,[String])+parseHelp xss + | null xss = ([],[])+ | otherwise = (unwords rss, uss `mappend` qss)+ where (yss,tss) = break (== "-b") xss+ (uss,wss) = break (== "+b") yss+ [qss,rss] = map (drop 1) [tss, wss]+ + main :: IO () main = do- args <- getArgs- let (argsA, argsB, argsC, arg2s) = args2Args31R ('+','-') (aSpecs `mappend` bSpecs `mappend` cSpecs) args+ args0 <- getArgs+ let (argCBs, args) = parseHelp args0+ (argsA, argsB, argsC, arg2s) = args2Args31R ('+','-') (aSpecs `mappend` bSpecs `mappend` cSpecs) args fileDu = concat . getB "+d" $ argsB sylD = let k = snd (fromMaybe 2 (readMaybe (concat . getB "+s" $ argsB)::Maybe Int) `quotRemInt` 4) in if k == 0 then 4 else k hc = readHashCorrections . concat . getB "+c" $ argsB@@ -83,7 +165,6 @@ helpMessage = oneA "-h" argsA argCs = catMaybes (fmap (readMaybeECG l) -- . (showB l lstW2:) . getC "+a" $ argsC)- argCBs = unwords . getC "+b" $ argsC ll = take 7 . (if prepare then id else words . mconcat . prepareText . unwords) $ arg2s l = length ll !perms @@ -111,7 +192,7 @@ putStrLn "https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#constraints in English or in Ukrainian: " putStrLn "https://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" putStrLn ""- 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 PhLADiPreLiO using some boolean-based algebra. If you use paretheses inside your constraints string, please use quotation marks in Linux shells and Windows PowerShell (basically, \' constraintswithparentheses\' is expected to be enough). For more information, see:"+ 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 PhLADiPreLiO 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 lelated 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:" putStrLn "https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioEng.5.2.pdf in English or: " putStrLn "https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioUkr.5.2.pdf in Ukrainian." putStrLn ""@@ -119,7 +200,11 @@ putStrLn "" putStrLn "+c \t— see explanation at the link: https://hackage.haskell.org/package/rhythmic-sequences-0.3.0.0/docs/src/Rhythmicity.MarkerSeqs.html#HashCorrections" putStrLn ""- putStrLn "-t \t— and afterwards the digit showing the test for \'smoothness\' (to be more accurate - absense or presense of some irregularities that influences the prosody) to be run - if 0 - more extended and strict, if 2 - less strict, more permissive, if 3 - the test for some values expected to be not the maximum nor the minimum ones in the line with no repetitions (the most common case), this option for its greatest values tends to give either more \'irregular\' lines (more jumping-like or wavy combinations) than other ones or more \'regular\' ones - it depends on the distribution of not included into account maximums and minimums; the lines with the minimum values here can be of different kinds but they are not \'stable\'; if 4 - similar to 0, but additionally there are printed two options for every part of test - one that corresponds to minimum value and one that corresponds the maximum value; if 5 - similar to 2, but additionally there are printed two options for every part of test - one that corresponds to minimum value and one that corresponds the maximum value; if 6 - similar to 3, but additionally there are printed two options for every part of test - one that corresponds to minimum value and one that corresponds the maximum value; if 7, 8, or 9 — then there are printed the mixmimum and maximum example strings for the minimums positions in the lines without repetitions during the period (feet), with more minimums taken into account with greater digit here, for 7 it is just 1 or 2 minimuums; otherwise - no tests at all (if no digit is here then it is likely that the first word can be used instead and it will be removed from the input)."+ putStrLn "-t \t— and afterwards the number in the range [0..179] (with some exceptions) showing the test for \'smoothness\' (to be more accurate - absense or presense of some irregularities that influences the prosody) to be run - you can see a list of possible values for the parameter here at the link: "+ putStrLn "https://hackage.haskell.org/package/phladiprelio-ukrainian-simple-0.6.0.0/src/app/Main.hs on the lines number: 51; 56-115; 118-126. The first section of the lines numbers 56-63 and 120 corresponds to the detailed explanation below. " + putStrLn "For different data and probably for different languages being represented here as a corresponding Ukrainian transliteration created by the user himself / herself some preliminary trials show that the following values have tendencies to manifest the following ideas and statements. If the argument here is 0 - test for \'smoothness\' is more extended, if 2 - less extended, more permissive, if 3 - the test for some values expected to be not the maximum nor the minimum ones in the line with no repetitions (the most common case), this option for its greatest values tends to give either more \'irregular\' lines (more jumping-like or wavy combinations) than other ones or more \'regular\' ones - it depends on the distribution of not included into account maximums and minimums; the lines with the minimum values here can be of different kinds but they are not \'stable\'; if 4 - similar to 0, but additionally there are printed two options for every part of test - one that corresponds to minimum value and one that corresponds the maximum value; if 5 - similar to 2, but additionally there are printed two options for every part of test - one that corresponds to minimum value and one that corresponds the maximum value; if 6 - similar to 3, but additionally there are printed two options for every part of test - one that corresponds to minimum value and one that corresponds the maximum value; if 7, 8, or 9 — then there are printed the mixmimum and maximum example strings for the minimums positions in the lines without repetitions during the period (feet), with more minimums taken into account with greater digit here, for 7 it is just 1 or 2 minimuums; otherwise - no tests at all (if no digit is here then it is likely that the first word can be used instead and it will be removed from the input)."+ putStrLn "If you use here the values from the range of 20-99 then it corresponds to the reduced set of values with all the intermediate elements included: e. g. 2, 3, 4 and 5."+ putStrLn "If you use here the values from the range of 100-179 then there are only primary numbers used for the number of syllables in the groups - just 2, 3, 5, or 7 or some subset of this set. This lead to some fastening the computation and can be beneficial to overall performance and presenting. Nevertheless, some important or valuable results can be omitted due to omittion of the composed numbers (4 and 6). Use with this caution." putStrLn "" putStrLn "+k \t— and then the number greater than 2 (better, greater than 12, the default value if not specified is 20). The greater value leads to greater numbers. The number less than some infimum here leads to wiping of some information from the result and, therefore, probably is not the desired behaviour. For most cases the default value is just enough sensible, but you can give it a try for other values." putStrLn ""@@ -132,5 +217,5 @@ aSpecs = zip ["-h", "+l", "+n","-p"] . cycle $ [0] cSpecs :: CLSpecifications-cSpecs = zip ["+a","+b"] . cycle $ [-1]+cSpecs = [("+a",-1)]
phladiprelio-ukrainian-simple.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: phladiprelio-ukrainian-simple-version: 0.5.3.0+version: 0.6.0.0 -- A short (one-line) description of the package. synopsis: A PhLADiPreLiO implementation for Ukrainian that uses hashes@@ -29,7 +29,7 @@ -- ghc-options: -threaded -rtsopts -- LANGUAGE extensions used by modules in this package. other-extensions: NoImplicitPrelude, BangPatterns- build-depends: base >=4.13 && <5, rhythmic-sequences ==0.3.0.0, ukrainian-phonetics-basic-array ==0.7.0.0, phonetic-languages-ukrainian-array ==0.10.0.0, phladiprelio-ukrainian-shared ==0.1.0.0, cli-arguments ==0.7.0.0, phonetic-languages-permutations-array ==0.4.0.0, phonetic-languages-constraints-array ==0.7.1.0, phonetic-languages-simplified-base ==0.7.0.0+ build-depends: base >=4.13 && <5, rhythmic-sequences ==0.3.0.0, ukrainian-phonetics-basic-array ==0.7.0.0, phonetic-languages-ukrainian-array ==0.10.0.0, phladiprelio-ukrainian-shared ==0.1.0.0, cli-arguments ==0.7.0.0, phonetic-languages-permutations-array ==0.4.0.0, phonetic-languages-constraints-array ==0.7.2.0, phonetic-languages-simplified-base ==0.7.0.0 hs-source-dirs: app default-language: Haskell2010