phladiprelio-ukrainian-simple 0.15.3.0 → 0.16.0.0
raw patch · 5 files changed
+154/−119 lines, 5 filesdep ~phladiprelio-ukrainian-shareddep ~phonetic-languages-simplified-basedep ~phonetic-languages-ukrainian-arrayPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: phladiprelio-ukrainian-shared, phonetic-languages-simplified-base, phonetic-languages-ukrainian-array, ukrainian-phonetics-basic-array
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- Main.hs +109/−100
- Phladiprelio/Ukrainian/IO.hs +33/−16
- README.md +2/−0
- phladiprelio-ukrainian-simple.cabal +3/−3
CHANGELOG.md view
@@ -212,3 +212,10 @@ * Fifteenth version revised C. Some performance improvements. Fixed issue with just one syllable in case of application '=' mode afterwards. Some minor documentation improvements. Switched to containers and minimax as additional dependencies. +## 0.16.0.0 -- 2024-03-08++* Sixteenth version. Added possibility to compare different line options from files. For more information on the idea see: +https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#comparative-mode-of-operation-c++Some code improvements. +
Main.hs view
@@ -29,112 +29,117 @@ import Phladiprelio.Ukrainian.Syllable import Phladiprelio.Ukrainian.SyllableDouble import Phladiprelio.Ukrainian.ReadDurations+import Data.ChooseLine main :: IO () main = do 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- syllableDurationsDs <- readSyllableDurations fileDu- let maxNumWords = let k = fromMaybe 7 (readMaybe (concat . getB "+x" $ argsB)::Maybe Int) in if k == 0 || abs k >= 9 then 9 else max (abs k) 2- hc = R.readHashCorrections . concat . getB "+c" $ argsB- dcspecs = getB "+dc" argsB- power10' = fromMaybe 4 (readMaybe (concat . getB "+q" $ argsB)::Maybe Int)- power10 - | power10' < 2 && power10' > 6 = 4- | otherwise = power10'- (html,dcfile) - | null dcspecs = (False, "")- | otherwise = (head dcspecs == "1",last dcspecs)- prepare = oneA "-p" argsA- selStr = concat . getB "+ul" $ argsB- grpp = R.grouppingR . concat . getB "+r" $ argsB- splitting = fromMaybe 50 (readMaybe (concat . getB "+w" $ argsB)::Maybe Int8)- emptyline = oneA "+l" argsA- numTest = fromMaybe 1 (readMaybe (concat . getB "-t" $ argsB)::Maybe Int)- hashStep = fromMaybe 20 (readMaybe (concat . getB "+k" $ argsB)::Maybe Int)- helpMessage = any (== "-h") args0- helpArg = concat . getB "-h" $ argsB- filedata = getB "+f" argsB- concurrently = oneA "-C" argsA- (multiline2, multiline2LineNum) - | oneB "+m3" argsB = - let r1ss = getB "+m3" argsB in - if length r1ss == 3 - then let (kss,qss) = splitAt 2 r1ss in - (kss, max 1 (fromMaybe 1 (readMaybe (concat qss)::Maybe Int))) - else (r1ss, 1)- | 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)- | length multiline2 == 2 = (head multiline2, fromMaybe 1 (readMaybe (last multiline2)::Maybe Int))- | otherwise = (head multiline2, 1)- (arg3s,prestr,poststr,linecomp3) <- do - if lineNmb /= -1 then do- txtFromFile <- readFile fileread- let lns = lines txtFromFile- ll1 = length lns- ln0 = max 1 (min lineNmb (length lns))- lm3 - | multiline2LineNum < 1 = -1- | otherwise = max 1 . min multiline2LineNum $ ll1- linecomp3 - | lm3 == -1 = []- | otherwise = lns !! (lm3 - 1)- ln_1 - | ln0 == 1 = 0- | otherwise = ln0 - 1- ln1- | ln0 == length lns = 0- | otherwise = ln0 + 1- lineF = lns !! (ln0 - 1)- line_1F - | ln_1 == 0 = []- | otherwise = lns !! (ln_1 - 1)- line1F- | ln1 == 0 = []- | otherwise = lns !! (ln1 - 1)- return $ (words lineF, line_1F,line1F,linecomp3)- else return (arg2s, [], [],[])- let line2comparewith - | oneC "+l2" argsC || null linecomp3 = unwords . getC "+l2" $ argsC- | otherwise = linecomp3- basecomp = 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 = 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- gcd1 = gcd le lb- ldc = (le * lb) `quot` gcd1- mulp = ldc `quot` lb- max2 = maximum basecomp- compards = concatMap (replicate mulp . (/ max2)) basecomp- (filesave,codesave) - | null filedata = ("",-1)- | length filedata == 2 = (head filedata, fromMaybe 0 (readMaybe (last filedata)::Maybe Int))- | otherwise = (head filedata,0)- 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)- !perms - | not (null argCBs) = filterGeneralConv l argCBs . genPermutationsL $ l- | null argCs = genPermutationsL l- | otherwise = decodeLConstraints argCs . genPermutationsL $ l - descending = oneA "+n" argsA- variants1 = uniquenessVariants2GNBL ' ' id id id perms ll- if helpMessage then do - hSetNewlineMode stdout universalNewlineMode- helpPrint helpArg- else generalF power10 ldc compards html dcfile selStr (prestr, poststr) lineNmb fileDu numTest hc grpp sylD descending hashStep emptyline splitting (filesave, codesave) concurrently (unwords arg3s) variants1 >> return ()+ compareByLinesFinalFile = concat . getB "-cm" $ argsB+ if not . null $ compareByLinesFinalFile then do+ compareFilesToOneCommon 14 arg2s compareByLinesFinalFile+ else do+ let 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+ syllableDurationsDs <- readSyllableDurations fileDu+ let maxNumWords = let k = fromMaybe 7 (readMaybe (concat . getB "+x" $ argsB)::Maybe Int) in if k == 0 || abs k >= 9 then 9 else max (abs k) 2+ hc = R.readHashCorrections . concat . getB "+c" $ argsB+ dcspecs = getB "+dc" argsB+ power10' = fromMaybe 4 (readMaybe (concat . getB "+q" $ argsB)::Maybe Int)+ power10 + | power10' < 2 && power10' > 6 = 4+ | otherwise = power10'+ (html,dcfile) + | null dcspecs = (False, "")+ | otherwise = (head dcspecs == "1",last dcspecs)+ prepare = oneA "-p" argsA+ selStr = concat . getB "+ul" $ argsB+ grpp = R.grouppingR . concat . getB "+r" $ argsB+ splitting = fromMaybe 50 (readMaybe (concat . getB "+w" $ argsB)::Maybe Int8)+ emptyline = oneA "+l" argsA+ numTest = fromMaybe 1 (readMaybe (concat . getB "-t" $ argsB)::Maybe Int)+ hashStep = fromMaybe 20 (readMaybe (concat . getB "+k" $ argsB)::Maybe Int)+ helpMessage = any (== "-h") args0+ helpArg = concat . getB "-h" $ argsB+ filedata = getB "+f" argsB+ concurrently = oneA "-C" argsA+ (multiline2, multiline2LineNum) + | oneB "+m3" argsB = + let r1ss = getB "+m3" argsB in + if length r1ss == 3 + then let (kss,qss) = splitAt 2 r1ss in + (kss, max 1 (fromMaybe 1 (readMaybe (concat qss)::Maybe Int))) + else (r1ss, 1)+ | 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)+ | length multiline2 == 2 = (head multiline2, fromMaybe 1 (readMaybe (last multiline2)::Maybe Int))+ | otherwise = (head multiline2, 1)+ (arg3s,prestr,poststr,linecomp3) <- do + if lineNmb /= -1 then do+ txtFromFile <- readFile fileread+ let lns = lines txtFromFile+ ll1 = length lns+ ln0 = max 1 (min lineNmb (length lns))+ lm3 + | multiline2LineNum < 1 = -1+ | otherwise = max 1 . min multiline2LineNum $ ll1+ linecomp3 + | lm3 == -1 = []+ | otherwise = lns !! (lm3 - 1)+ ln_1 + | ln0 == 1 = 0+ | otherwise = ln0 - 1+ ln1+ | ln0 == length lns = 0+ | otherwise = ln0 + 1+ lineF = lns !! (ln0 - 1)+ line_1F + | ln_1 == 0 = []+ | otherwise = lns !! (ln_1 - 1)+ line1F+ | ln1 == 0 = []+ | otherwise = lns !! (ln1 - 1)+ return $ (words lineF, line_1F,line1F,linecomp3)+ else return (arg2s, [], [],[])+ let line2comparewith + | oneC "+l2" argsC || null linecomp3 = unwords . getC "+l2" $ argsC+ | otherwise = linecomp3+ basecomp = 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 = 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+ gcd1 = gcd le lb+ ldc = (le * lb) `quot` gcd1+ mulp = ldc `quot` lb+ max2 = maximum basecomp+ compards = concatMap (replicate mulp . (/ max2)) basecomp+ (filesave,codesave) + | null filedata = ("",-1)+ | length filedata == 2 = (head filedata, fromMaybe 0 (readMaybe (last filedata)::Maybe Int))+ | otherwise = (head filedata,0)+ 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)+ !perms + | not (null argCBs) = filterGeneralConv l argCBs . genPermutationsL $ l+ | null argCs = genPermutationsL l+ | otherwise = decodeLConstraints argCs . genPermutationsL $ l + descending = oneA "+n" argsA+ variants1 = uniquenessVariants2GNBL ' ' id id id perms ll+ if helpMessage then do + hSetNewlineMode stdout universalNewlineMode+ helpPrint helpArg+ else generalF power10 ldc compards html dcfile selStr (prestr, poststr) lineNmb fileDu numTest hc grpp sylD descending hashStep emptyline splitting (filesave, codesave) concurrently (unwords arg3s) variants1 >> return () bSpecs :: CLSpecifications-bSpecs = (zip ["+c","+d","+k","-h","+r","+s","-t","+ul","+w","+x","+q","+m2"] . 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"] . cycle $ [1]) `mappend` [("+f",2),("+m",2),("+dc",2),("+m3",3)] aSpecs :: CLSpecifications aSpecs = zip ["+l", "+n","-p", "-C"] . cycle $ [0]@@ -151,6 +156,7 @@ | xs == "4" = putStrLn "phladiprelioUkr [[+a <PhLADiPreLiO constraints> -a] [+b <extended algebraic PhLADiPreLiO 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 "phladiprelioUkr [[+a <PhLADiPreLiO constraints> -a] [+b <extended algebraic PhLADiPreLiO 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 "phladiprelioUkr [[+a <PhLADiPreLiO constraints> -a] [+b <extended algebraic PhLADiPreLiO 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 == "7" = putStrLn "phladiprelioUkr [-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 == "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"@@ -172,10 +178,12 @@ | xs == "k" = 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.\n" | xs == "x" = putStrLn "+x \t— If specified with the further natural number then means that instead of maximum 7 words or their concatenations that can be analysed together as a line there will be taken the specified number here or 9 if the number is greater than 8. More words leads to more computations, therefore, please, use with this caution in mind. It can be useful mostly for the cases with the additional constraints specified (+a ... -a or +b ... -b groups, see above).\n" | xs == "m" = putStrLn "+m \t— If present followed with two arguments — the name of the file to be used for reading data for multiline processment and the second one — the number of line to be processed. The numeration of the lines in the file for the phladiprelioUkr program here starts from 1 (so, it is: 1, 2, 3, 4,.. etc). The program then uses instead of text the specified line from the file specified here and prints information about its previous and next lines (if available).\n"- | xs == "m2" || xs == "m3" = putStrLn "+m2 \t— If present, it means that the line with the corresponding number specified here will be taken from the same file specified as +m <file>. For example, the entry +m <file> 1 +m2 4 means that 1 line will be taken from the file <file> for the similarity analysis and it will be compared not with contents of +l2 ... -l2, but with the 4th line from the same file. \nThe abbreviation for +m <file> <num1> +m2 <num2> is +m3 <file> <num1> <num2>, which has the same meaning but a slightly shorter entry. \nIf <num1> == <num2>, then there is at least one of all the options with a property value of 0. \nYou can also use the \"music\" mode, which allows you to write better lyrics and music. To do this, you can add a record of the form _{set of digits} or ={set of digits} to a word or between syllables after the needed to be referred to, and this set of digits will be converted to a positive double-precision number by the program so that the first digit in the record is a whole number and the rest is a fraction (mantissa). \nIf you have added _{set of digits} then this number will be multiplied by the duration of the syllable to which this insertion refers, and the resulting number will be placed among the others in the place where this entry is inserted. \nIf you have added ={a set of digits} then this number will also be multiplied by the duration of the syllable to which this insertion refers, and the resulting number will be placed instead the duration that it was multiplied by. This allows to make syllables longer or shorter to follow language or creative intentions and rules (e. g. in French there have been noticed that the duration of the last syllable in the word, especially in the sentence or phrase is prolonged to some extent, so you can use '=12' or '=13' or '=14' here). Not as for the _{set of digits} group, you can place it only after the syllable and only once to change the duration of the syllable. If you use this option, the following _{set of digits} will be referred to the new changed duration here, so that \"так\"=2_05_1 will mean that you will use instead of the usual duration of the syllable \"так\" the twice as much duration, and then half of this twice as much (therefore, equal to duration of the syllable without altering) and then again the twice as much duration etc. The insertion of =1, =10, =100, =1000 etc will not change anything at all, except for the time of computations (you probably do not need this). \nThese two additional possibilities allows you to change rhythmic structures, and interpret this insert as a musical pause or, conversely, a musical phrase inserted to change the rhythm. What syllable does this insertion refer to? It refers to the previous syllable in the line. There can be several such inserts, their number is not limited by the program itself (in the program code), but a significant number of inserts can significantly increase the duration of the calculation. \n\nWhen the results of the program are displayed on the screen, these inserts will also be displayed in the appropriate places. \n\nIf you specify _1, _10, _100, _1000, etc. as such an insertion, the program will assume that this insertion duration is equal to the duration of the syllable to which it refers. If the set of digits is preceded by a 0, the insertion has a shorter duration, if the 1 in the first 4 examples above is followed by digits other than 0, or if another digit is used instead of 1 or 0, the insertion has a longer duration. For example, _05 means exactly half the duration of the syllable, and _2 means double the duration.\n\nFor the \"music\" mode the number of syllables printed for the line does include the inserts (since the version 0.15.2.0)."+ | xs == "m2" || xs == "m3" = putStrLn "+m2 \t— If present, it means that the line with the corresponding number specified here will be taken from the same file specified as +m <file>. For example, the entry +m <file> 1 +m2 4 means that 1 line will be taken from the file <file> for the similarity analysis and it will be compared not with contents of +l2 ... -l2, but with the 4th line from the same file. \nThe abbreviation for +m <file> <num1> +m2 <num2> is +m3 <file> <num1> <num2>, which has the same meaning but a slightly shorter entry. \nIf <num1> == <num2>, then there is at least one of all the options with a property value of 0. \nYou can also use the \"music\" mode, which allows you to write better lyrics and music. To do this, you can add a record of the form _{set of digits} or ={set of digits} to a word or between syllables after the needed to be referred to, and this set of digits will be converted to a positive double-precision number by the program so that the first digit in the record is a whole number and the rest is a fraction (mantissa). \nIf you have added _{set of digits} then this number will be multiplied by the duration of the syllable to which this insertion refers, and the resulting number will be placed among the others in the place where this entry is inserted. \nIf you have added ={a set of digits} then this number will also be multiplied by the duration of the syllable to which this insertion refers, and the resulting number will be placed instead the duration that it was multiplied by. This allows to make syllables longer or shorter to follow language or creative intentions and rules (e. g. in French there have been noticed that the duration of the last syllable in the word, especially in the sentence or phrase is prolonged to some extent, so you can use '=12' or '=13' or '=14' here). Not as for the _{set of digits} group, you can place it only after the syllable and only once to change the duration of the syllable. If you use this option, the following _{set of digits} will be referred to the new changed duration here, so that \"так\"=2_05_1 will mean that you will use instead of the usual duration of the syllable \"так\" the twice as much duration, and then half of this twice as much (therefore, equal to duration of the syllable without altering) and then again the twice as much duration etc. The insertion of =1, =10, =100, =1000 etc will not change anything at all, except for the time of computations (you probably do not need this). \nThese two additional possibilities allows you to change rhythmic structures, and interpret this insert as a musical pause or, conversely, a musical phrase inserted to change the rhythm. What syllable does this insertion refer to? It refers to the previous syllable in the line. There can be several such inserts, their number is not limited by the program itself (in the program code), but a significant number of inserts can significantly increase the duration of the calculation. \n\nWhen the results of the program are displayed on the screen, these inserts will also be displayed in the appropriate places. \n\nIf you specify _1, _10, _100, _1000, etc. as such an insertion, the program will assume that this insertion duration is equal to the duration of the syllable to which it refers. If the set of digits is preceded by a 0, the insertion has a shorter duration, if the 1 in the first 4 examples above is followed by digits other than 0, or if another digit is used instead of 1 or 0, the insertion has a longer duration. For example, _05 means exactly half the duration of the syllable, and _2 means double the duration.\n\nFor the \"music\" mode the number of syllables printed for the line does include the inserts (since the version 0.15.2.0).\n"+ | xs == "cm" = putStrLn "-cm \t— If present, the program works in a special comparative mode reading information from the several files line-by-line and prompting to choose the resulting option from the files given. If some files do not have such lines, then the resulting option for the file is empty. You choose the resulting option by typing its number on the terminal. In the version 0.16.0.0 the total number of sources is limited to no more than 14. For more information, please refer to the link: https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#comparative-mode-of-operation-c " | otherwise = helpFE xs where helpFE xs = mapM helpPrint js >> return ()- js + js+ | xs == "-cm" = ["0","7","cm"] | xs == "+n" = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","n"] | xs == "+l" = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","l"] | xs == "+w" = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","w"] @@ -198,4 +206,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","n","l","w","s","d","p","f","dc","a","b","l2","q","ul","r","c","t","C","k","x","m","m2"]+ | otherwise = ["0","1","OR","2","OR","3","OR","4","OR","5","OR","6","OR","7","n","l","w","s","d","p","f","dc","a","b","l2","q","ul","r","c","t","C","k","x","m","m2","cm"]+
Phladiprelio/Ukrainian/IO.hs view
@@ -1,25 +1,24 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude, ScopedTypeVariables #-} module Phladiprelio.Ukrainian.IO where import GHC.Arr import GHC.Base import GHC.Num (Num(..),Integer,(+),(-),(*))-import GHC.Real (Integral(..),fromIntegral,(/),quot,rem,quotRem,round,(^))-import GHC.Enum (fromEnum,toEnum)+import GHC.Real (Integral(..),fromIntegral,(/),rem,quotRem,round,(^))+import GHC.Enum (fromEnum) import Text.Show (Show(..)) import Text.Read (readMaybe)-import Data.Char (isDigit, isAlpha,toLower,isSpace)-import System.IO (putStrLn, FilePath,stdout,hSetNewlineMode,universalNewlineMode,getLine,appendFile,print,writeFile)-import qualified Rhythmicity.MarkerSeqs as R hiding (id)+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.Foldable (Foldable)-import Data.Maybe (isNothing,fromJust) +import Data.Foldable (mapM_)+import Data.Maybe (isNothing,fromJust,fromMaybe) import Data.Tuple (fst,snd) import Phladiprelio.Ukrainian.Syllable import Phladiprelio.Ukrainian.SyllableDouble import Phladiprelio.Ukrainian.Melodics -import Control.Monad (sequence) import GHC.Int (Int8) import CaseBi.Arr (getBFst') import Phladiprelio.Ukrainian.ReadDurations@@ -34,6 +33,7 @@ import Phladiprelio.General.Datatype3 import Phladiprelio.General.Distance import Phladiprelio.UniquenessPeriodsG+import Control.Exception generalF :: Int -- ^ A power of 10. 10 in this power is then multiplied the value of distance if the next ['Double'] argument is not empty. The default one is 4. The right values are in the range [2..6].@@ -58,7 +58,7 @@ -> String -- ^ An initial string to be analysed. -> [String] -> IO [String]-generalF power10 ldc compards html dcfile selStr (prestr, poststr) lineNmb file numTest hc (grps,mxms) k descending hashStep emptyline splitting (fs,code) concurrently initstr universalSet@(u1:u2:us) = do+generalF power10 ldc compards html dcfile selStr (prestr, poststr) lineNmb file numTest hc (grps,mxms) k descending hashStep emptyline splitting (fs,code) concurrently initstr universalSet@(_:_:_) = do syllableDurationsDs <- readSyllableDurations file let syllN = countSyll initstr -- universalSet = map unwords . permutations . words $ rs@@ -72,7 +72,20 @@ (let h1 = if descending then (\(u,w) -> ((-1) * u, w)) else id in sortOn h1) . map (\xss -> (f ldc compards syllableDurationsDs grps mxms xss, xss)) $ universalSet strOutput = (:[]) . halfsplit1G (\(S _ y _) -> y) (if html then "<br>" else "") (jjj splitting) $ sRepresent in do- _ <- (if null dcfile then mapM putStrLn strOutput else do {mapM putStrLn strOutput >> doesFileExist dcfile >>= \exist -> if exist then do {getPermissions dcfile >>= \perms -> if writable perms then mapM (writeFile dcfile) strOutput else error $ "Phladiprelio.Ukrainian.IO.generalF: File " `mappend` dcfile `mappend` " is not writable!"} else do {getCurrentDirectory >>= \currdir -> do {getPermissions currdir >>= \perms -> if writable perms then mapM (writeFile dcfile) strOutput else error $ "Phladiprelio.Ukrainian.IO.generalF: Directory of the file " `mappend` dcfile `mappend` " is not writable!"}}})+ let lns1 = unlines strOutput+ putStrLn lns1+ if null dcfile then putStr "" + else do + exist <- doesFileExist dcfile + if exist then do + perms <- getPermissions dcfile + if writable perms then writeFile dcfile lns1 + else error $ "Phladiprelio.Ukrainian.IO.generalF: File " `mappend` dcfile `mappend` " is not writable!"+ else do + currdir <- getCurrentDirectory+ perms <- getPermissions currdir+ if writable perms then writeFile dcfile lns1 + else error $ "Phladiprelio.Ukrainian.IO.generalF: Directory of the file " `mappend` dcfile `mappend` " is not writable!" let l1 = length sRepresent if code == -1 then if lineNmb == -1 then return strOutput@@ -94,8 +107,12 @@ | r1 == 1 || r1 == 3 = 10*q1 + (if emptyline then 5 else r1) | r1 < 0 = -10*q1 + (if emptyline then -4 else r1) | otherwise = 10*q1 + (if emptyline then 4 else r1)-generalF _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [u1] = mapM putStrLn [u1] >> return [u1]-generalF _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ = let strOutput = ["You have specified the data and constraints on it that lead to no further possible options.", "Please, specify another data and constraints."] in mapM putStrLn strOutput >> return strOutput+generalF _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ [u1] = do+ putStrLn u1+ return [u1]+generalF _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ = let strOutput = ["You have specified the data and constraints on it that lead to no further possible options.", "Please, specify another data and constraints."] in do + putStrLn . unlines $ strOutput+ return strOutput data PhladiprelioUkr = S Int Integer String deriving Eq @@ -140,7 +157,7 @@ selectSounds :: String -> FlowSound selectSounds = f . sort . filter (/= 101) . concatMap g . words . map (\c -> if c == '.' then ' ' else toLower c) where g = getBFst' ([101::Sound8], listArray (0,41) (("1",[1,2,3,4,5,6,7,8,10,15,17,19,21,23,25,27,28,30,32,34,36,38,39,41,43,45,47,49,50,52,54,66]):("sr",[27,28,30,32,34,36]):("vd",[8,10,15,17,19,21,23,25]) :("vs",[45,47,49,50,43,52,38,66,54,39,41]) :("vw",[1..6]) :map (\(k,t) -> (k,[t])) [("\1072",1),("\1073",15),("\1074",36),("\1075",21),("\1076",17),("\1076\1078",23),("\1076\1079",8),("\1077",2),("\1078",10),("\1079",25),("\1080",5),("\1081",27),("\1082",45),("\1083",28),("\1084",30),("\1085",32),("\1086",3),("\1087",47),("\1088",34),("\1089",49),("\1089\1100",54),("\1090",50),("\1091",4),("\1092",43),("\1093",52),("\1094",38),("\1094\1100",66),("\1095",39),("\1096",41),("\1097",55),("\1100",7),("\1102",56),("\1103",57),("\1108",58),("\1110",6),("\1111",59),("\1169",19),("\8217",61)]))- f (x:ts@(y:xs)) + f (x:ts@(y:_)) | x == y = f ts | otherwise = x:f ts f xs = xs@@ -188,9 +205,9 @@ | otherwise = appendF outputS where mBool = null selStr && null compards appendF = appendFile fs- lineOption = head . filter (\(S k _ ts) -> k == num) $ sRepresent+ lineOption = head . filter (\(S k _ _) -> k == num) $ sRepresent textP = (\(S _ _ ts) -> ts) lineOption- sylls = createSyllablesUkrS textP+-- 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 (breaks, rs) = R.showZerosFor2PeriodMusic qqs
README.md view
@@ -124,6 +124,8 @@ The version 0.15.3.0 is also devoted to Sophie Kok, a sister of Emma Kok, who turned 18 on the 06/01/2024. Besides, on the 22/01/2024 there is Day of Unity of Ukraine and on the 23/01/2024 there is for Orthodox Church memory of St. Paulinus of Nola. +On the 08/03/2024 there is International Women's Day.+ All support is welcome, including donations for the needs of the Ukrainian army, IDPs and refugees. If you would like to share some financial support, please, contact the mentioned foundation
phladiprelio-ukrainian-simple.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: phladiprelio-ukrainian-simple-version: 0.15.3.0+version: 0.16.0.0 -- A short (one-line) description of the package. synopsis: A PhLADiPreLiO implementation for Ukrainian that uses hashes and asynchronous concurrency.@@ -28,7 +28,7 @@ -- LANGUAGE extensions used by modules in this package. other-extensions: NoImplicitPrelude, BangPatterns- build-depends: base >=4.13 && <5, rhythmic-sequences ==0.4.1.0, ukrainian-phonetics-basic-array ==0.7.0.0, phonetic-languages-ukrainian-array ==0.12.1.0, phladiprelio-ukrainian-shared ==0.1.0.0, cli-arguments ==0.7.0.0, phonetic-languages-permutations-array ==0.5.0.0, phonetic-languages-constraints-array ==0.8.0.0, phonetic-languages-simplified-base ==0.8.0.0, halfsplit ==0.4.2.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >= 2.2.2 && <3, phladiprelio-tests ==0.1.0.0, phladiprelio-general-datatype ==0.7.0.0, mmsyn2-array ==0.3.1.1, phonetic-languages-basis ==0.3.0.0, minmax ==0.1.1.0+ build-depends: base >=4.13 && <5, rhythmic-sequences ==0.4.1.0, ukrainian-phonetics-basic-array ==0.7.1.1, phonetic-languages-ukrainian-array ==0.12.2.0, phladiprelio-ukrainian-shared ==0.1.1.0, cli-arguments ==0.7.0.0, phonetic-languages-permutations-array ==0.5.0.0, phonetic-languages-constraints-array ==0.8.0.0, phonetic-languages-simplified-base ==0.9.0.0, halfsplit ==0.4.2.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >= 2.2.2 && <3, phladiprelio-tests ==0.1.0.0, phladiprelio-general-datatype ==0.7.0.0, mmsyn2-array ==0.3.1.1, phonetic-languages-basis ==0.3.0.0, minmax ==0.1.1.0 hs-source-dirs: . default-language: Haskell2010 @@ -40,7 +40,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.4.1.0, ukrainian-phonetics-basic-array ==0.7.0.0, phonetic-languages-ukrainian-array ==0.12.1.0, phladiprelio-ukrainian-shared ==0.1.0.0, cli-arguments ==0.7.0.0, phonetic-languages-permutations-array ==0.5.0.0, phonetic-languages-constraints-array ==0.8.0.0, phonetic-languages-simplified-base ==0.8.0.0, halfsplit ==0.4.2.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >= 2.2.2 && <3, phladiprelio-tests ==0.1.0.0, phladiprelio-general-datatype ==0.7.0.0, mmsyn2-array ==0.3.1.1, phonetic-languages-basis ==0.3.0.0, minmax ==0.1.1.0+ build-depends: base >=4.13 && <5, rhythmic-sequences ==0.4.1.0, ukrainian-phonetics-basic-array ==0.7.1.1, phonetic-languages-ukrainian-array ==0.12.2.0, phladiprelio-ukrainian-shared ==0.1.1.0, cli-arguments ==0.7.0.0, phonetic-languages-permutations-array ==0.5.0.0, phonetic-languages-constraints-array ==0.8.0.0, phonetic-languages-simplified-base ==0.9.0.0, halfsplit ==0.4.2.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >= 2.2.2 && <3, phladiprelio-tests ==0.1.0.0, phladiprelio-general-datatype ==0.7.0.0, mmsyn2-array ==0.3.1.1, phonetic-languages-basis ==0.3.0.0, minmax ==0.1.1.0 hs-source-dirs: . default-language: Haskell2010