packages feed

phonetic-languages-simplified-generalized-examples-array 0.11.3.0 → 0.12.0.0

raw patch · 5 files changed

+86/−54 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Phonetic.Languages.General.Lines: compareFilesToOneCommon :: FilePath -> FilePath -> FilePath -> IO ()
+ Phonetic.Languages.General.Lines: compareFilesToOneCommon :: [FilePath] -> FilePath -> IO ()
- Phonetic.Languages.General.Lines: generalProcessment :: (Int, Int) -> GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> (Double -> String -> [[[PRS]]] -> [[Double]]) -> [[[[PRS]]] -> [[Double]]] -> Concatenations -> String -> String -> String -> Coeffs2 -> [String] -> String -> Int -> FilePath -> IO ()
+ Phonetic.Languages.General.Lines: generalProcessment :: (Int, Int) -> GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> (Double -> String -> [[[PRS]]] -> [[Double]]) -> [[[[PRS]]] -> [[Double]]] -> Concatenations -> String -> String -> String -> Coeffs2 -> [String] -> [String] -> Int -> FilePath -> IO ()
- Phonetic.Languages.General.Lines.Parsing: files4Processment :: FilePath -> FilePath -> FilePath -> FilePath -> [String] -> IO (GWritingSystemPRPLX, [(Char, Char)], CharPhoneticClassification, SegmentRulesG, String, String, Concatenations, String, [String], String, Int, FilePath)
+ Phonetic.Languages.General.Lines.Parsing: files4Processment :: FilePath -> FilePath -> FilePath -> FilePath -> Int -> [String] -> IO (GWritingSystemPRPLX, [(Char, Char)], CharPhoneticClassification, SegmentRulesG, String, String, Concatenations, String, [String], [String], Int, FilePath)

Files

ChangeLog.md view
@@ -137,3 +137,8 @@ * The eleventh version revised D. Updated the README.md file with the hyperlinks to the updated documentation related to the usage of the related package phonetic-languages-simplified-examples-array. +## 0.12.0.0 -- 2021-09-14++* The twelth version. Added multiple properties mode to the Phonetic.Languages.General.Lines module and related+module and extended the comparative mode for it up to 7 different input source files. Some documentation improvements.+
Phonetic/Languages/General/Lines.hs view
@@ -38,12 +38,17 @@ import Phonetic.Languages.Simplified.Array.General.FuncRep2RelatedG2 import Data.Monoid (mappend) import Phonetic.Languages.General.Common+import Interpreter.StringConversion +{-| @ since 0.12.0.0 -- Changed the arguments. Now it can run multiple rewritings for the one given data file+on the given list of choices for the properties given as the second ['String'] argument. Every new file is being+saved with the choice prefix.+-} generalProcessment  :: (Int,Int) -- ^ Argument to specify possible 'line growing'.  -> GWritingSystemPRPLX -- ^ Data used to obtain the phonetic language representation of the text.  -> [(Char,Char)] -- ^ The pairs of the 'Char' that corresponds to the similar phonetic languages consonant phenomenon-  -- (e. g. allophones). Must be sorted in the ascending order to be used correctly. +  -- (e. g. allophones). Must be sorted in the ascending order to be used correctly.  -> CharPhoneticClassification -- ^ The 'Array' 'Int' 'PRS' must be sorted in the ascending order to be used in the module correctly.  -> SegmentRulesG  -> (Double -> String -> ([[[PRS]]] -> [[Double]]))-- ^ The function that is needed in the 'procRhythmicity23F' function.@@ -60,56 +65,56 @@  -> String  -> Coeffs2  -> [String]- -> String -- ^ Is intended to be one of the following strings: \"02y\", \"02z\", \"03y\", \"03z\", \"04y\", \"04z\",- -- \"0y\", \"0z\", \"y\", \"y0\", \"y2\", \"y3\", \"y4\", \"yy\", \"yy2\", \"yy3\", \"z\", \"z2\", \"z3\", \"z4\",- -- \"zz\", \"zz2\", \"zz3\", \"zz4\" or some other one (that is the default one). Specifies the applied properties- -- to get the result. The \"z\"-line uses \'F\' functions. + -> [String] -- ^ List of properties encoded which are used to rewrite the text.  -> Int  -> FilePath  -> IO ()-generalProcessment (gr1,gr2) wrs ks arr gs h rs ysss xs js vs coeffs numericArgs choice numberI file = do+generalProcessment (gr1,gr2) wrs ks arr gs h rs ysss xs js vs coeffs numericArgs choices numberI file = do   contents <- readFile file   let !permsV = genPermutationsArrL       !flines         | gr1 == 0 = fLines ysss xs js vs 0 contents         | otherwise = prepareGrowTextMN gr1 gr2 ysss xs . unlines . fLines ysss xs js vs 0 $ contents       !lasts = map (\ts -> if null . words $ ts then [] else last . words $ ts) flines-  if compare numberI 2 == LT then toFileStr (file ++ ".new.txt") (circle2 wrs ks arr gs js vs h rs coeffs permsV choice [] $ flines)+  if compare numberI 2 == LT then+    mapM_ (\choice -> toFileStr (choice ++ "." ++ file ++ ".new.txt") (circle2 wrs ks arr gs js vs h rs coeffs permsV choice [] $ flines)) choices   else do     let !intervalNmbrs = (\vs -> if null vs then [numberI] else nub vs) . sort . filter (<= numberI) .            map (\t -> fromMaybe numberI (readMaybe t::Maybe Int)) . drop 2 $ numericArgs         !us = words . concat . take 1 $ flines         !l2 = (subtract 3) . length $ us     if compare l2 0 /= LT then do-      let !perms2 = unsafeAt permsV $ l2 -          (!minE,!maxE) = let !frep20 = chooseMax wrs ks arr gs js vs id h coeffs rs choice in minMax11C . map (toPropertiesF' frep20) .-                    uniquenessVariants2GNPBL [] (concat . take 1 $ lasts) ' ' id id id perms2 . init $ us-      toFileStr (file ++ ".new.txt") (circle2I wrs ks arr gs js vs h rs coeffs permsV choice [] numberI intervalNmbrs minE maxE $ flines)-    else toFileStr (file ++ ".new.txt") ((concat . take 1 $ flines):(circle2I wrs ks arr gs js vs h rs coeffs permsV choice [] numberI intervalNmbrs 0.0 0.0 . drop 1 $ flines))+      let !perms2 = unsafeAt permsV $ l2+          minMaxTuples = let !frep20Zip = zip choices . map (chooseMax wrs ks arr gs js vs id h coeffs rs) $ choices in+            map (\(choice,frep20) -> minMax11C . map (toPropertiesF' frep20) .+                    uniquenessVariants2GNPBL [] (concat . take 1 $ lasts) ' ' id id id perms2 . init $ us) frep20Zip+      mapM_ (\(choice, (minE,maxE)) ->+        toFileStr (choice ++ "." ++ file ++ ".new.txt") (circle2I wrs ks arr gs js vs h rs coeffs permsV choice [] numberI intervalNmbrs minE maxE $ flines)) .+          zip choices $ minMaxTuples+    else mapM_ (\choice -> toFileStr (choice ++ "." ++ file ++ ".new.txt") ((concat . take 1 $ flines):+       (circle2I wrs ks arr gs js vs h rs coeffs permsV choice [] numberI intervalNmbrs 0.0 0.0 . drop 1 $ flines))) choices -compareFilesToOneCommon :: FilePath -> FilePath -> FilePath -> IO ()-compareFilesToOneCommon file1 file2 file3 = do- contents1 <- fmap lines . readFile $ file1- contents2 <- fmap lines . readFile $ file2- let linesZipped = zip contents1 contents2- compare2F linesZipped file3-   where compare2F :: [(String,String)] -> FilePath -> IO ()-         compare2F yss file3 = mapM_ (\xs -> do-           putStrLn "Please, specify which variant to use as the result, either 1 or 2: "-           putStrLn $ "1:\t" ++ fst xs-           putStrLn $ "2:\t" ++ snd xs-           ch <- getLine-           let choice2 = fromMaybe 0 (readMaybe ch::Maybe Int)-           case choice2 of-            1 -> toFileStr file3 [fst xs]-            2 -> toFileStr file3 [snd xs]-            _ -> toFileStr file3 [""]) yss+compareFilesToOneCommon :: [FilePath] -> FilePath -> IO ()+compareFilesToOneCommon files file3 = do+ contentss <- mapM ((\(j,ks) -> do {readFileIfAny ks >>= \fs -> return (j, zip [1..] . lines $ fs)})) . zip [1..7] . take 7 $ files+ compareF contentss file3+   where compareF :: [(Int,[(Int,String)])] -> FilePath -> IO ()+         compareF ysss file3 = mapM_ (\i -> do+          putStr "Please, specify which variant to use as the result, "+          putStrLn "maximum number is the quantity of the files from which the data is read: "+          let strs = map (\(j,ks) -> (\ts -> if null ts then (j,"")+                      else let (k,rs) = head ts in  (j,rs)) .+                       filter ((== i) . fst) $ ks) ysss+          mapM_ (\(i,xs) -> putStrLn $ show i ++ ":\t" ++ xs) strs+          ch <- getLine+          let choice2 = fromMaybe 0 (readMaybe ch::Maybe Int)+          toFileStr file3 ((\us -> if null us then [""] else [snd . head $ us]) . filter ((== choice2) . fst) $ strs)) [1..]  -- | Processment without rearrangements. circle2  :: GWritingSystemPRPLX -- ^ Data used to obtain the phonetic language representation of the text.  -> [(Char,Char)] -- ^ The pairs of the 'Char' that corresponds to the similar phonetic languages consonant phenomenon-  -- (e. g. allophones). Must be sorted in the ascending order to be used correctly. +  -- (e. g. allophones). Must be sorted in the ascending order to be used correctly.  -> CharPhoneticClassification -- ^ The 'Array' 'Int' 'PRS' must be sorted in the ascending order to be used in the module correctly.  -> SegmentRulesG  -> String@@ -126,7 +131,7 @@  -> String -- ^ Is intended to be one of the following strings: \"02y\", \"02z\", \"03y\", \"03z\", \"04y\", \"04z\",  -- \"0y\", \"0z\", \"y\", \"y0\", \"y2\", \"y3\", \"y4\", \"yy\", \"yy2\", \"yy3\", \"z\", \"z2\", \"z3\", \"z4\",  -- \"zz\", \"zz2\", \"zz3\", \"zz4\" or some other one (that is the default one). Specifies the applied properties- -- to get the result. The \"z\"-line uses \'F\' functions. + -- to get the result. The \"z\"-line uses \'F\' functions.  -> [String]  -> [String]  -> [String]@@ -144,7 +149,7 @@ circle2I   :: GWritingSystemPRPLX -- ^ Data used to obtain the phonetic language representation of the text.   -> [(Char,Char)] -- ^ The pairs of the 'Char' that corresponds to the similar phonetic languages consonant phenomenon-  -- (e. g. allophones). Must be sorted in the ascending order to be used correctly. +  -- (e. g. allophones). Must be sorted in the ascending order to be used correctly.   -> CharPhoneticClassification -- ^ The 'Array' 'Int' 'PRS' must be sorted in the ascending order to be used in the module correctly.   -> SegmentRulesG   -> String@@ -161,7 +166,7 @@   -> String -- ^ Is intended to be one of the following strings: \"02y\", \"02z\", \"03y\", \"03z\", \"04y\", \"04z\",  -- \"0y\", \"0z\", \"y\", \"y0\", \"y2\", \"y3\", \"y4\", \"yy\", \"yy2\", \"yy3\", \"z\", \"z2\", \"z3\", \"z4\",  -- \"zz\", \"zz2\", \"zz3\", \"zz4\" or some other one (that is the default one). Specifies the applied properties- -- to get the result. The \"z\"-line uses \'F\' functions. + -- to get the result. The \"z\"-line uses \'F\' functions.   -> [String]   -> Int   -> [Int]@@ -176,14 +181,14 @@             !w2s = words . concat . take 1 $ tss             !l3 = (subtract 3) . length $ w2s             !rs = words . concat $ zss-            !l = length rs +            !l = length rs             !frep2 = chooseMax wrs ks arr gs js vs (unsafeSwapVecIWithMaxI minE maxE numberI intervNbrs) h coeffs qs choice             !ws = if compare (length rs) 3 == LT then unwords rs else line . maximumElR . map (toResultR frep2) .                uniquenessVariants2GNPBL [] (last rs) ' ' id id id (unsafeAt permsG1 (l - 3)) . init $ rs             (!minE1,!maxE1)              | compare l3 0 /= LT =                let !perms3 = unsafeAt permsG1 l3-                   !v4 = init w2s  +                   !v4 = init w2s                    !frep20 = chooseMax wrs ks arr gs js vs id h coeffs qs choice in minMax11C . map (toPropertiesF' frep20) .                       uniquenessVariants2GNPBL [] (last w2s) ' ' id id id perms3 $ v4              | otherwise = (0.0,0.0)
Phonetic/Languages/General/Lines/Parsing.hs view
@@ -23,7 +23,7 @@ import Phonetic.Languages.General.Lines import Data.Phonetic.Languages.PrepareText import Phonetic.Languages.General.Lines-import Data.List (sort)+import Data.List (sort,nub) import GHC.Arr import Data.Phonetic.Languages.Base import Data.Phonetic.Languages.Syllables@@ -44,6 +44,10 @@ -- three files -- the first two -- the existing ones with probably rewritten text by the program for different arguments -- and the third one is the resulting file. While running in such a mode the program outputs line-by-line the contents of -- the two first files and writes one of them (or an empty line if neither one) to the third file.+--+-- @ since 0.12.0.0+-- You can run the comparative mode on the up to 7 different files simultaneously.+-- Besides, there is also a multiple properties mode. argsToLinePrepare  :: (Double -> String -> ([[[PRS]]] -> [[Double]])) -- ^ The function that is needed in the 'procRhythmicity23F' function.  -- Specifies a way how the syllables represented in the phonetic language approach transforms into their durations and@@ -54,16 +58,23 @@   -- exact one and, therefore, the default one.  -> IO () argsToLinePrepare h qs = do- args00 <- getArgs- let coeffs = readCF . concat . take 1 $ args00 -- The first command line argument. If not sure, pass just \"1_\".+ args000 <- getArgs+ let multiple = if null . filter (== "+m") $ args000 then 0 else 1+     args00+       | multiple == 1 = takeWhile (/= "+m") args000 `mappend` drop 1 (dropWhile (/= "-m") args000)+       | otherwise = args000+     coeffs = readCF . concat . take 1 $ args00 -- The first command line argument. If not sure, pass just \"1_\".      compare2 = (\xs -> if null xs then False else True) . filter (== "+c") $ args00  if compare2 then do    let args1 = filter (\xs -> xs /= "+c" && take 2 xs /= "+g") args00-       [file1, file2, file3] = take 3 args1-   if file3 /= file1 && file3 /= file2 then compareFilesToOneCommon file1 file2 file3-   else do-    putStrLn "You specified some files twice being in the comparative mode, the program has no well-defined behaviour in such a mode. "-    putStrLn "Please, run it again and specify the three different arguments with the first two being the existing files. "+       (args2,file3)+         | null args1 = ([],[])+         | otherwise = (init . nub $ args1,last args1)+   if null file3 then do+       putStrLn "Please, specify the file to save the data to. "+       file3 <- getLine+       compareFilesToOneCommon args2 file3+   else compareFilesToOneCommon args2 file3  else do   let growing = filter ((== "+g") . (take 2)) args00       (gr1,gr2)@@ -73,10 +84,10 @@                               mm = readMaybe (concat mms)::Maybe Int in case (nm,mm) of                                   (Just n4,Just m4) -> if (m4 `rem` 7) < (n4 `rem` 7) then (n4 `rem` 7 + 1, m4 `rem` 7 + 1) else (0,0)                                   _ -> (0,0)-      args0 = drop 5 args00+      args0 = drop 5 args000       [fileGWrSys, controlFile, segmentRulesFile, concatenationsFileP] = drop 1 . take 5 $ args00 -- To get the valid 'Concatenations' data.-  (wrs, ks, arr, gs, js, vs, ysss, xs, numericArgs, choice, numberI, file) <- files4Processment fileGWrSys controlFile segmentRulesFile concatenationsFileP args0-  generalProcessment (gr1,gr2) wrs ks arr gs h qs ysss xs js vs {- the old arguments afterwards -} coeffs numericArgs choice numberI file+  (wrs, ks, arr, gs, js, vs, ysss, xs, numericArgs, choices, numberI, file) <- files4Processment fileGWrSys controlFile segmentRulesFile concatenationsFileP multiple args0+  generalProcessment (gr1,gr2) wrs ks arr gs h qs ysss xs js vs {- the old arguments afterwards -} coeffs numericArgs choices numberI file  -- | Is used internally in the 'argsToLinePrepare'. Nevertheless, can be used independently if the semantics -- of the arguments and their structure are preserved.@@ -85,14 +96,21 @@   -> FilePath -- ^ With the 5 meaningful lines that are delimited with the \'~\' line one from another with the specifications for the possible allophones (if any), 'CharPhoneticClassification', white spaces information (two 'String's) and the 'String' of all the possible 'PLL' 'Char's;   -> FilePath -- ^ With the 'SegmentRulesG' specifications only;   -> FilePath -- ^ With the 'Concatenations' specifications only (see the data in the EnglishConcatenated.txt file in the @phonetic-languages-phonetics-basics@ package as a list of English equivalents of the needed 'String's).+  -> Int -- ^ If equal to 1, then the function is intended to be used in the multiple properties mode, else it is intended to be used in the single property mode.   -> [String] -- ^ List of other command line arguments-  -> IO (GWritingSystemPRPLX, [(Char, Char)], CharPhoneticClassification, SegmentRulesG, String, String, Concatenations, String, [String], String, Int, FilePath)-files4Processment fileGWrSys controlFile segmentRulesFile concatenationsFileP args0 = do+  -> IO (GWritingSystemPRPLX, [(Char, Char)], CharPhoneticClassification, SegmentRulesG, String, String, Concatenations, String, [String], [String], Int, FilePath)+files4Processment fileGWrSys controlFile segmentRulesFile concatenationsFileP multiple args0 = do   [controlConts, gwrsCnts, segmentData, concatenationsFile] <- mapM readFile [controlFile, fileGWrSys, segmentRulesFile, concatenationsFileP]-  let !numericArgs = filter (all isDigit) . drop 2 $ args0-      !choice = concat . drop 1 . take 2 $ args0+  let args00+       | multiple == 1 = takeWhile (/= "+m") args0 `mappend` drop 1 (dropWhile (/= "-m") args0)+       | otherwise = args0+      !args1 = filter (\xs -> take 2 xs /= "+g") args00+      !numericArgs = filter (all isDigit) args1+      !choices+         | multiple == 1 = drop 1 . dropWhile (/= "+m") . takeWhile (/= "-m") $ args0+         | otherwise = drop 1 . take 2 . filter (\xs -> take 2 xs /= "+g") $ args0       !numberI = fromMaybe 1 (readMaybe (concat . take 1 $ numericArgs)::Maybe Int)       !file = concat . take 1 $ args0       (wrs, ks, arr, gs, js, vs, ysss, xs) = innerProcessmentSimple gwrsCnts controlConts segmentData concatenationsFile-        in return (wrs, ks, arr, gs, js, vs, ysss, xs, numericArgs, choice, numberI, file)- +        in return (wrs, ks, arr, gs, js, vs, ysss, xs, numericArgs, choices, numberI, file)+
README.md view
@@ -76,7 +76,11 @@ Since the 0.5.0.0 version you can use also "w" and "x" series (lines) of properties. They use more complex approach and are intended for 4 elements in the rhythmic groups. For more information, please, refer to the section 'WX argument' in the English instruction:-https://oleksandrzhabenko.github.io/uk/InstructionEng.11.3.pdf+https://oleksandrzhabenko.github.io/uk/InstructionEng.12.pdf++or here:++https://web.archive.org/web/20210914215340/https://oleksandrzhabenko.github.io/uk/InstructionEng.12.pdf  There are also some additional information there about the changes in the 0.6.0.0 version. 
phonetic-languages-simplified-generalized-examples-array.cabal view
@@ -3,7 +3,7 @@ -- http://haskell.org/cabal/users-guide/  name:                phonetic-languages-simplified-generalized-examples-array-version:             0.11.3.0+version:             0.12.0.0 synopsis:            Helps to create texts with the given phonetic properties (e. g. poetic). description:         Is rewritten from the modules of the @phonetic-languages-simplified-examples-array@ package. Can be used not only for Ukrainian, but also for other languages. homepage:            https://hackage.haskell.org/package/phonetic-languages-simplified-generalized-examples-array