packages feed

phladiprelio-ukrainian-simple 0.2.0.0 → 0.3.0.0

raw patch · 4 files changed

+46/−16 lines, 4 files

Files

CHANGELOG.md view
@@ -26,3 +26,9 @@ * Second version. Added help message (phladiprelioUkr -h). Changed the +h argument group to +c   argument group. Updated the dependency boundaries. +## 0.3.0.0 -- 2023-03-19++* Third version. Added new possibilities for reverse order and a new test for 'smoothness'+of the line. The latter one works for most cases because of the highly not equal pairwise +values for the syllable durations.+
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.2.0.0) not the full functionality. The previous implementation +has at the moment (as of the version 0.3.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,6 +14,10 @@  [New implementation](https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioEng.pdf) +Example of the new functionality in the version 0.3.0.0 is in the video:++https://www.facebook.com/Oleksandr.S.Zhabenko/posts/pfbid0QT1BCWf9fmgQHasfUrSSqCenR9YT1C6CtL8PV4ieGrCTWGwatRh6TTUcxho8irkHl+ Video recordings as examples of the working prototype usage and how you can listen to  Ukrainian text using Google services are at the links below: @@ -32,6 +36,7 @@ At the day of publication of the first version of the package (12/03/2023) there is the foundation founder's (this is [Emma Kok](https://www.emmakok.nl)) Birthday. And on the 17/03/2023 there is the author's Birthday.+And on the 19/03/2023 is the St. Joseph the Betrothed feast for Roman Catholics. If you would like to share some financial support, please, contact the foundation using the URL: 
app/Main.hs view
@@ -1,61 +1,80 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -threaded #-}  module Main where  import GHC.Base-import GHC.Num ((-))+import GHC.Num ((+),(-),(*))+import GHC.Real (fromIntegral,(/))+import GHC.Enum (fromEnum) import Text.Show (show) import Text.Read (readMaybe) import System.IO (putStrLn, FilePath) import Rhythmicity.MarkerSeqs hiding (id)  import Rhythmicity.BasicF -import Data.List+import Data.List hiding (foldr) import Data.Maybe (fromMaybe)  import Data.Tuple (fst,snd) import Phladiprelio.Ukrainian.PrepareText  import Phladiprelio.Ukrainian.Syllable -import Phladiprelio.Ukrainian.SyllableDouble +import Phladiprelio.Ukrainian.SyllableDouble+import Phladiprelio.Ukrainian.Melodics  import System.Environment (getArgs) import GHC.Int (Int8) import CLI.Arguments import CLI.Arguments.Get import CLI.Arguments.Parsing import Phladiprelio.Ukrainian.ReadDurations+import Data.Ord (comparing) -generalF :: FilePath -> HashCorrections -> (Int8,[Int8]) -> Int -> String -> IO [()]-generalF file hc (grps,mxms) k rs = do+generalF :: FilePath -> Int -> HashCorrections -> (Int8,[Int8]) -> Int -> Bool -> String -> IO [()]+generalF file numTest hc (grps,mxms) k descending rs = do    syllableDurationsDs <- readSyllableDurations file-   mapM (\(x,y) -> putStrLn (show x `mappend` (' ':y)))  . sortOn id . map ((\xss -> (f syllableDurationsDs xss, xss)) . unwords) . permutations . words $ rs-     where f syllableDurationsDs = sum . countHashesG hc grps mxms . mconcat . +   let syllN = countSyll rs+       universalSet = map unwords . permutations . words $ rs+       f syllableDurationsDs grps mxms = sum . countHashesG 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 == 0 then do+     putStrLn "Feet   Val  Stat   Proxim" +     sequence . map putStrLn . map (\(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 (show (fromEnum q) `mappend` "   |   " `mappend`  show mx `mappend` "     " `mappend` show m `mappend` "  -> " `mappend` show (100 * fromIntegral mx / fromIntegral m) `mappend` "%")) $ [(2,[1]),(3,[2,1]),(4,[3,2]),(5,[4,3,2]),(6,[5,4,3]),(7,[6,5,4,3,2])]+   else mapM (\(x,y) -> putStrLn (show x `mappend` (' ':y)))  . sortOn (\(u,w) -> if descending then ((-1) * u, w) else (u,w)) . map (\xss -> (f syllableDurationsDs grps mxms xss, xss)) $ universalSet +countSyll :: String -> Int+countSyll xs = fromEnum . foldr (\x y -> if isVowel1 x then y + 1 else y) 0 . convertToProperUkrainianI8 $ xs++stat1 :: Int -> (Int8,[Int8]) -> Int+stat1 n (k, ks) = fst (n `quotRemInt` fromEnum k) * length ks+ main :: IO () main = do   args <- getArgs-  let (argsB, arg2s) = takeBsR bSpecs args-      (argsA, _) = takeAsR aSpecs args+  let (argsA, argsB, _, arg2s) = args2Args3R (aSpecs `mappend` bSpecs) args+  --    (argsA, _) = takeAsR aSpecs 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       grpp = grouppingR . concat . getB "+r" $ argsB+      numTest = fromMaybe 1 (readMaybe (concat . getB "-t" $ argsB)::Maybe Int)       helpMessage = oneA "-h" argsA+      descending = oneA "+n" argsA       str1 = unwords . take 7 . words . mconcat . prepareText . unwords $ arg2s   if helpMessage then do       putStrLn "Synopsis:"-      putStrLn "phladiprelioUkr [+c <HashCorrections encoded>] [+d <FilePath to file with durations>] [+r <groupping info>] [+s <syllable durations function number>] <Ukrainian textual line>"+      putStrLn "phladiprelioUkr [+c <HashCorrections encoded>] [+n] [+d <FilePath to file with durations>] [+r <groupping info>] [+s <syllable durations function number>] <Ukrainian textual line>"       putStrLn ""-      putStrLn "+s — 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 "+n — if specified then the order of sorting and printing is descending (the reverse one to the default otherwise). "+      putStrLn "+s — 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 "+d — 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 "+r — 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 "+c — see explanation at the link: https://hackage.haskell.org/package/rhythmic-sequences-0.2.3.1/docs/src/Rhythmicity.MarkerSeqs.html#HashCorrections"-  else generalF fileDu hc grpp sylD str1 >> return ()+  else generalF fileDu numTest hc grpp sylD descending str1 >> return ()  bSpecs :: CLSpecifications-bSpecs = zip ["+c","+d","+r","+s"] . cycle $ [1]+bSpecs = zip ["+c","+d","+r","+s","-t"] . cycle $ [1]  aSpecs :: CLSpecifications-aSpecs = [("-h",0)]+aSpecs = [("-h",0),("+n",0)]  cSpecs :: CLSpecifications cSpecs = []
phladiprelio-ukrainian-simple.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               phladiprelio-ukrainian-simple-version:            0.2.0.0+version:            0.3.0.0  -- A short (one-line) description of the package. synopsis:           A PhLADiPreLiO implementation for Ukrainian that uses hashes