phonetic-languages-simplified-base 0.7.0.0 → 0.9.0.0
raw patch · 8 files changed
Files
- CHANGELOG.md +13/−0
- Data/ChooseLine.hs +67/−0
- LICENSE +1/−1
- Phladiprelio/DataG.hs +30/−11
- Phladiprelio/Partir.hs +11/−5
- Phladiprelio/StrictVG.hs +6/−4
- README.md +24/−0
- phonetic-languages-simplified-base.cabal +8/−6
CHANGELOG.md view
@@ -63,3 +63,16 @@ * Seventh version. Switched to NoImplicitPrelude extension. Changed the names of the modules. Updated the dependencies boundaries. +## 0.7.1.0 -- 2023-06-24++* Seventh version revised A. Fixed constraints in the function declarations so that the code can+ successfully be compiled for GHC-9.6.2 compiler.++## 0.8.0.0 -- 2024-01-24++* Eighth version. Added bug-tracker on Github. Generalized functions with specializing. Updated the dependencies, switched to minmax and monoid-insertleft instead of subG.++ ## 0.9.0.0 -- 2024-03-08++* Ninth version. Added a new module Data.ChooseLine with common functionality for PhLADiPreLiO mostly taken and rewritten from previous implementations. +
+ Data/ChooseLine.hs view
@@ -0,0 +1,67 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module : Data.ChooseLine+-- Copyright : (c) Oleksandr Zhabenko 2021-2024+-- License : MIT+-- Stability : Experimental+-- Maintainer : oleksandr.zhabenko@yahoo.com+--+-- General shared by phladiprelio-ukrainian-simple and phladiprelio-general-simple functionality to compare contents of the up to 14 files line-by-line +-- and to choose the resulting option. ++{-# LANGUAGE NoImplicitPrelude, ScopedTypeVariables #-}++module Data.ChooseLine where++import GHC.Base+import Data.Foldable (mapM_) +import Data.Maybe (fromMaybe) +import Text.Show (Show(..))+import Text.Read (readMaybe)+import System.IO (putStrLn, FilePath,getLine,appendFile,putStr,readFile)+import Data.List+import Data.Tuple (fst,snd)+import Control.Exception (IOException,catch) ++-- | Is rewritten from the <https://hackage.haskell.org/package/phonetic-languages-simplified-examples-array-0.21.0.0/docs/src/Phonetic.Languages.Lines.html#compareFilesToOneCommon>+-- Given a list of different filepaths and the resulting filepath for the accumulated data provides a simple way to compare options of the lines in every file in the+-- first argument and to choose that option for the resulting file. Therefore, the resulting file can combine options for lines from various sources.+compareFilesToOneCommon + :: Int -- ^ A number of files to be read and treated as sources of lines to choose from.+ -> [FilePath] + -> FilePath + -> IO ()+compareFilesToOneCommon n files file3 = do+ contentss <- mapM ((\(j,ks) -> do {readFileIfAny ks >>= \fs -> return (j, zip [1..] . lines $ fs)})) . zip [1..] . take n $ 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 (_,rs) = head ts in (j,rs)) .+ filter ((== i) . fst) $ ks) ysss+ putStrLn . unlines . map (\(i,xs) -> 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..]++{-| Inspired by: 'https://hackage.haskell.org/package/base-4.15.0.0/docs/src/GHC-IO.html#catch' + Is taken from the +https://hackage.haskell.org/package/string-interpreter-0.8.0.0/docs/src/Interpreter.StringConversion.html#readFileIfAny+to reduce general quantity of dependencies.+Reads a textual file given by its 'FilePath' and returns its contents lazily. If there is+some 'IOException' thrown or an empty file then returns just "". Raises an exception for the binary file. -}+readFileIfAny :: FilePath -> IO String+readFileIfAny file = catch (readFile file) (\(_ :: IOException) -> return "")+{-# INLINE readFileIfAny #-}++-- | Prints list of 'String's to the file as a multiline 'String' with default line ending. Uses 'appendFile' function inside.+toFileStr ::+ FilePath -- ^ The 'FilePath' to the file to be written in the 'AppendMode' (actually appended with) the information output.+ -> [String] -- ^ Each element is appended on the new line to the file.+ -> IO ()+toFileStr file = appendFile file . unlines+{-# INLINE toFileStr #-}+
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2020-2023 Oleksandr Zhabenko+Copyright (c) 2020-2024 Oleksandr Zhabenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
Phladiprelio/DataG.hs view
@@ -2,7 +2,7 @@ -- | -- Module : Phladiprelio.DataG--- Copyright : (c) Oleksandr Zhabenko 2020-2023+-- Copyright : (c) Oleksandr Zhabenko 2020-2024 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com@@ -18,8 +18,9 @@ import GHC.Num ((-)) import GHC.Real import qualified Data.Foldable as F-import Data.SubG-import Data.MinMax.Preconditions+import Data.InsertLeft (InsertLeft(..),mapG,partitionG) +import Data.MinMax1+import Data.Maybe (fromJust) import Phladiprelio.Basis maximumEl@@ -31,30 +32,36 @@ !m = getAB frep2 l !tm = getBC frep2 m in R {line = l, propertiesF = m, transPropertiesF = tm} {-# INLINE maximumEl #-}+{-# SPECIALIZE maximumEl :: (Ord c) => FuncRep2 [a] Double c -> [[a]] -> Result [] a Double c #-} +-- | Is intended to be used for the structures with at least two elements, though it is not checked. minMaximumEls :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord (t a), Ord c) => FuncRep2 (t a) b c -> t2 (t a) -> (Result t a b c,Result t a b c) minMaximumEls !frep2 data0 =- let (!ln,!lx) = minMax11ByC (\x y -> compare (getAC frep2 x) (getAC frep2 y)) data0+ let (!ln,!lx) = fromJust . minMax11By (\x y -> compare (getAC frep2 x) (getAC frep2 y)) $ data0 !mn = getAB frep2 ln !mx = getAB frep2 lx !tmn = getBC frep2 mn !tmx = getBC frep2 mx in (R {line = ln, propertiesF = mn, transPropertiesF = tmn}, R {line = lx, propertiesF = mx, transPropertiesF = tmx}) {-# INLINE minMaximumEls #-}+{-# SPECIALIZE minMaximumEls :: (Ord a, Ord c) => FuncRep2 [a] Double c -> [[a]] -> (Result [] a Double c, Result [] a Double c) #-} maximumElR :: (F.Foldable t2, Ord c) => t2 (Result t a b c) -> Result t a b c maximumElR = F.maximumBy (\x y -> compare (transPropertiesF x) (transPropertiesF y)) {-# INLINE maximumElR #-}+{-# SPECIALIZE maximumElR :: (Ord c) => [Result [] a Double c] -> Result [] a Double c #-} +-- | Is intended to be used for the structures with at least two elements, though it is not checked. minMaximumElRs :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), Ord (t a), Ord b, Ord c) => t2 (Result t a b c) -> (Result t a b c,Result t a b c)-minMaximumElRs = minMax11ByC (\x y -> compare (transPropertiesF x) (transPropertiesF y))+minMaximumElRs = fromJust . minMax11By (\x y -> compare (transPropertiesF x) (transPropertiesF y)) {-# INLINE minMaximumElRs #-}+{-# SPECIALIZE minMaximumElRs :: (Ord a, Ord c) => [Result [] a Double c] -> (Result [] a Double c, Result [] a Double c) #-} ----------------------------------------------------------------------------------- @@ -66,6 +73,7 @@ innerPartitioning !frep2 data0 = let !l = F.maximum . mapG (toTransPropertiesF' frep2) $ data0 in partitionG ((== l) . getAC frep2) data0 {-# INLINE innerPartitioning #-}+{-# SPECIALIZE innerPartitioning :: (Eq a, Ord c) => FuncRep2 [a] Double c -> [[a]] -> ([[a]], [[a]]) #-} -- | The first argument must be not empty for the function to work correctly. innerPartitioningR@@ -74,6 +82,7 @@ innerPartitioningR dataR = let !l = F.maximum . mapG transPropertiesF $ dataR in partitionG ((== l) . transPropertiesF) dataR {-# INLINE innerPartitioningR #-}+{-# SPECIALIZE innerPartitioningR :: (Eq a, Ord c) => [Result [] a Double c] -> ([Result [] a Double c], [Result [] a Double c]) #-} maximumGroupsClassification :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d@@ -99,7 +108,7 @@ {-# NOINLINE maximumGroupsClassification1 #-} maximumGroupsClassificationR2- :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d+ :: (Eq a, Eq b, Eq (t a), InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d -> (t2 (Result t a b c), t2 (Result t a b c)) -> (t2 (Result t a b c), t2 (Result t a b c)) maximumGroupsClassificationR2 !nGroups (dataT,dataF)@@ -110,7 +119,7 @@ {-# NOINLINE maximumGroupsClassificationR2 #-} maximumGroupsClassificationR- :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), InsertLeft t2 c, Monoid (t2 c), Ord c, Integral d) => d+ :: (Eq a, Eq b, Eq (t a), InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), InsertLeft t2 c, Monoid (t2 c), Ord c, Integral d) => d -> t2 (Result t a b c) -> (t2 (Result t a b c), t2 (Result t a b c)) maximumGroupsClassificationR !nGroups dataR@@ -149,6 +158,7 @@ -> (t2 (Result t a b c), t2 (Result t a b c)) partiR p dataR = partitionG (p . transPropertiesF) dataR {-# INLINE partiR #-}+{-# SPECIALIZE partiR :: (Eq a, Eq c) => (c -> Bool) -> [Result [] a Double c] -> ([Result [] a Double c], [Result [] a Double c]) #-} ----------------------------------------------------------- @@ -161,30 +171,36 @@ !m = getAB frep2 l !tm = getBC frep2 m in R2 {line2 = l, propertiesF2 = m, transPropertiesF2 = tm} {-# INLINE maximumEl2 #-}+{-# SPECIALIZE maximumEl2 :: (Ord c) => FuncRep2 a Double c -> [a] -> Result2 a Double c #-} +-- | Is intended to be used with the structures with at least two elements, though it is not checked. minMaximumEls2 :: (InsertLeft t2 a, Monoid (t2 a), Ord a, Ord c) => FuncRep2 a b c -> t2 a -> (Result2 a b c,Result2 a b c) minMaximumEls2 !frep2 data0 =- let (!ln,!lx) = minMax11ByC (\x y -> compare (getAC frep2 x) (getAC frep2 y)) data0+ let (!ln,!lx) = fromJust . minMax11By (\x y -> compare (getAC frep2 x) (getAC frep2 y)) $ data0 !mn = getAB frep2 ln !mx = getAB frep2 lx !tmn = getBC frep2 mn !tmx = getBC frep2 mx in (R2 {line2 = ln, propertiesF2 = mn, transPropertiesF2 = tmn}, R2 {line2 = lx, propertiesF2 = mx, transPropertiesF2 = tmx}) {-# INLINE minMaximumEls2 #-}+{-# SPECIALIZE minMaximumEls2 :: (Ord a, Ord c) => FuncRep2 a Double c -> [a] -> (Result2 a Double c, Result2 a Double c) #-} maximumElR2 :: (F.Foldable t2, Ord c) => t2 (Result2 a b c) -> Result2 a b c maximumElR2 = F.maximumBy (\x y -> compare (transPropertiesF2 x) (transPropertiesF2 y)) {-# INLINE maximumElR2 #-}+{-# SPECIALIZE maximumElR2 :: (Ord c) => [Result2 a Double c] -> Result2 a Double c #-} +-- | Is intended to be used with the structures with at least two elements, though it is not checked. minMaximumElRs2 :: (InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord a, Ord b, Ord c) => t2 (Result2 a b c) -> (Result2 a b c,Result2 a b c)-minMaximumElRs2 = minMax11ByC (\x y -> compare (transPropertiesF2 x) (transPropertiesF2 y))+minMaximumElRs2 = fromJust . minMax11By (\x y -> compare (transPropertiesF2 x) (transPropertiesF2 y)) {-# INLINE minMaximumElRs2 #-}+{-# SPECIALIZE minMaximumElRs2 :: (Ord a, Ord c) => [Result2 a Double c] -> (Result2 a Double c, Result2 a Double c) #-} ----------------------------------------------------------------------------------- @@ -196,6 +212,7 @@ innerPartitioning2 !frep2 data0 = let !l = F.maximum . mapG (toTransPropertiesF'2 frep2) $ data0 in partitionG ((== l) . getAC frep2) data0 {-# INLINE innerPartitioning2 #-}+{-# SPECIALIZE innerPartitioning2 :: (Eq a, Ord c) => FuncRep2 a Double c -> [a] -> ([a], [a]) #-} -- | The first argument must be not empty for the function to work correctly. innerPartitioningR2@@ -204,6 +221,7 @@ innerPartitioningR2 dataR = let !l = F.maximum . mapG transPropertiesF2 $ dataR in partitionG ((== l) . transPropertiesF2) dataR {-# INLINE innerPartitioningR2 #-}+{-# SPECIALIZE innerPartitioningR2 :: (Eq a, Ord c) => [Result2 a Double c] -> ([Result2 a Double c], [Result2 a Double c]) #-} maximumGroupsClassification2 :: (InsertLeft t2 a, Monoid (t2 a), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d@@ -229,7 +247,7 @@ {-# NOINLINE maximumGroupsClassification12 #-} maximumGroupsClassificationR2_2- :: (InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d+ :: (Eq a, Eq b, InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d -> (t2 (Result2 a b c), t2 (Result2 a b c)) -> (t2 (Result2 a b c), t2 (Result2 a b c)) maximumGroupsClassificationR2_2 !nGroups (dataT,dataF)@@ -240,7 +258,7 @@ {-# NOINLINE maximumGroupsClassificationR2_2 #-} maximumGroupsClassificationR_2- :: (InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), InsertLeft t2 c, Monoid (t2 c), Ord c, Integral d) => d+ :: (Eq a, Eq b, InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), InsertLeft t2 c, Monoid (t2 c), Ord c, Integral d) => d -> t2 (Result2 a b c) -> (t2 (Result2 a b c), t2 (Result2 a b c)) maximumGroupsClassificationR_2 !nGroups dataR@@ -279,4 +297,5 @@ -> (t2 (Result2 a b c), t2 (Result2 a b c)) partiR2 p dataR = partitionG (p . transPropertiesF2) dataR {-# INLINE partiR2 #-}+{-# SPECIALIZE partiR2 :: (Eq a, Eq c) => (c -> Bool) -> [Result2 a Double c] -> ([Result2 a Double c], [Result2 a Double c]) #-}
Phladiprelio/Partir.hs view
@@ -2,7 +2,7 @@ -- | -- Module : Phladiprelio.Partir--- Copyright : (c) Oleksandr Zhabenko 2022-2023+-- Copyright : (c) Oleksandr Zhabenko 2022-2024 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com@@ -18,8 +18,7 @@ import GHC.Real import GHC.Float import qualified Data.Foldable as F-import Data.SubG-import Data.MinMax.Preconditions+import Data.InsertLeft (InsertLeft(..)) import Phladiprelio.DataG import Phladiprelio.Basis import Data.Char (isDigit)@@ -64,7 +63,11 @@ partitioningR !xs dataR | F.null dataR = (mempty,mempty) | otherwise = partiR (decodeCDouble xs) dataR-{-# INLINABLE partitioningR #-}+{-# INLINE partitioningR #-}+{-# SPECIALIZE partitioningR + :: String+ -> [Result [] Char Double Double]+ -> ([Result [] Char Double Double], [Result [] Char Double Double])#-} partitioningR2 :: (InsertLeft t2 (Result2 a b Double), Monoid (t2 (Result2 a b Double)), InsertLeft t2 Double, Monoid (t2 Double)) => String@@ -73,5 +76,8 @@ partitioningR2 !xs dataR | F.null dataR = (mempty,mempty) | otherwise = partiR2 (decodeCDouble xs) dataR-{-# INLINABLE partitioningR2 #-}+{-# INLINE partitioningR2 #-}+{-# SPECIALIZE partitioningR2 :: (Eq a) => String+ -> [Result2 a Double Double]+ -> ([Result2 a Double Double], [Result2 a Double Double]) #-}
Phladiprelio/StrictVG.hs view
@@ -2,7 +2,7 @@ -- | -- Module : Phladiprelio.StrictVG--- Copyright : (c) Oleksandr Zhabenko 2020-2023+-- Copyright : (c) Oleksandr Zhabenko 2020-2024 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com@@ -22,7 +22,7 @@ import GHC.Num ((-)) import Phladiprelio.PermutationsArr import qualified Data.Foldable as F-import Data.SubG+import Data.InsertLeft (InsertLeft(..)) import GHC.Arr uniquenessVariants2GNBL ::@@ -31,10 +31,11 @@ -> ((t (t a)) -> [[a]]) -- ^ The function that is used internally to convert to the @[[a]]@ so that the function can process further -> ([a] -> t a) -- ^ The function that is used internally to convert to the needed representation so that the function can process further -> [Array Int Int] -- ^ The permutations of 'Int' indices starting from 0 and up to n (n is probably less than 8).- -> t (t a) -- ^ Must be obtained as 'subG' @whspss xs@+ -> t (t a) -- ^ Must be obtained as 'subG' @whspss xs@ or in equivalent way -> [t a] uniquenessVariants2GNBL !hd f1 f2 f3 perms !subs = uniquenessVariants2GNPBL mempty mempty hd f1 f2 f3 perms subs {-# INLINE uniquenessVariants2GNBL #-}+{-# SPECIALIZE uniquenessVariants2GNBL :: Char -> (String -> String) -> ([String] -> [String]) -> (String -> String) -> [Array Int Int] -> [String] -> [String] #-} uniquenessVariants2GNPBL :: (Eq a, F.Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => t a@@ -44,7 +45,7 @@ -> ((t (t a)) -> [[a]]) -- ^ The function that is used internally to convert to the @[[a]]@ so that the function can process further -> ([a] -> t a) -- ^ The function that is used internally to convert to the needed representation that the function can process further -> [Array Int Int] -- ^ The permutations of 'Int' indices starting from 0 and up to n (n is probably less than 8).- -> t (t a) -- ^ Must be obtained as @subG whspss xs@+ -> t (t a) -- ^ Must be obtained as @subG whspss xs@ or in equivalent way -> [t a] uniquenessVariants2GNPBL !ts !us !hd f1 f2 f3 perms !subs | F.null subs = mempty@@ -55,3 +56,4 @@ !baseArr = listArray (0,l - 1) base0 !ns = universalSetGL ts uss f1 f2 perms baseArr -- in map f3 ns {-# INLINE uniquenessVariants2GNPBL #-}+{-# SPECIALIZE uniquenessVariants2GNPBL :: String -> String -> Char -> (String -> String) -> ([String] -> [String]) -> (String -> String) -> [Array Int Int] -> [String] -> [String] #-}
+ README.md view
@@ -0,0 +1,24 @@+ Devotion+ ========++The author would like to devote this project to support the [Foundation Gastrostars](https://gastrostars.nl).++The foundation founder is [Emma Kok](https://www.emmakok.nl).++On the 06/01/2024 there is Sophie's Kok, a sister of Emma Kok, 19th Birthday (she is 18). Therefore, the version 0.8.0.0 is additionally devoted also to her. On the 22/01/2023 there is Day of Unity of Ukraine, and on the 23/01/2024 the Orthodox Christians have memory of St. Paulinus of Nola.++On the 08/03/2024 there is International Women's Day.++Besides, you can support Ukraine and Ukrainian people. ++All support is welcome, including donations for the needs of the Ukrainian army, IDPs and refugees.++If you would like to share some financial support with Gastrostars, please, contact the mentioned foundation+using the URL:++[Contact Foundation GASTROSTARS](https://gastrostars.nl/hou-mij-op-de-hoogte)++or ++[Donation Page](https://gastrostars.nl/doneren)+
phonetic-languages-simplified-base.cabal view
@@ -3,10 +3,11 @@ -- http://haskell.org/cabal/users-guide/ name: phonetic-languages-simplified-base-version: 0.7.0.0+version: 0.9.0.0 synopsis: A basics of the phonetic-languages functionality that can be groupped.-description: The common for different realizations functionality. Just the necessary one.+description: The common for different realizations of PhLADiPreLiO functionality. Just the necessary one. homepage: https://hackage.haskell.org/package/phonetic-languages-simlified-base+bug-reports: https://github.com/Oleksandr-Zhabenko/phonetic-languages-simplified-base/issues license: MIT license-file: LICENSE author: OleksandrZhabenko@@ -14,13 +15,14 @@ copyright: Oleksandr Zhabenko category: Language,Math,Game build-type: Simple-extra-source-files: CHANGELOG.md+extra-source-files: CHANGELOG.md, README.md cabal-version: >=1.10 library- exposed-modules: Phladiprelio.DataG, Phladiprelio.StrictVG, Phladiprelio.Partir+ exposed-modules: Phladiprelio.DataG, Phladiprelio.StrictVG, Phladiprelio.Partir, Data.ChooseLine -- other-modules:- other-extensions: BangPatterns, FlexibleContexts, MultiParamTypeClasses, NoImplicitPrelude- build-depends: base >=4.13 && <5, subG ==0.6.1.0, phonetic-languages-permutations-array ==0.4.0.0, phonetic-languages-basis ==0.3.0.0+ -- ghc-options: -Wall+ other-extensions: BangPatterns, FlexibleContexts, MultiParamTypeClasses, NoImplicitPrelude, ScopedTypeVariables+ build-depends: base >=4.13 && <5, monoid-insertleft ==0.1.0.1, phonetic-languages-permutations-array ==0.5.0.0, phonetic-languages-basis ==0.3.0.0, minmax ==0.1.1.0 -- hs-source-dirs: default-language: Haskell2010