{-# LANGUAGE NoImplicitPrelude, BangPatterns #-} module Main where import GHC.Base import Text.Read (readMaybe) import System.IO (putStrLn) import Rhythmicity.MarkerSeqs hiding (id) import Data.List hiding (foldr) import Data.Maybe (fromMaybe,catMaybes) import Data.Tuple (snd) import Phladiprelio.Ukrainian.PrepareText import System.Environment (getArgs) import GHC.Int (Int8) import CLI.Arguments import CLI.Arguments.Get import CLI.Arguments.Parsing import Phladiprelio.ConstraintsEncoded import Phladiprelio.PermutationsArr import Phladiprelio.StrictVG import Phladiprelio.Ukrainian.IO 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 hc = readHashCorrections . concat . getB "+c" $ argsB prepare = oneA "-p" argsA grpp = 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 = oneA "-h" argsA argCs = catMaybes (fmap (readMaybeECG l) -- . (showB l lstW2:) . getC "+a" $ argsC) filedata = getB "+f" argsB (filesave,codesave) | null filedata = ("",-1) | length filedata == 2 = (head filedata, fromMaybe 0 (readMaybe (last filedata)::Maybe Int)) | otherwise = (head filedata,0) ll = take 7 . (if prepare then id else words . mconcat . prepareText . unwords) $ arg2s l = length ll !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 putStrLn "SYNOPSIS:" putStrLn "" putStrLn "phladiprelioUkr [+a -a] [+b -b] [+c ] [+n] [+l] [+d ] [+k ] [+r ] [-t ] [+s ] [-p] [+w ] [+f ] " putStrLn "" putStrLn "+n \t— if specified then the order of sorting and printing is descending (the reverse one to the default otherwise). " putStrLn "" 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. " putStrLn "" 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 splitten 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 50 that corresponds to some reasonable layout." putStrLn "" putStrLn "+s \t— the next is the digit from 1 to 4 included. The default one is 2. Influences the result in the case of +d parameter is not given. " putStrLn "" putStrLn "+d \t— see: https://web.archive.org/web/20220610171812/https://raw.githubusercontent.com/OleksandrZhabenko/phonetic-languages-data/main/0.20.0.0/56.csv as a format for the file. The explanation for how to create such a file by yourself is given at: https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioEng.7.pdf#page=12 and the 2 next pages in the pdf file." putStrLn "" putStrLn "-p \t— if present the minimal grammar transformations (appending and prepending the dependent parts) are not applied. Can be useful also if the text is analyzed as a Ukrainian transcription of text in some other language." putStrLn "" putStrLn "+f \t— if present with two arguments specifies the file to which the output information should be appended and the mode of appending (which parts to write). The default value if the secodnd parameter is 0 or not element of [1..4] is just the resulting String option. If the second parameter is 1 then the sequential number and the text are written; if it is 2 then the estimation value and the string are written; if it is 3 then the full information is written i. e. number, string and estimation; if it is 4 then the number and estimation (no string). " putStrLn "" putStrLn "+a ... -a \t— if present contains a group of constraints for PhLADiPreLiO. For more information, see: " 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 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.7.pdf in English or: " putStrLn "https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioUkr.7.pdf in Ukrainian." putStrLn "" putStrLn "+r \t— afterwards are several unique digits not greater than 8 in the descending order — the first one is the length of the group of syllables to be considered as a period, the rest — positions of the maximums and minimums. Example: \"543\" means that the line is splitted into groups of 5 syllables starting from the beginning, then the positions of the most maximum (4 = 5 - 1) and the next (smaller) maximum (3 = 4 - 1). If there are no duplicated values then the lowest possible value here is 0, that corresponds to the lowest minimum. If there are duplicates then the lowest value here is the number of the groups of duplicates, e. g. in the sequence 1,6,3,3,4,4,5 that is one group there are two groups of duplicates — with 3 and 4 — and, therefore, the corresponding data after +r should be 7...2. The values less than the lowest minimum are neglected." 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 Some preliminary tests show that theee corrections influence the result but not drastically, they can lead to changes in groupping and order, but mostly leave the structure similar. This shows that the algorithms used are more stable for such changes." putStrLn "" putStrLn "-t \t— and afterwards the number in the range [0..179] (with some exceptions) showing the test for \'smoothness\' (to be more accurate - absence or presence 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 "" else generalF fileDu numTest hc grpp sylD descending hashStep emptyline splitting (filesave, codesave) variants1 >> return () bSpecs :: CLSpecifications bSpecs = (zip ["+c","+d","+k","+r","+s","-t","+w"] . cycle $ [1]) `mappend` [("+f",2)] aSpecs :: CLSpecifications aSpecs = zip ["-h", "+l", "+n","-p"] . cycle $ [0] cSpecs :: CLSpecifications cSpecs = [("+a",-1)]