packages feed

phladiprelio-general-simple 0.5.0.0 → 0.6.0.0

raw patch · 5 files changed

+125/−25 lines, 5 filesdep +directorydep +halfsplitdep ~phonetic-languages-constraints-arrayPVP ok

version bump matches the API change (PVP)

Dependencies added: directory, halfsplit

Dependency ranges changed: phonetic-languages-constraints-array

API changes (from Hackage documentation)

+ Phladiprelio.General.Simple: S :: Int -> Integer -> String -> PhladiprelioGen
+ Phladiprelio.General.Simple: bSpecs :: CLSpecifications
+ Phladiprelio.General.Simple: data PhladiprelioGen
+ Phladiprelio.General.Simple: instance GHC.Classes.Eq Phladiprelio.General.Simple.PhladiprelioGen
+ Phladiprelio.General.Simple: instance GHC.Show.Show Phladiprelio.General.Simple.PhladiprelioGen
+ Phladiprelio.General.Simple: outputSel :: PhladiprelioGen -> Int -> String
+ Phladiprelio.General.Simple: parseLineNumber :: Int -> IO Int
- Phladiprelio.General.Simple: generalF :: GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> ([[[PRS]]] -> [[Double]]) -> Int -> HashCorrections -> (Int8, [Int8]) -> Bool -> Int -> Bool -> [String] -> IO [()]
+ Phladiprelio.General.Simple: generalF :: GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> ([[[PRS]]] -> [[Double]]) -> Int -> HashCorrections -> (Int8, [Int8]) -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> [String] -> IO [String]

Files

CHANGELOG.md view
@@ -71,3 +71,12 @@ * Fifth version. Fixed issues with incorrect parentheses behaviour for +b ... -b command line   arguments group. Updated the corresponding dependency boundaries. Added much more variants of tests (to improve mostly performance characteristics). ++## 0.6.0.0 -- 2023-06-15++* Sixth 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.+
+ 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.
Phladiprelio/General/Simple.hs view
@@ -4,20 +4,21 @@  import GHC.Base import GHC.Enum (fromEnum,toEnum)-import GHC.Real (fromIntegral,(/),quot,rem)-import Text.Show (show)+import GHC.Real (fromIntegral,(/),quot,rem,quotRem)+import Text.Show (Show(..)) import Phladiprelio.General.PrepareText  import Phladiprelio.General.Syllables  import Phladiprelio.General.Base import System.Environment (getArgs)-import GHC.Num ((+),(-),(*))+import GHC.Num ((+),(-),(*),Integer) import Text.Read (readMaybe)-import System.IO (putStrLn, FilePath,stdout,universalNewlineMode,hSetNewlineMode)+import System.IO (putStrLn, FilePath,stdout,universalNewlineMode,hSetNewlineMode,getLine,appendFile) import Rhythmicity.MarkerSeqs hiding (id)  import Rhythmicity.BasicF  import Data.List hiding (foldr)-import Data.Maybe (fromMaybe, mapMaybe, catMaybes) +import Data.Maybe (fromMaybe, mapMaybe, catMaybes,isNothing,fromJust)  import Data.Tuple (fst,snd)+import Data.Char (isDigit) import CLI.Arguments import CLI.Arguments.Get import CLI.Arguments.Parsing@@ -28,6 +29,8 @@ import Phladiprelio.PermutationsArr import Phladiprelio.StrictVG import Numeric (showFFloat)+import Phladiprelio.Halfsplit+import System.Directory (doesFileExist,readable,writable,getPermissions,Permissions(..))  generalF   :: GWritingSystemPRPLX -- ^ Data used to obtain the phonetic language representation of the text.@@ -43,25 +46,41 @@  -> Bool  -> Int -- ^ The hashing function step. The default value is 20. Is expected to be greater than 2, and better greater than 12.   -> Bool + -> Int8+ -> (FilePath, Int)  -> [String] - -> IO [()] -generalF wrs ks arr gs us vs h numTest hc (grps,mxms) descending hashStep emptyline universalSet - | null universalSet = mapM putStrLn ["You have specified the data and constraints on it that lead to no further possible options.", "Please, specify another data and constraints."]+ -> IO [String] +generalF wrs ks arr gs us vs h numTest hc (grps,mxms) descending hashStep emptyline splitting (fs, code) universalSet + | null universalSet = 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+ | length universalSet == 1 = mapM putStrLn universalSet >> return universalSet  | otherwise = do    let syllN = countSyll wrs arr us vs . concat . take 1  $ universalSet --       universalSet = map unwords . permutations $ rss        f grps mxms = sum . countHashes2G hashStep hc grps mxms . mconcat . h . createSyllablesPL wrs ks arr gs us vs-   if numTest `elem` 0:[2..9] then do-      hSetNewlineMode stdout universalNewlineMode+   hSetNewlineMode stdout universalNewlineMode+   if numTest >= 0 && numTest <= 179 && numTest /= 1 then do       putStrLn "Feet   Val  Stat   Proxim"        mapM (\(q,qs) -> let m = stat1 syllN (q,qs)                            (min1,max1) = minMax11ByCList (comparing (f q qs)) universalSet -                           mx = f 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 numTest >= 4 then let min1 = minimumBy (comparing (f q qs)) universalSet in ("\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 (u,w) = if descending then ((-1)*u,w) else (u,w) in sortOn h1) . map (\xss -> (f grps mxms xss, xss)) $ universalSet+                           mx = f 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 let min1 = minimumBy (comparing (f q qs)) universalSet in ("\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 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.@@ -140,7 +159,18 @@                         | g z y == GT = (x,z)                         | otherwise = (x,y)            minMax11ByCList _ _ = undefined -- Is not intended to be used for lists with less than two elements.+           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) +data PhladiprelioGen = S Int Integer String deriving Eq++instance Show PhladiprelioGen where+  show (S i j xs) = show j `mappend` " " `mappend` xs `mappend` "  " `mappend` show i+ countSyll    :: GWritingSystemPRPLX -- ^ Data used to obtain the phonetic language representation of the text.   -> CharPhoneticClassification @@ -162,6 +192,25 @@ stat1 :: Int -> (Int8,[Int8]) -> Int stat1 n (k, ks) = fst (n `quotRemInt` fromEnum k) * length ks +outputSel :: PhladiprelioGen -> 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+ processingF  :: 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. @@ -182,11 +231,18 @@ processingF wrs ks arr gs us vs h numTest hc (grps,mxms) ysss zsss descending hashStep xs = do   args0 <- getArgs   let (argsC, args) = takeCs1R ('+','-') cSpecs args0-      prepare = any (== "-p") args-      emptyline = any (== "+l") args +      (argsB, args11) = takeBsR bSpecs args+      prepare = any (== "-p") args11+      emptyline = any (== "+l") args11        argCs = catMaybes (fmap (readMaybeECG l) -- . (showB l lstW2:)                                                     . getC "+a" $ argsC)-      ll = take 7 . (if prepare then id else words . mconcat . prepareText ysss zsss xs . unwords) $ args+      splitting = fromMaybe 50 (readMaybe (concat . getB "+w" $ argsB)::Maybe Int8) +      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 ysss zsss xs . unwords) $ args11       l = length ll       argCBs = unwords . getC "+b" $ argsC -- If you use the parenthese with +b ... -b then consider also using the quotation marks for the whole algebraic constraint. At the moment though it is still not working properly for parentheses functionality. The issue should be fixed in the further releases.       !perms @@ -194,7 +250,7 @@         | null argCs = genPermutationsL l         | otherwise = decodeLConstraints argCs . genPermutationsL $ l        variants1 = uniquenessVariants2GNBL ' ' id id id perms ll-  generalF wrs ks arr gs us vs h numTest hc (grps,mxms) descending hashStep emptyline variants1 >> return ()+  generalF wrs ks arr gs us vs h numTest hc (grps,mxms) descending hashStep emptyline splitting (filesave, codesave) variants1 >> return ()  -- | Specifies the group of the command line arguments for 'processingF', which specifies the -- PhLADiPreLiO constraints. For more information, see:@@ -202,3 +258,5 @@ cSpecs :: CLSpecifications cSpecs = zip ["+a","+b"] . cycle $ [-1] +bSpecs :: CLSpecifications+bSpecs = [("+f",2), ("+w",1)]
README.md view
@@ -1,6 +1,6 @@ The library is the new implementation of the ideas related to PhLADiPreLiO (Phonetic Languages Approach to Discovering the Preferred Line Options) for different languages. It uses hashes and-has at the moment (as of the version 0.5.0.0) not the full functionality. The previous implementation +has at the moment (as of the version 0.6.0.0) not the full functionality. The previous implementation  and its documentation are at the links:  https://hackage.haskell.org/package/phonetic-languages-simplified-generalized-examples-array@@ -10,10 +10,18 @@ [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.6.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.6.0.0 is by the link for+the parallel project phladiprelio-ukrainian-simple:++https://www.facebook.com/100012184148486/posts/1767318773684244+ Examples of the new functionality in the version 0.5.1.1 of the related prototype project for  Ukrainian is in the videos: @@ -51,6 +59,10 @@ On the 25/05/2023 there is Ascension Day according to Julian Greek Orthodox calendar.   On the 01/06/2023 there is Children's Day in many countries including Ukraine and the Netherlands.++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 foundation using the URL:
phladiprelio-general-simple.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               phladiprelio-general-simple-version:            0.5.0.0+version:            0.6.0.0  -- A short (one-line) description of the package. synopsis:           A generalized functionality of PhLADiPreLiO for different languages that uses hash algorithms.@@ -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 @@ -27,7 +28,7 @@      -- LANGUAGE extensions used by modules in this package.     other-extensions: NoImplicitPrelude, BangPatterns-    build-depends:    base >=4.13 && <5, rhythmic-sequences ==0.3.0.0, phonetic-languages-phonetics-basics ==0.10.0.2, phladiprelio-general-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, phonetic-languages-phonetics-basics ==0.10.0.2, phladiprelio-general-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:   .     default-language: Haskell2010