phladiprelio-ukrainian-simple 0.12.1.0 → 0.13.0.0
raw patch · 5 files changed
+54/−21 lines, 5 filesdep ~phladiprelio-general-datatypePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: phladiprelio-general-datatype
API changes (from Hackage documentation)
- Phladiprelio.Ukrainian.IO: generalF :: Bool -> FilePath -> String -> (String, String) -> Int -> FilePath -> Int -> HashCorrections -> (Int8, [Int8]) -> Int -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> Bool -> String -> [String] -> IO [String]
+ Phladiprelio.Ukrainian.IO: generalF :: Int -> [Double] -> Bool -> FilePath -> String -> (String, String) -> Int -> FilePath -> Int -> HashCorrections -> (Int8, [Int8]) -> Int -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> Bool -> String -> [String] -> IO [String]
Files
- CHANGELOG.md +5/−0
- Main.hs +25/−6
- Phladiprelio/Ukrainian/IO.hs +15/−12
- README.md +6/−0
- phladiprelio-ukrainian-simple.cabal +3/−3
CHANGELOG.md view
@@ -169,3 +169,8 @@ allow to specify whether to add <br> html tag to each line in the two-column output and to what file print additionally two-column output. +## 0.13.0.0 -- 2023-11-11++* Thirteenth version. Added a new functionality related to the comparison of similarity of two+ lists. Use for this +l2 ... -l2 group of command line options. +
Main.hs view
@@ -5,9 +5,9 @@ module Main where import GHC.Base-import GHC.Num (abs,(+),(-))+import GHC.Num (abs,(+),(-),(*)) import Text.Read (readMaybe)-import System.IO (putStrLn,readFile,print)+import System.IO (putStrLn,readFile) import Rhythmicity.MarkerSeqs hiding (id) import Data.List hiding (foldr) import Data.Maybe (fromMaybe,catMaybes) @@ -22,6 +22,11 @@ import Phladiprelio.PermutationsArr import Phladiprelio.StrictVG import Phladiprelio.Ukrainian.IO+import Phladiprelio.General.Datatype (readBasic3)+import GHC.Real ((/),quot,gcd)+import Phladiprelio.Ukrainian.Syllable +import Phladiprelio.Ukrainian.SyllableDouble+import Phladiprelio.Ukrainian.ReadDurations main :: IO () main = do@@ -30,6 +35,10 @@ (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 line2comparewith = unwords . getC "+l2" $ argsC+ basecomp = readBasic3 ((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) (mconcat) line2comparewith 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 = readHashCorrections . concat . getB "+c" $ argsB dcspecs = getB "+dc" argsB@@ -71,7 +80,15 @@ | otherwise = lns !! (ln1 - 1) return $ (words lineF, line_1F,line1F) else return (arg2s, [], [])- let + let example = readBasic3 ((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) (mconcat) (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))@@ -89,7 +106,7 @@ if helpMessage then do putStrLn "SYNOPSIS:" putStrLn ""- putStrLn "phladiprelioUkr [+a <PhLADiPreLiO constraints> -a] [+b <extended algebraic PhLADiPreLiO constraints> -b] [+c <HashCorrections encoded>] [+n] [+l] [+d <FilePath to file with durations>] [+k <number - hash step>] [+ul <diversity property encoding string>] [+r <groupping info>] [-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>] [+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>"+ putStrLn "phladiprelioUkr [+a <PhLADiPreLiO constraints> -a] [+b <extended algebraic PhLADiPreLiO constraints> -b] [+c <HashCorrections encoded>] [+n] [+l] [+d <FilePath to file with durations>] [+k <number - hash step>] [+ul <diversity property encoding string>] [+r <groupping info>] [-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>] [+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>" putStrLn "" putStrLn "+n \t— if specified then the order of sorting and printing is descending (the reverse one to the default otherwise). " putStrLn ""@@ -117,6 +134,8 @@ 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 "+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 presedence over +t, +r, +k, +c etc. groups of command line options so that these latter ones have no effect when +l2 ... -l2 is present."+ putStrLn "" putStrLn "+ul \t— afterwards there is a string that encodes which sounds are used for diversity property evaluation. If used, then +r group has no meaning and is not used. Unlike in the link, the argument \"1\" means computing the property for all the sound representations included (for all of the present representations, so the value is maximal between all other strings instead of \"1\"). For more information, see: https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#types" 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."@@ -143,7 +162,7 @@ putStrLn "" putStrLn "For the \"music\" mode the number of syllables printed for the line does not include the inserts. So the property value can be greater than this number." putStrLn ""- else generalF html dcfile selStr (prestr, poststr) lineNmb fileDu numTest hc grpp sylD descending hashStep emptyline splitting (filesave, codesave) concurrently (unwords arg3s) variants1 >> return ()+ else generalF 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@@ -153,5 +172,5 @@ aSpecs = zip ["-h", "+l", "+n","-p", "-C"] . cycle $ [0] cSpecs :: CLSpecifications-cSpecs = [("+a",-1)]+cSpecs = [("+a",-1),("+l2",-1)]
Phladiprelio/Ukrainian/IO.hs view
@@ -5,7 +5,7 @@ import GHC.Arr import GHC.Base import GHC.Num (Integer,(+),(-),(*))-import GHC.Real (fromIntegral,(/),quot,rem,quotRem)+import GHC.Real (fromIntegral,(/),quot,rem,quotRem,round) import GHC.Enum (fromEnum,toEnum) import Text.Show (Show(..)) import Text.Read (readMaybe)@@ -29,10 +29,13 @@ import Control.Concurrent.Async (mapConcurrently) import Phladiprelio.Tests import Phladiprelio.General.Datatype (readBasic3, readBasic4, readBasic1G)+import Phladiprelio.General.Distance import Phladiprelio.UniquenessPeriodsG generalF- :: Bool -- ^ If 'True' then adds \"<br>\" to line endings for double column output+ :: Int -- ^ A 'length' of the next argument here.+ -> [Double] -- ^ A list of non-negative values normed by 1.0 (the greatest of which is 1.0) that the line options are compared with. If null, then the program works as for version 0.12.1.0 without this newly-introduced argument since the version 0.13.0.0. The length of it must be a least common multiplier of the (number of syllables plus number of \'_digits\' groups) to work correctly. Is not used when the next 'FilePath' and 'String' arguments are not null.+ -> Bool -- ^ If 'True' then adds \"<br>\" to line endings for double column output -> FilePath -- ^ A path to the file to save double columns output to. If empty then just prints to 'stdout'. -> String -- ^ If not null than instead of rhythmicity evaluation using hashes and and feets, there is computed a diversity property for the specified 'String' here using the 'selectSounds' function. For more information, see: 'https://oleksandr-zhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#types' -> (String, String) -- ^ If the next element is not equal to -1, then the prepending and appending lines to be displayed. Used basically for working with the multiline textual input data.@@ -51,29 +54,29 @@ -> String -- ^ An initial string to be analysed. -> [String] -> IO [String]-generalF 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 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 syllableDurationsDs <- readSyllableDurations file let syllN = countSyll initstr -- universalSet = map unwords . permutations . words $ rs- f syllableDurationsDs grps mxms -- Since the version 0.12.0.0, has a possibility to evaluate diversity property.- | null selStr = sum . countHashes2G hashStep hc grps mxms . readBasic3 ((if null file then case k of { 1 -> syllableDurationsD; 2 -> syllableDurationsD2; 3 -> syllableDurationsD3; 4 -> syllableDurationsD4} + f ldc compards syllableDurationsDs grps mxms -- Since the version 0.12.0.0, has a possibility to evaluate diversity property.+ | null selStr = (if null compards then (sum . countHashes2G hashStep hc grps mxms) else (round . (*10000) . distanceSqrG2 ldc compards)) . readBasic3 ((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) (mconcat) | otherwise = fromIntegral . diverse2GGL (selectSounds selStr) [100,101] . convertToProperUkrainianI8 . filter (\c -> not (isDigit c) && c /= '_') hSetNewlineMode stdout universalNewlineMode- if numTest >= 0 && numTest <= 179 && numTest /= 1 then do+ if numTest >= 0 && numTest <= 179 && numTest /= 1 && null compards then do putStrLn "Feet Val Stat Proxim" (if concurrently then mapConcurrently else mapM) (\(q,qs) -> let m = stat1 syllN (q,qs)- (min1, max1) = minMax11ByCList (comparing (f syllableDurationsDs q qs)) universalSet - mx = f syllableDurationsDs q qs max1 + (min1, max1) = minMax11ByCList (comparing (f ldc [] syllableDurationsDs q qs)) universalSet + mx = f ldc [] syllableDurationsDs q qs max1 strTest = (show (fromEnum q) `mappend` " | " `mappend` show mx `mappend` " " `mappend` show m `mappend` " -> " `mappend` showFFloat (Just 3) (100 * fromIntegral mx / fromIntegral m) "%" `mappend` (if rem numTest 10 >= 4 then ("\n" `mappend` min1 `mappend` "\n" `mappend` max1 `mappend` "\n") else "")) in putStrLn strTest >> return strTest) . zip (sel2 numTest) $ (sel numTest) else let sRepresent = zipWith (\k (x, ys) -> S k x ys) [1..] . - (let h1 = if descending then (\(u,w) -> ((-1) * u, w)) else id in sortOn h1) . map (\xss -> (f syllableDurationsDs grps mxms xss, xss)) $ universalSet+ (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!"}}})@@ -90,7 +93,7 @@ let writ = writable permiss readab = readable permiss if writ && readab then do- if null selStr then do+ if null selStr && null compards then do let lineOption = head . filter (\(S k _ ts) -> k == num) $ sRepresent textP = (\(S _ _ ts) -> ts) lineOption sylls = createSyllablesUkrS textP@@ -115,8 +118,8 @@ | 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] = 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 data PhladiprelioUkr = S Int Integer String deriving Eq
README.md view
@@ -55,6 +55,10 @@ See the demonstration video for the new functionality in version 0.12.0.0 and 0.12.0.1 by the link: [https://www.youtube.com/watch?v=zapAPpQ-fc4](https://www.youtube.com/watch?v=zapAPpQ-fc4) +Since the version 0.13.0.0 there is a possibility to compare the distances (opposite to the+similarity measure) for the line options using the +l2 ... -l2 command line group of options. It is+generally a completely new functionality for the package.+ To see the help message with synopsis information, run: phladiprelioUkr -h@@ -102,6 +106,8 @@ In Ukraine this day has several important celebrations — Intercession of the Holy Theotokos (Pokrova), Cossacks' Day, Day of Defenders of Ukraine (especially relevant during the Russian war against Ukraine). On the 27/10/2023 there is Ukrainian Language and Writing Day.++On the 11/11/2023 there is St. Martin of Tours Day for Roman Catholics and Poland Independence Day. All support is welcome, including donations for the needs of the Ukrainian army, IDPs and refugees.
phladiprelio-ukrainian-simple.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: phladiprelio-ukrainian-simple-version: 0.12.1.0+version: 0.13.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.11.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.3.0, phonetic-languages-simplified-base ==0.7.1.0, halfsplit ==0.4.1.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.3.1.0, mmsyn2-array ==0.3.1.1, phonetic-languages-basis ==0.3.0.0+ 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.11.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.3.0, phonetic-languages-simplified-base ==0.7.1.0, halfsplit ==0.4.1.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.4.1.0, mmsyn2-array ==0.3.1.1, phonetic-languages-basis ==0.3.0.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.11.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.3.0, phonetic-languages-simplified-base ==0.7.1.0, halfsplit ==0.4.1.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.3.1.0, mmsyn2-array ==0.3.1.1, phonetic-languages-basis ==0.3.0.0+ 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.11.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.3.0, phonetic-languages-simplified-base ==0.7.1.0, halfsplit ==0.4.1.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.4.1.0, mmsyn2-array ==0.3.1.1, phonetic-languages-basis ==0.3.0.0 hs-source-dirs: . default-language: Haskell2010