packages feed

phladiprelio-general-shared (empty) → 0.1.0.0

raw patch · 4 files changed

+184/−0 lines, 4 filesdep +basedep +phonetic-languages-phonetics-basics

Dependencies added: base, phonetic-languages-phonetics-basics

Files

+ CHANGELOG.md view
@@ -0,0 +1,6 @@+# Revision history for phladiprelio-general-shared++## 0.1.0.0 -- 2023-03-10++* First version. Released on an unsuspecting world.+
+ Phladiprelio/General/Parsing.hs view
@@ -0,0 +1,138 @@+{-# OPTIONS_GHC -threaded -rtsopts #-}+{-# OPTIONS_HADDOCK show-extensions #-}+{-# LANGUAGE BangPatterns, NoImplicitPrelude #-}++-- |+-- Module      :  Phladiprelio.General.Parsing+-- Copyright   :  (c) Oleksandr Zhabenko 2021-2023+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  oleksandr.zhabenko@yahoo.com+--+-- The additional parsing library functions for the lineVariantsG3 executable.+-- Is taken from the Phonetic.Languages.Parsing module from the+-- @phonetic-languages-simplified-examples-array@ package to reduce dependencies in general case.+-- ++module Phladiprelio.General.Parsing (+  -- * Predicates+  isClosingCurlyBracket+  , isSlash+  , isOpeningCurlyBracket+  , variations+  -- * Transformations+  , breakGroupOfStrings+  , breakInSlashes+  , combineVariants+  , combineHeadsWithNexts+  , transformToVariations+  -- * Files processment for specifications+  , readLangSpecs +  , innerProcessmentSimple+  , argsProcessment+) where++import GHC.Base+import GHC.List+import Phladiprelio.General.PrepareText+import System.Environment (getArgs)+import System.IO (FilePath, readFile)+import Data.List (sort,lines,unwords)+import GHC.Arr+import Phladiprelio.General.Base+import Phladiprelio.General.Syllables+import Text.Read (readMaybe,read)+import Data.Maybe (fromMaybe)+import Phladiprelio.General.SpecificationsRead++isClosingCurlyBracket :: String -> Bool+isClosingCurlyBracket = (== "}")++isSlash :: String -> Bool+isSlash (x:xs)+ | x /= '/' = False+ | null xs = True+ | otherwise = False+isSlash _ = False++isOpeningCurlyBracket :: String -> Bool+isOpeningCurlyBracket = (== "{")++breakGroupOfStrings :: [String] -> (([String],[[String]]),[String])+breakGroupOfStrings !xss = ((tss,breakInSlashes uss []), drop 1 zss)+  where (!yss,!zss) = break isClosingCurlyBracket xss+        (!tss,!uss) = (\(t1,t2) -> (t1,drop 1 t2)) . break isOpeningCurlyBracket $ yss++breakInSlashes :: [String] -> [[String]] -> [[String]]+breakInSlashes !wss !usss+ | null lss = kss : usss+ | otherwise = breakInSlashes (drop 1 lss) (kss : usss)+  where (!kss,!lss) = break isSlash wss++combineVariants :: ([String],[[String]]) -> [[String]]+combineVariants (!xss, (!yss:ysss)) = (xss `mappend` yss) : combineVariants (xss, ysss)+combineVariants _ = []++combineHeadsWithNexts :: [[String]] -> [String] -> [[String]]+combineHeadsWithNexts !xsss !yss+ | null yss = xsss+ | otherwise = combineHeadsWithNexts [xss `mappend` zss | xss <- xsss, zss <- zsss] uss+     where (!t,!uss) = breakGroupOfStrings yss+           !zsss = combineVariants t++transformToVariations :: [String] -> [[String]]+transformToVariations !yss+ | null yss = []+ | otherwise = combineHeadsWithNexts xsss tss+  where (!y,!tss) = breakGroupOfStrings yss+        !xsss = combineVariants y++variations :: [String] -> Bool+variations xss + | any isSlash xss = if any isOpeningCurlyBracket xss && any isClosingCurlyBracket xss then True else False+ | otherwise = False+++innerProcessmentSimple+  :: String -- ^ Must be a valid 'GWritingSystemPRPLX' specifications 'String' representation only (see the gwrsysExample.txt file in the @phonetic-languages-phonetics-basics@ package as a schema);+  -> String -- ^ Must be a 'String' 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;+  -> String -- ^ Must be a 'String' with the 'SegmentRulesG' specifications only;+  -> String -- ^ Must be a 'String' 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). These are to be prepended to the next word.+  -> String -- ^ Must be a 'String' 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). These are to be appended to the previous word.+  -> (GWritingSystemPRPLX, [(Char, Char)], CharPhoneticClassification, SegmentRulesG, String, String, Concatenations, Concatenations, String)+innerProcessmentSimple gwrsCnts controlConts segmentData concatenationsFileP concatenationsFileA =+ let [allophonesGs, charClfs, jss, vss, wss] = groupBetweenChars '~' . lines $ controlConts+     wrs = getGWritingSystem '~' gwrsCnts+     ks = sort . fromMaybe [] $ (readMaybe (unwords allophonesGs)::Maybe [(Char, Char)])+     arr = read (unwords charClfs)::Array Int PRS -- The 'Array' must be previously sorted in the ascending order.+     gs = read segmentData::SegmentRulesG+     ysss = sort2Concat . fromMaybe [] $ (readMaybe concatenationsFileP::Maybe [[String]])+     zzzsss = sort2Concat . fromMaybe [] $ (readMaybe concatenationsFileA::Maybe [[String]])+     js = concat jss+     vs = concat vss+     ws = sort . concat $ wss+       in (wrs, ks, arr, gs, js, vs, ysss, zzzsss, ws)++{-| -}+argsProcessment+ :: FilePath -- ^ With the 'GWritingSystemPRPLX' specifications only (see the gwrsysExample.txt file in the @phonetic-languages-phonetics-basics@ package as a schema);+ -> 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). These are to be prepended to the next word.+ -> 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). These are to be appended to the previous word.+ -> IO [String]+argsProcessment fileGWrSys controlFile segmentRulesFile concatenationsFileP concatenationsFileA = mapM readFile [controlFile, fileGWrSys, segmentRulesFile, concatenationsFileP, concatenationsFileA]++-- | The function that is mostly intended to be used by the end user. Reads the specifications from+-- the5 given files and returns the data that can be used further for generalized PhLADiPreLiO.+readLangSpecs + :: FilePath -- ^ With the 'GWritingSystemPRPLX' specifications only (see the gwrsysExample.txt file in the @phonetic-languages-phonetics-basics@ package as a schema);+ -> 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). These are to be prepended to the next word.+ -> 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). These are to be appended to the previous word.+ -> IO (GWritingSystemPRPLX, [(Char, Char)], CharPhoneticClassification, SegmentRulesG, String, String, Concatenations, Concatenations, String)+readLangSpecs  fileGWrSys controlFile segmentRulesFile concatenationsFileP concatenationsFileA = + argsProcessment fileGWrSys controlFile segmentRulesFile concatenationsFileP concatenationsFileA >>= \xss -> let [controlConts, gwrsCnts, segmentData, concatenationsFileP1, concatenationsFileA1] = xss in return $ innerProcessmentSimple gwrsCnts controlConts segmentData concatenationsFileP1 concatenationsFileA1 ++
+ README.md view
@@ -0,0 +1,8 @@+The module is intended to be used by both old and new projects related to PhLADiPreLiO.++P.S.: the author would like to devote this project to support the Fund GASTROSTARS.+If you would like to share some financial support, please, contact the fund+using the URL:++https://gastrostars.nl/hou-mij-op-de-hoogte+
+ phladiprelio-general-shared.cabal view
@@ -0,0 +1,32 @@+cabal-version:      2.4+name:               phladiprelio-general-shared+version:            0.1.0.0++-- A short (one-line) description of the package.+synopsis:           A shared by different general implementations of the PhLADiPreLiO functionality.++-- A longer description of the package.+description:        Is intended to be used by both old phonetic-languages-simplified-generalized-examples-array and new phladiprelio-general-simple packages.++-- A URL where users can report bugs.+-- bug-reports:++-- The license under which the package is released.+license:            MIT+author:             Oleksandr Zhabenko+maintainer:         oleksandr.zhabenko@yahoo.com++-- A copyright notice.+copyright:          Oleksandr Zhabenko+category:           Language, Math, Data+extra-source-files: CHANGELOG.md, README.md++library+    exposed-modules:  Phladiprelio.General.Parsing++    -- LANGUAGE extensions used by modules in this package.+    other-extensions: BangPatterns, NoImplicitPrelude+    build-depends:    base >=4.13 && <5, phonetic-languages-phonetics-basics ==0.10.0.2+    hs-source-dirs:   .+    default-language: Haskell2010+