phladiprelio-general-simple 0.7.0.0 → 0.8.0.0
raw patch · 4 files changed
+90/−102 lines, 4 filesdep +phladiprelio-testsdep ~halfsplitdep ~rhythmic-sequencesPVP ok
version bump matches the API change (PVP)
Dependencies added: phladiprelio-tests
Dependency ranges changed: halfsplit, rhythmic-sequences
API changes (from Hackage documentation)
- Phladiprelio.General.Simple: generalF :: GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> ([[[PRS]]] -> [[Double]]) -> Int -> HashCorrections -> (Int8, [Int8]) -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> Bool -> [String] -> IO [String]
+ Phladiprelio.General.Simple: generalF :: (String, String) -> Int -> GWritingSystemPRPLX -> [(Char, Char)] -> CharPhoneticClassification -> SegmentRulesG -> String -> String -> ([[[PRS]]] -> [[Double]]) -> Int -> HashCorrections -> (Int8, [Int8]) -> Bool -> Int -> Bool -> Int8 -> (FilePath, Int) -> Bool -> String -> [String] -> IO [String]
Files
- CHANGELOG.md +12/−0
- Phladiprelio/General/Simple.hs +64/−97
- README.md +12/−3
- phladiprelio-general-simple.cabal +2/−2
CHANGELOG.md view
@@ -96,3 +96,15 @@ the possibility to calculate for the text with maximum 9 words or their combinations (using +x command line option). Added new draft papers with improved theory about the usage of the software. +## 0.7.0.1 -- 2023-07-30++* Seventh version revised A. Fixed some issues with documentation.++## 0.8.0.0 -- 2023-08-14++* Eighth version. Added the possibility for 2-syllable meter to print additional information about+points of incongruences of the line for +f group of command line arguments (using +f <filename for saving> <code> where code is in the range of (10..19) inclusively). +Added the possibility to work with multiline files as the input of the program on the per line basis using +m group+command line arguments. Moved the shared with phladiprelio-ukrainian-simple code to the new package +phladiprelio-tests to reduce code duplication. Updated the dependencies.+
Phladiprelio/General/Simple.hs view
@@ -12,7 +12,7 @@ import System.Environment (getArgs) import GHC.Num ((+),(-),(*),Integer) import Text.Read (readMaybe)-import System.IO (putStrLn, FilePath,stdout,universalNewlineMode,hSetNewlineMode,getLine,appendFile)+import System.IO (putStrLn, FilePath,stdout,universalNewlineMode,hSetNewlineMode,getLine,appendFile,readFile) import Rhythmicity.MarkerSeqs hiding (id) import Rhythmicity.BasicF import Data.List hiding (foldr)@@ -33,9 +33,12 @@ import System.Directory (doesFileExist,readable,writable,getPermissions,Permissions(..)) import Data.ReversedScientific import Control.Concurrent.Async (mapConcurrently)+import Phladiprelio.Tests generalF - :: GWritingSystemPRPLX -- ^ Data used to obtain the phonetic language representation of the text.+ :: (String, String) -- ^ If the next element is not equal to -1, then the prepending and appending lines to be displayed. Used basically for working with the multiline textual input data.+ -> Int -- ^ The number of the line in the file to be read the lines from. If equal to -1 then neither reading from the file is done nor the first argument influences the processment results.+ -> 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. -> CharPhoneticClassification -> SegmentRulesG@@ -51,13 +54,14 @@ -> Int8 -> (FilePath, Int) -> Bool -- ^ In the testing mode, whether to execute computations in concurrent mode (for speed up) or in single thread. If specified needs the executable to be compiled with -rtsopts and -threaded options and run with the command line +RTS -N -RTS options.+ -> String -- ^ An initial string to be analyzed. -> [String] -> IO [String] -generalF wrs ks arr gs us vs h numTest hc (grps,mxms) descending hashStep emptyline splitting (fs, code) concurrently universalSet +generalF (prestr,poststr) lineNmb wrs ks arr gs us vs h numTest hc (grps,mxms) descending hashStep emptyline splitting (fs, code) concurrently initstr 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+ let syllN = countSyll wrs arr us vs initstr -- universalSet = map unwords . permutations $ rss f grps mxms = sum . countHashes2G hashStep hc grps mxms . mconcat . h . createSyllablesPL wrs ks arr gs us vs hSetNewlineMode stdout universalNewlineMode@@ -77,93 +81,32 @@ _ <- mapM putStrLn strOutput let l1 = length sRepresent if code == -1 - then return strOutput- else parseLineNumber l1 >>= \num -> do+ then if lineNmb == -1 then return strOutput+ else do + print23 prestr poststr 1 [initstr]+ return strOutput+ else do + print23 prestr poststr 1 [initstr]+ 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)+ if writ && readab then do+ let lineOption = head . filter (\(S k _ ts) -> k == num) $ sRepresent+ textP = (\(S _ _ ts) -> ts) lineOption+ sylls = createSyllablesPL wrs ks arr gs us vs textP+ if code >= 10 && code <= 19 && grps == 2+ then do+ let structData = h . createSyllablesPL wrs ks arr gs us vs $ textP+ (breaks,rs) = showZerosFor2Period structData syllN (\(SylS c _) -> [c]) sylls+ putStrLn textP+ putStrLn breaks+ putStrLn . show $ rs+ appendFile fs ((if code >= 15 then (show rs `mappend` "\n" `mappend` breaks `mappend` "\n") else "") `mappend` outputSel lineOption code)+ else appendFile fs (outputSel lineOption code) 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.- | x == 2 || x == 5 = [[1],[2],[3],[4,3],[5,4],[6,5,4]]- | x == 7 = [[0],[1,0],[1,0],[1,0],[1,0],[1,0]]- | x == 8 = [[0],[1,0],[1,0],[2,1,0],[2,1,0],[2,1,0]]- | x == 9 = [[0],[1,0],[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]]------------------------------------------------------------------------------- | x >= 20 && x <= 26 && x /= 21 = [[1]] -- at least 7 is omitted, but probably 6, or even 5, or even 4, or even 3. 2 is however present.- | x >= 27 && x <= 29 = [[0]]- | x == 30 || x == 34 = [[1],[2,1]]- | x == 32 || x == 35 = [[1],[2]]- | x >= 37 && x <= 39 = [[0],[1,0]]- | x == 40 || x == 44 = [[1],[2,1],[3,2]]- | x == 42 || x == 45 = [[1],[2],[3]]- | x >= 47 && x <= 49 = [[0],[1,0],[1,0]]- | x == 50 || x == 54 = [[1],[2,1],[3,2],[4,3,2]]- | x == 52 || x == 55 = [[1],[2],[3],[4,3]]- | x == 57 = [[0],[1,0],[1,0],[1,0]]- | x == 58 || x == 59 = [[0],[1,0],[1,0],[2,1,0]]- | x == 60 || x == 64 = [[1],[2,1],[3,2],[4,3,2],[5,4,3]]- | x == 62 || x == 65 = [[1],[2],[3],[4,3],[5,4]]- | x == 67 = [[0],[1,0],[1,0],[1,0],[1,0]]- | x == 68 = [[0],[1,0],[1,0],[2,1,0],[2,1,0]]- | x == 69 = [[0],[1,0],[1,0],[2,1,0],[3,2,1,0]]------------------------------------------------------------------- | x == 70 || x == 74 = [[2,1],[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]] -- at least 2 is omitted, but probably 3 and even 4. 5, 6 and 7 are present.- | x == 72 || x == 75 = [[2],[3],[4,3],[5,4],[6,5,4]]- | x == 77 = [[1,0],[1,0],[1,0],[1,0],[1,0]]- | x == 78 = [[1,0],[1,0],[2,1,0],[2,1,0],[2,1,0]]- | x == 79 = [[1,0],[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]]- | x == 80 || x == 84 = [[3,2],[4,3,2],[5,4,3],[6,5,4,3,2]]- | x == 82 || x == 85 = [[3],[4,3],[5,4],[6,5,4]]- | x == 87 = [[1,0],[1,0],[1,0],[1,0]]- | x == 88 = [[1,0],[2,1,0],[2,1,0],[2,1,0]]- | x == 89 = [[1,0],[2,1,0],[3,2,1,0],[3,2,1,0]]- | x == 90 || x == 94 = [[4,3,2],[5,4,3],[6,5,4,3,2]]- | x == 92 || x == 95 = [[4,3],[5,4],[6,5,4]]- | x == 97 = [[1,0],[1,0],[1,0]]- | x == 98 = [[2,1,0],[2,1,0],[2,1,0]]- | x == 99 = [[2,1,0],[3,2,1,0],[3,2,1,0]]------------------------------------------------------------------------------------- | x == 100 || x == 104 = [[1],[2,1],[4,3,2],[6,5,4,3,2]] -- 4 and 6 are omitted, just present the ones from: 2, 3, 5, 7.- | x == 102 || x == 105 = [[1],[2],[4,3],[6,5,4]]- | x == 107 = [[0],[1,0],[1,0],[1,0]]- | x == 108 = [[0],[1,0],[2,1,0],[2,1,0]]- | x == 109 = [[0],[1,0],[2,1,0],[3,2,1,0]]------------------------------------------------------------------------------- | x == 150 || x == 154 = [[1],[2,1],[4,3,2]] -- 4, 6, 7 are omitted but 2, 3, 5 are present.- | x == 152 || x == 155 = [[1],[2],[4,3]]- | x == 157 = [[0],[1,0],[1,0]]- | x == 158 || x == 159 = [[0],[1,0],[2,1,0]]------------------------------------------------------------------- | x == 170 || x == 174 = [[2,1],[4,3,2],[6,5,4,3,2]] -- just 3, 5 and 7 are present- | x == 172 || x == 175 = [[2],[4,3],[6,5,4]]- | x == 177 = [[1,0],[1,0],[1,0]]- | x == 178 = [[1,0],[2,1,0],[2,1,0]]- | x == 179 = [[1,0],[2,1,0],[3,2,1,0]]----------------------------------------------------------------------------------- - | otherwise = [[1],[1],[2,1],[3,2,1],[3,2],[4,3,2]]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- sel2 y - | y == 1 || y < 0 || y > 179 = []- | (rem y 10 `elem` [1,3,6]) || y >= 0 && y <= 9 = [2..7]- | y >= 20 && y <= 69 = [2..toEnum (y `quot` 10)]- | y >= 70 && y <= 99 = [toEnum (y `quot` 10) - 4..7]- | y >= 100 && y <= 109 = [2,3,5,7]- | y >= 150 && y <= 159 = [2,3,5]- | y >= 170 && y <= 179 = [3,5,7]- | otherwise = [2..7]- minMax11ByCList :: Ord a => (a -> a -> Ordering) -> [a] -> (a, a) -- Is rewritten from the 'Data.MinMax.Preconditions.minMax11ByC' from @subG@ package.- minMax11ByCList g xs@(x:y:ys) = foldr f (if x > y then (y, x) else (x, y)) ys- where f z (x,y)- | g z x == LT = (z,y)- | 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+ where 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)@@ -199,11 +142,10 @@ 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"+ | code == 1 || code == 11 || code == 16 = intercalate " " [show x1, ts] `mappend` "\n"+ | code == 2 || code == 12 || code == 17 = intercalate " " [show y1, ts] `mappend` "\n"+ | code == 3 || code == 13 || code == 18 = intercalate " " [show x1, ts, show y1] `mappend` "\n"+ | code == 4 || code == 14 || code == 19 = intercalate " " [show x1, show y1] `mappend` "\n" | otherwise = ts `mappend` "\n" parseLineNumber :: Int -> IO Int@@ -238,24 +180,49 @@ (argsB, args11) = takeBsR bSpecs args prepare = any (== "-p") args11 emptyline = any (== "+l") args11 - argCs = catMaybes (fmap (readMaybeECG l) -- . (showB l lstW2:)- . getC "+a" $ argsC) splitting = fromMaybe 50 (readMaybe (concat . getB "+w" $ argsB)::Maybe Int8) concurrently = any (== "-C") args11 filedata = getB "+f" argsB- (filesave,codesave) + multiline2 = getB "+m" argsB+ (fileread,lineNmb)+ | null multiline2 = ("",-1)+ | length multiline2 == 2 = (head multiline2, fromMaybe 1 (readMaybe (last multiline2)::Maybe Int))+ | otherwise = (head multiline2, 1)+ (arg3s,prestr,poststr) <- do + if lineNmb /= -1 then do+ txtFromFile <- readFile fileread+ let lns = lines txtFromFile+ ln0 = max 1 (min lineNmb (length lns))+ ln_1 + | ln0 == 1 = 0+ | otherwise = ln0 - 1+ ln1+ | ln0 == length lns = 0+ | otherwise = ln0 + 1+ lineF = lns !! (ln0 - 1)+ line_1F + | ln_1 == 0 = []+ | otherwise = lns !! (ln_1 - 1)+ line1F+ | ln1 == 0 = []+ | otherwise = lns !! (ln1 - 1)+ return $ (words lineF, line_1F,line1F)+ else return (args11, [], [])+ let (filesave,codesave) | null filedata = ("",-1) | length filedata == 2 = (head filedata, fromMaybe 0 (readMaybe (last filedata)::Maybe Int)) | otherwise = (head filedata,0)- ll = take (if any (== "+x") args11 then 9 else 7) . (if prepare then id else words . mconcat . prepareText ysss zsss xs . unwords) $ args11+ ll = take (if any (== "+x") arg3s then 9 else 7) . (if prepare then id else words . mconcat . prepareText ysss zsss xs . unwords) $ arg3s l = length ll+ argCs = catMaybes (fmap (readMaybeECG l) -- . (showB l lstW2:)+ . getC "+a" $ argsC) 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 | not (null argCBs) = filterGeneralConv l argCBs . genPermutationsL $ l | 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 splitting (filesave, codesave) concurrently variants1 >> return ()+ generalF (prestr,poststr) lineNmb wrs ks arr gs us vs h numTest hc (grps,mxms) descending hashStep emptyline splitting (filesave, codesave) concurrently (unwords arg3s) variants1 >> return () -- | Specifies the group of the command line arguments for 'processingF', which specifies the -- PhLADiPreLiO constraints. For more information, see:@@ -264,4 +231,4 @@ cSpecs = zip ["+a","+b"] . cycle $ [-1] bSpecs :: CLSpecifications-bSpecs = [("+f",2), ("+w",1)]+bSpecs = [("+f",2), ("+w",1), ("+m",2)]
README.md view
@@ -9,8 +9,8 @@ [English documentation](https://oleksandrzhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.pdf) -The new documentation for the usage of the software package for Ukrainian language is by the-following links:+The new documentation for the usage of the software package for Ukrainian language (with noteworthy+information related to other languages as well) is by the following links: [English draft paper](https://www.academia.edu/105067761/Why_some_lines_are_easy_to_pronounce_and_others_are_not_or_prosodic_unpredictability_as_a_characteristic_of_text) @@ -21,6 +21,13 @@ [New implementation](https://oleksandr-zhabenko.github.io/uk/rhythmicity/phladiprelioEng.7.pdf) +The examples of the using the new functionality in the 0.8.0.0 version is in two short videos by+the links below (they are for the phladiprelio-ukrainian-simple, the parallel project for Ukranian):++[+f <filename> <code> mode additions](https://www.facebook.com/Oleksandr.S.Zhabenko/videos/593118766229253/)++[+m <another filename> <another code> mode — new one in this version](https://www.facebook.com/Oleksandr.S.Zhabenko/videos/325188039864718/)+ 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. @@ -49,7 +56,7 @@ Devotion ======== -The author would like to devote this project to support the Foundation GASTROSTARS. The releas+The author would like to devote this project to support the Foundation GASTROSTARS. The release version 0.7.0.0 is dedicated to Vico Kok. At the day of publication of the first version of the package (12/03/2023) there is@@ -74,6 +81,8 @@ On the 30/07/2023 there is the Birthday of Vico Kok and International Friendship Day. Therefore, the release version 0.7.0.0 is devoted to Vico Kok.++The version 0.8.0.0 is devoted to [Enzo Kok](https://enzokok.nl) who has Birthday on the 14/08/2023. 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.7.0.0+version: 0.8.0.0 -- A short (one-line) description of the package. synopsis: A generalized functionality of PhLADiPreLiO for different languages that uses hash algorithms.@@ -28,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.3.0, phonetic-languages-simplified-base ==0.7.1.0, halfsplit ==0.2.0.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >=2.2.2 && <3+ build-depends: base >=4.13 && <5, rhythmic-sequences ==0.4.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.1.0, halfsplit ==0.3.0.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >=2.2.2 && <3, phladiprelio-tests ==0.1.0.0 hs-source-dirs: . default-language: Haskell2010