packages feed

phladiprelio-ukrainian-simple 0.6.0.0 → 0.7.0.0

raw patch · 5 files changed

+121/−27 lines, 5 filesdep +directorydep +halfsplitdep ~phonetic-languages-constraints-array

Dependencies added: directory, halfsplit

Dependency ranges changed: phonetic-languages-constraints-array

Files

CHANGELOG.md view
@@ -104,3 +104,12 @@ documentation of the help menu and general documentation. Updated the dependecy boundaries for the new version of phonetic-languages-constraints-array to fix functionality. +## 0.7.0.0 -- 2023-06-15++* Seventh version. Fixed some issues with tests output for all platforms and issues with output for+  Windows users for non-tests functionality. Added new constraint of U. Updated the documentation.+Added two new command line options - +w and +f which allows to specify the output mode for +printing in the terminal window and printing the result to the file. Added new dependencies. +Switched to the two-column ouput as a usual one for non-tests functionality. For more information,+see phladiprelioUkr -h and / or README.md.+
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2023 Oleksandr Zhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.6.0.0) not the full functionality. The previous implementation +has at the moment (as of the version 0.7.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@@ -10,10 +10,17 @@ [English documentation](https://oleksandrzhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.pdf)  The documentation for  the  new implementation is available at the following links.-[Новий текст теорії](https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioUkr.5.2.pdf)+[Новий текст теорії](https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioUkr.7.pdf) -[New implementation](https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioEng.5.2.pdf)+[New implementation](https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioEng.7.pdf) +Since the version 0.7.0.0 the default mode for non-tests output is in two-column. This improves +the UI / UX for the end user. Besides there is the possibility to write the result to a file.++The video with the demonstration of the new functionality in the version 0.7.0.0 is by the link:++https://www.facebook.com/100012184148486/posts/1767318773684244+ 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@@ -55,7 +62,11 @@  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+On the 09/06/2023 there was unofficial World Friendship Day. ++On the 15/06/2023 there is the final bachelor's exam for Enzo Kok in violin playing in Amsterdam. ++If you would like to share some financial support, please, contact the mentioned foundation using the URL:  [Contact Foundation GASTROSTARS](https://gastrostars.nl/hou-mij-op-de-hoogte)
app/Main.hs view
@@ -3,16 +3,17 @@ module Main where  import GHC.Base-import GHC.Num ((+),(-),(*))-import GHC.Real (fromIntegral,(/),quot,rem)+import GHC.Num (Integer,(+),(-),(*))+import GHC.Real (fromIntegral,(/),quot,rem,quotRem) import GHC.Enum (fromEnum,toEnum)-import Text.Show (show)+import Text.Show (Show(..)) import Text.Read (readMaybe)-import System.IO (putStrLn, FilePath,stdout,hSetNewlineMode,universalNewlineMode)+import Data.Char (isDigit)+import System.IO (putStrLn, FilePath,stdout,hSetNewlineMode,universalNewlineMode,getLine,appendFile) import Rhythmicity.MarkerSeqs hiding (id)  import Rhythmicity.BasicF  import Data.List hiding (foldr)-import Data.Maybe (fromMaybe,catMaybes) +import Data.Maybe (fromMaybe,catMaybes,isNothing,fromJust)  import Data.Tuple (fst,snd) import Phladiprelio.Ukrainian.PrepareText  import Phladiprelio.Ukrainian.Syllable @@ -30,29 +31,42 @@ import Phladiprelio.PermutationsArr import Phladiprelio.StrictVG import Numeric (showFFloat)+import Phladiprelio.Halfsplit+import System.Directory (doesFileExist,readable,writable,getPermissions,Permissions(..)) -generalF :: FilePath -> Int -> HashCorrections -> (Int8,[Int8]) -> Int -> Bool -> Int -> Bool -> [String] -> IO [()]-generalF file numTest hc (grps,mxms) k descending hashStep emptyline universalSet@(u1:u2:us) = do+generalF :: FilePath -> Int -> HashCorrections -> (Int8,[Int8]) -> Int -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> [String] -> IO [String]+generalF file numTest hc (grps,mxms) k descending hashStep emptyline splitting (fs,code) 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+   hSetNewlineMode stdout universalNewlineMode    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)                           (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 +                          mx = f 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 ""))) . 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+                                                                                                             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+            strOutput = (:[]) . halfsplit (\(S _ y _) -> y) (jjj splitting) $ sRepresent+                        in do+                             _ <- mapM putStrLn strOutput+                             let l1 = length sRepresent+                             if code == -1 +                                 then return strOutput+                                 else parseLineNumber l1 >>= \num -> do+                                         permiss <- getPermissions fs+                                         let writ = writable permiss+                                             readab = readable permiss+                                         if writ && readab then appendFile fs (flip outputSel code . head . filter (\(S k _ _) -> k == num) $ sRepresent)+                                         else error "The specified file cannot be used for appending the text! Please, specify another file!"+                                         return []      where sel x                | 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.@@ -131,9 +145,20 @@                         | 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."]+           jjj kk = let (q1,r1) = quotRem kk (if kk < 0 then -10 else 10) in jjj' q1 r1 emptyline+           jjj' q1 r1 emptyline+             | r1 == (-1) || r1 == (-3) = -10*q1 + (if emptyline then -5 else r1)+             | 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 +data PhladiprelioUkr = S Int Integer String deriving Eq++instance Show PhladiprelioUkr where+  show (S i j xs) = show j `mappend` " " `mappend` xs `mappend` "  " `mappend` show i+ countSyll :: String -> Int countSyll xs = fromEnum . foldr (\x y -> if isVowel1 x then y + 1 else y) 0 . convertToProperUkrainianI8 $ xs @@ -148,7 +173,25 @@              (uss,wss) = break (== "+b") yss              [qss,rss] = map (drop 1) [tss, wss]              +outputSel :: PhladiprelioUkr -> Int -> String+outputSel (S x1 y1 ts) code+  | code < 0 = []+  | code == 0 = ts `mappend` "\n"+  | code == 1 = intercalate " " [show x1, ts] `mappend` "\n"+  | code == 2 = intercalate " " [show y1, ts] `mappend` "\n"+  | code == 3 = intercalate " " [show x1, ts, show y1] `mappend` "\n"+  | code == 4 = intercalate " " [show x1, show y1] `mappend` "\n"+  | otherwise = ts `mappend` "\n" +parseLineNumber :: Int -> IO Int+parseLineNumber l1 = do +  putStrLn "Please, specify the number of the option to be written to the file specified: "+  number <- getLine+  let num = readMaybe (filter isDigit number)::Maybe Int+  if isNothing num || num > Just l1 || num == Just 0 +      then parseLineNumber l1 +      else return . fromJust $ num+ main :: IO () main = do   args0 <- getArgs@@ -159,12 +202,18 @@       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 @@ -176,18 +225,22 @@   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>] [+r <groupping info>] [-t <number of the test or its absense if 1 is here>] [+s <syllable durations function number>] [-p] <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>] [+r <groupping info>] [-t <number of the test or its absense if 1 is here>] [+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>] <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 ""       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."       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 infomation 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"@@ -208,10 +261,10 @@       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 variants1 >> return ()+  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"] . cycle $ [1]+bSpecs = (zip ["+c","+d","+k","+r","+s","-t","+w"] . cycle $ [1]) `mappend` [("+f",2)]   aSpecs :: CLSpecifications aSpecs = zip ["-h", "+l", "+n","-p"] . cycle $ [0]
phladiprelio-ukrainian-simple.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               phladiprelio-ukrainian-simple-version:            0.6.0.0+version:            0.7.0.0  -- A short (one-line) description of the package. synopsis:           A PhLADiPreLiO implementation for Ukrainian that uses hashes@@ -13,6 +13,7 @@  -- The license under which the package is released. license:            MIT+license-file:       LICENSE author:             Oleksandr Zhabenko maintainer:         oleksandr.zhabenko@yahoo.com @@ -29,7 +30,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.2.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.3.0, phonetic-languages-simplified-base ==0.7.0.0, halfsplit ==0.1.0.0, directory >=1.3.4.0 && <2     hs-source-dirs:   app     default-language: Haskell2010