{-# OPTIONS_HADDOCK show-extensions #-}

-- |
-- Module      :  Phonetic.Languages.Array.General.PropertiesFuncRepG2
-- Copyright   :  (c) OleksandrZhabenko 2020-2022
-- License     :  MIT
-- Stability   :  Experimental
-- Maintainer  :  olexandr543@yahoo.com
--
-- Generalization of the functionality of the DobutokO.Poetry.Norms
-- and DobutokO.Poetry.Norms.Extended modules
-- from the @dobutokO-poetry@ package and the recent module Phonetic.Languages.Array.General.PropertiesFuncRepG2
-- from the @phonetic-languages-simplified-properties-array@. If you import the module with the last one
-- module, please, use the qualified import, because of common names.
--
-- Instead of vectors, uses arrays.

{-# LANGUAGE CPP, BangPatterns #-}

module Phonetic.Languages.Array.General.PropertiesFuncRepG2 (
  -- * Functions with 'Int16'
  procDiverse2I
  -- * Functions with 'Double'
  , procB2FG
  , procB2F
  , procB2FF
  , procB2InvFG
  , procB2InvF
  , procB2InvFF
  , procRhythm23F
  , procDiverse2F
  -- * Working with rhythmicity
  , procRhythmicity23F
) where

#ifdef __GLASGOW_HASKELL__
#if __GLASGOW_HASKELL__>=710
/* code that applies only to GHC 7.10.* and higher versions */
import GHC.Base (mconcat)
#endif
#endif
import GHC.Int
import Phonetic.Languages.Array.General.PropertiesSyllablesG2
import Phonetic.Languages.UniquenessPeriodsG
import Languages.Rhythmicity
import Languages.Rhythmicity.Factor
import Phonetic.Languages.Basis
import GHC.Float (int2Double)
import Data.Phonetic.Languages.Base
import Data.Phonetic.Languages.Syllables hiding (D)
import Data.Maybe (fromMaybe,mapMaybe)
import Data.Monoid (mappend)

#ifdef __GLASGOW_HASKELL__
#if __GLASGOW_HASKELL__==708
/* code that applies only to GHC 7.8.* */
mconcat = concat
#endif
#endif

procDiverse2I
  :: (Ord c) => GWritingSystemPRPLX
  -> String -- ^ Actually is the \' \':us ++ vs in the following functions where in the definition is us and vs 'String's. See the
  -- source code of the module.
  -> (Int16 -> c)
  -> FuncRep2 String Int16 c
procDiverse2I :: GWritingSystemPRPLX
-> String -> (Int16 -> c) -> FuncRep2 String Int16 c
procDiverse2I GWritingSystemPRPLX
wrs String
zs Int16 -> c
g = (String -> Int16) -> (Int16 -> c) -> FuncRep2 String Int16 c
forall a b c. (a -> b) -> (b -> c) -> FuncRep2 a b c
D (String -> String -> Int16
forall (t :: * -> *). Foldable t => String -> t Char -> Int16
diverse2GL String
zs (String -> Int16) -> (String -> String) -> String -> Int16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PhoneticsRepresentationPLX -> String)
-> [PhoneticsRepresentationPLX] -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap PhoneticsRepresentationPLX -> String
string1 ([PhoneticsRepresentationPLX] -> String)
-> (String -> [PhoneticsRepresentationPLX]) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GWritingSystemPRPLX -> String -> [PhoneticsRepresentationPLX]
stringToXG GWritingSystemPRPLX
wrs) Int16 -> c
g
{-# INLINE procDiverse2I #-}

procDiverse2F
  :: (Ord c) => GWritingSystemPRPLX
  -> String -- ^ Actually is the \' \':us ++ vs in the following functions where in the definition is us and vs 'String's. See the
  -- source code of the module.
  -> (Double -> c)
  -> FuncRep2 String Double c
procDiverse2F :: GWritingSystemPRPLX
-> String -> (Double -> c) -> FuncRep2 String Double c
procDiverse2F GWritingSystemPRPLX
wrs String
zs Double -> c
g = (String -> Double) -> (Double -> c) -> FuncRep2 String Double c
forall a b c. (a -> b) -> (b -> c) -> FuncRep2 a b c
D (Int -> Double
int2Double (Int -> Double) -> (String -> Int) -> String -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int16 -> Int
forall a. Enum a => a -> Int
fromEnum (Int16 -> Int) -> (String -> Int16) -> String -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> Int16
forall (t :: * -> *). Foldable t => String -> t Char -> Int16
diverse2GL String
zs (String -> Int16) -> (String -> String) -> String -> Int16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PhoneticsRepresentationPLX -> String)
-> [PhoneticsRepresentationPLX] -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap PhoneticsRepresentationPLX -> String
string1 ([PhoneticsRepresentationPLX] -> String)
-> (String -> [PhoneticsRepresentationPLX]) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GWritingSystemPRPLX -> String -> [PhoneticsRepresentationPLX]
stringToXG GWritingSystemPRPLX
wrs) Double -> c
g
{-# INLINE procDiverse2F #-}

--------------------------------------------------------------------------------------------

eval23Coeffs :: Coeffs2 -> [Double] -> Double
eval23Coeffs :: Coeffs2 -> [Double] -> Double
eval23Coeffs (CF2 Maybe Double
x Maybe Double
y) = Double -> Double -> [Double] -> Double
forall a. (RealFrac a, Floating a) => a -> a -> [a] -> a
evalRhythmicity23K (Double -> Maybe Double -> Double
forall a. a -> Maybe a -> a
fromMaybe Double
1.0 Maybe Double
x) (Double -> Maybe Double -> Double
forall a. a -> Maybe a -> a
fromMaybe Double
1.0 Maybe Double
y)
eval23Coeffs Coeffs2
CF0 = [Double] -> Double
forall a. (RealFrac a, Floating a) => [a] -> a
evalRhythmicity23
{-# INLINE eval23Coeffs #-}

eval23CoeffsF :: Double -> Coeffs2 -> [Double] -> Double
eval23CoeffsF :: Double -> Coeffs2 -> [Double] -> Double
eval23CoeffsF Double
k (CF2 Maybe Double
x Maybe Double
y) = Double -> Double -> Double -> [Double] -> Double
forall a. (RealFrac a, Floating a) => a -> a -> a -> [a] -> a
evalRhythmicity23KF Double
k (Double -> Maybe Double -> Double
forall a. a -> Maybe a -> a
fromMaybe Double
1.0 Maybe Double
x) (Double -> Maybe Double -> Double
forall a. a -> Maybe a -> a
fromMaybe Double
1.0 Maybe Double
y)
eval23CoeffsF Double
k Coeffs2
CF0 = Double -> [Double] -> Double
forall a. (RealFrac a, Floating a) => a -> [a] -> a
evalRhythmicity23F Double
k
{-# INLINE eval23CoeffsF #-}

-------------------------------------------------------------------------------------------

procB2FG
  :: (Ord c) =>  GWritingSystemPRPLX
  -> [(Char,Char)]
  -> CharPhoneticClassification
  -> SegmentRulesG
  -> String -- ^ Corresponds to the \'0\' symbol delimiter in the @ukrainian-phonetics-basic-array@ package.
  -> String -- ^ Corresponds to the \'1\' and \'-\' symbol delimiters in the @ukrainian-phonetics-basic-array@ package.
  -> ([Double] -> Double)
  -> (Double -> c)
  -> ([[[PRS]]] -> [[Double]])
  -> Coeffs2
  -> FuncRep2 String Double c
procB2FG :: GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2FG GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs [Double] -> Double
h1 Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs = let zs :: String
zs = Char
' 'Char -> String -> String
forall a. a -> [a] -> [a]
:String
us String -> String -> String
forall a. Monoid a => a -> a -> a
`mappend` String
vs in (String -> Double) -> (Double -> c) -> FuncRep2 String Double c
forall a b c. (a -> b) -> (b -> c) -> FuncRep2 a b c
D (\String
xs -> let ys :: String
ys = (PhoneticsRepresentationPLX -> String)
-> [PhoneticsRepresentationPLX] -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap PhoneticsRepresentationPLX -> String
string1 ([PhoneticsRepresentationPLX] -> String)
-> (String -> [PhoneticsRepresentationPLX]) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GWritingSystemPRPLX -> String -> [PhoneticsRepresentationPLX]
stringToXG GWritingSystemPRPLX
wrs (String -> [PhoneticsRepresentationPLX])
-> (String -> String) -> String -> [PhoneticsRepresentationPLX]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map (\Char
x -> if Char
x Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'-' then Char
' ' else Char
x) (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String
xs in
  ((Int -> Double
int2Double (Int -> Double) -> (String -> Int) -> String -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int16 -> Int
forall a. Enum a => a -> Int
fromEnum (Int16 -> Int) -> (String -> Int16) -> String -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> Int16
forall (t :: * -> *). Foldable t => String -> t Char -> Int16
diverse2GL String
zs (String -> Double) -> String -> Double
forall a b. (a -> b) -> a -> b
$ String
ys)Double -> Double -> Double
forall a. Num a => a -> a -> a
*([Double] -> Double
h1 ([Double] -> Double) -> (String -> [Double]) -> String -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Double]] -> [Double]
forall a. Monoid a => [a] -> a
mconcat ([[Double]] -> [Double])
-> (String -> [[Double]]) -> String -> [Double]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[[PRS]]] -> [[Double]]
g ([[[PRS]]] -> [[Double]])
-> (String -> [[[PRS]]]) -> String -> [[Double]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [[PRS]]) -> [String] -> [[[PRS]]]
forall a b. (a -> b) -> [a] -> [b]
map ([[PRS]] -> [[PRS]]
divSylls ([[PRS]] -> [[PRS]]) -> (String -> [[PRS]]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Char, Char)] -> SegmentRulesG -> [[PRS]] -> [[PRS]]
reSyllableCntnts [(Char, Char)]
ks SegmentRulesG
gs ([[PRS]] -> [[PRS]]) -> (String -> [[PRS]]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PRS] -> [[PRS]]
groupSnds ([PRS] -> [[PRS]]) -> (String -> [PRS]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    CharPhoneticClassification -> String -> [PRS]
str2PRSs CharPhoneticClassification
arr) ([String] -> [[[PRS]]])
-> (String -> [String]) -> String -> [[[PRS]]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
words1 (String -> [String]) -> (String -> String) -> String -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Maybe Char) -> String -> String
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (String -> String -> Char -> Maybe Char
forall (t :: * -> *) (t :: * -> *).
(Foldable t, Foldable t) =>
t Char -> t Char -> Char -> Maybe Char
f String
us String
vs) (String -> Double) -> String -> Double
forall a b. (a -> b) -> a -> b
$ String
ys))) Double -> c
h
{-# INLINE procB2FG #-}

procB2F
  :: (Ord c) =>  GWritingSystemPRPLX
  -> [(Char,Char)]
  -> CharPhoneticClassification
  -> SegmentRulesG
  -> String -- ^ Corresponds to the \'0\' symbol delimiter in the @ukrainian-phonetics-basic-array@ package.
  -> String -- ^ Corresponds to the \'1\' and \'-\' symbol delimiters in the @ukrainian-phonetics-basic-array@ package.
  -> (Double -> c)
  -> ([[[PRS]]] -> [[Double]])
  -> Coeffs2
  -> FuncRep2 String Double c
procB2F :: GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2F GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs = GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
forall c.
Ord c =>
GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2FG GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs (Coeffs2 -> [Double] -> Double
eval23Coeffs Coeffs2
coeffs) Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs
{-# INLINE procB2F #-}

procB2FF
  :: (Ord c) =>  GWritingSystemPRPLX
  -> [(Char,Char)]
  -> CharPhoneticClassification
  -> SegmentRulesG
  -> String -- ^ Corresponds to the \'0\' symbol delimiter in the @ukrainian-phonetics-basic-array@ package.
  -> String -- ^ Corresponds to the \'1\' and \'-\' symbol delimiters in the @ukrainian-phonetics-basic-array@ package.
  -> Double 
  -> (Double -> c)
  -> ([[[PRS]]] -> [[Double]])
  -> Coeffs2
  -> FuncRep2 String Double c
procB2FF :: GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> Double
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2FF GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs Double
k Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs = GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
forall c.
Ord c =>
GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2FG GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs (Double -> Coeffs2 -> [Double] -> Double
eval23CoeffsF Double
k Coeffs2
coeffs) Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs
{-# INLINE procB2FF #-}

procB2InvFG
  :: (Ord c) =>  GWritingSystemPRPLX
  -> [(Char,Char)]
  -> CharPhoneticClassification
  -> SegmentRulesG
  -> String -- ^ Corresponds to the \'0\' symbol delimiter in the @ukrainian-phonetics-basic-array@ package.
  -> String -- ^ Corresponds to the \'1\' and \'-\' symbol delimiters in the @ukrainian-phonetics-basic-array@ package.
  -> ([Double] -> Double)
  -> (Double -> c)
  -> ([[[PRS]]] -> [[Double]])
  -> Coeffs2
  -> FuncRep2 String Double c
procB2InvFG :: GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2InvFG GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs [Double] -> Double
h1 Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs = let zs :: String
zs = Char
' 'Char -> String -> String
forall a. a -> [a] -> [a]
:String
us String -> String -> String
forall a. Monoid a => a -> a -> a
`mappend` String
vs in (String -> Double) -> (Double -> c) -> FuncRep2 String Double c
forall a b c. (a -> b) -> (b -> c) -> FuncRep2 a b c
D (\String
xs ->
  let !ys :: String
ys = (PhoneticsRepresentationPLX -> String)
-> [PhoneticsRepresentationPLX] -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap PhoneticsRepresentationPLX -> String
string1 ([PhoneticsRepresentationPLX] -> String)
-> (String -> [PhoneticsRepresentationPLX]) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GWritingSystemPRPLX -> String -> [PhoneticsRepresentationPLX]
stringToXG GWritingSystemPRPLX
wrs (String -> [PhoneticsRepresentationPLX])
-> (String -> String) -> String -> [PhoneticsRepresentationPLX]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map (\Char
x -> if Char
x Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'-' then Char
' ' else Char
x) (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String
xs
      !z :: Int16
z = String -> String -> Int16
forall (t :: * -> *). Foldable t => String -> t Char -> Int16
diverse2GL String
zs String
ys in if Int16
z Int16 -> Int16 -> Bool
forall a. Eq a => a -> a -> Bool
== Int16
0 then  ([Double] -> Double
h1 ([Double] -> Double) -> (String -> [Double]) -> String -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Double]] -> [Double]
forall a. Monoid a => [a] -> a
mconcat ([[Double]] -> [Double])
-> (String -> [[Double]]) -> String -> [Double]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[[PRS]]] -> [[Double]]
g ([[[PRS]]] -> [[Double]])
-> (String -> [[[PRS]]]) -> String -> [[Double]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [[PRS]]) -> [String] -> [[[PRS]]]
forall a b. (a -> b) -> [a] -> [b]
map ([[PRS]] -> [[PRS]]
divSylls ([[PRS]] -> [[PRS]]) -> (String -> [[PRS]]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Char, Char)] -> SegmentRulesG -> [[PRS]] -> [[PRS]]
reSyllableCntnts [(Char, Char)]
ks SegmentRulesG
gs ([[PRS]] -> [[PRS]]) -> (String -> [[PRS]]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PRS] -> [[PRS]]
groupSnds ([PRS] -> [[PRS]]) -> (String -> [PRS]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
         CharPhoneticClassification -> String -> [PRS]
str2PRSs CharPhoneticClassification
arr) ([String] -> [[[PRS]]])
-> (String -> [String]) -> String -> [[[PRS]]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
words1 (String -> [String]) -> (String -> String) -> String -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Maybe Char) -> String -> String
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (String -> String -> Char -> Maybe Char
forall (t :: * -> *) (t :: * -> *).
(Foldable t, Foldable t) =>
t Char -> t Char -> Char -> Maybe Char
f String
us String
vs) (String -> Double) -> String -> Double
forall a b. (a -> b) -> a -> b
$ String
ys) Double -> Double -> Double
forall a. Floating a => a -> a -> a
** Double
2.0
        else  (([Double] -> Double
h1 ([Double] -> Double) -> (String -> [Double]) -> String -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Double]] -> [Double]
forall a. Monoid a => [a] -> a
mconcat ([[Double]] -> [Double])
-> (String -> [[Double]]) -> String -> [Double]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[[PRS]]] -> [[Double]]
g ([[[PRS]]] -> [[Double]])
-> (String -> [[[PRS]]]) -> String -> [[Double]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> [[PRS]]) -> [String] -> [[[PRS]]]
forall a b. (a -> b) -> [a] -> [b]
map ([[PRS]] -> [[PRS]]
divSylls ([[PRS]] -> [[PRS]]) -> (String -> [[PRS]]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Char, Char)] -> SegmentRulesG -> [[PRS]] -> [[PRS]]
reSyllableCntnts [(Char, Char)]
ks SegmentRulesG
gs ([[PRS]] -> [[PRS]]) -> (String -> [[PRS]]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PRS] -> [[PRS]]
groupSnds ([PRS] -> [[PRS]]) -> (String -> [PRS]) -> String -> [[PRS]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharPhoneticClassification -> String -> [PRS]
str2PRSs CharPhoneticClassification
arr) ([String] -> [[[PRS]]])
-> (String -> [String]) -> String -> [[[PRS]]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
words1 (String -> [String]) -> (String -> String) -> String -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
          (Char -> Maybe Char) -> String -> String
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (String -> String -> Char -> Maybe Char
forall (t :: * -> *) (t :: * -> *).
(Foldable t, Foldable t) =>
t Char -> t Char -> Char -> Maybe Char
f String
us String
vs) (String -> Double) -> String -> Double
forall a b. (a -> b) -> a -> b
$ String
ys) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Int -> Double
int2Double (Int -> Double) -> (Int16 -> Int) -> Int16 -> Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int16 -> Int
forall a. Enum a => a -> Int
fromEnum (Int16 -> Double) -> Int16 -> Double
forall a b. (a -> b) -> a -> b
$ Int16
z))) Double -> c
h
{-# INLINE procB2InvFG #-}

procB2InvF
  :: (Ord c) =>  GWritingSystemPRPLX
  -> [(Char,Char)]
  -> CharPhoneticClassification
  -> SegmentRulesG
  -> String -- ^ Corresponds to the \'0\' symbol delimiter in the @ukrainian-phonetics-basic-array@ package.
  -> String -- ^ Corresponds to the \'1\' and \'-\' symbol delimiters in the @ukrainian-phonetics-basic-array@ package.
  -> (Double -> c)
  -> ([[[PRS]]] -> [[Double]])
  -> Coeffs2
  -> FuncRep2 String Double c
procB2InvF :: GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2InvF GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs = GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
forall c.
Ord c =>
GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2InvFG GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs (Coeffs2 -> [Double] -> Double
eval23Coeffs Coeffs2
coeffs) Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs
{-# INLINE procB2InvF #-}

procB2InvFF
  :: (Ord c) =>  GWritingSystemPRPLX
  -> [(Char,Char)]
  -> CharPhoneticClassification
  -> SegmentRulesG
  -> String -- ^ Corresponds to the \'0\' symbol delimiter in the @ukrainian-phonetics-basic-array@ package.
  -> String -- ^ Corresponds to the \'1\' and \'-\' symbol delimiters in the @ukrainian-phonetics-basic-array@ package.
  -> Double
  -> (Double -> c)
  -> ([[[PRS]]] -> [[Double]])
  -> Coeffs2
  -> FuncRep2 String Double c
procB2InvFF :: GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> Double
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2InvFF GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs Double
k Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs = GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
forall c.
Ord c =>
GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> ([Double] -> Double)
-> (Double -> c)
-> ([[[PRS]]] -> [[Double]])
-> Coeffs2
-> FuncRep2 String Double c
procB2InvFG GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
gs String
us String
vs (Double -> Coeffs2 -> [Double] -> Double
eval23CoeffsF Double
k Coeffs2
coeffs) Double -> c
h [[[PRS]]] -> [[Double]]
g Coeffs2
coeffs
{-# INLINE procB2InvFF #-}

---------------------------------------------------------------------

procRhythm23F
  :: (Ord c) => (Double -> c)
  -> String
  -> (String -> Coeffs2 -> String -> Double)
  -> Coeffs2
  -> FuncRep2 String Double c
procRhythm23F :: (Double -> c)
-> String
-> (String -> Coeffs2 -> String -> Double)
-> Coeffs2
-> FuncRep2 String Double c
procRhythm23F Double -> c
h String
choice String -> Coeffs2 -> String -> Double
g Coeffs2
coeffs = (String -> Double) -> (Double -> c) -> FuncRep2 String Double c
forall a b c. (a -> b) -> (b -> c) -> FuncRep2 a b c
D (String -> Coeffs2 -> String -> Double
g String
choice Coeffs2
coeffs) Double -> c
h
{-# INLINE procRhythm23F #-}

procRhythmicity23F
  :: (Ord c) => Double
  -> (Double -> c)
  -> (Double -> String -> ([[[PRS]]] -> [[Double]]))
  -> String
  -> Coeffs2
  -> GWritingSystemPRPLX
  -> [(Char,Char)]
  -> CharPhoneticClassification
  -> SegmentRulesG
  -> String -- ^ Corresponds to the \'0\' symbol delimiter in the @ukrainian-phonetics-basic-array@ package.
  -> String -- ^ Corresponds to the \'1\' and \'-\' symbol delimiters in the @ukrainian-phonetics-basic-array@ package.
  -> FuncRep2 String Double c
procRhythmicity23F :: Double
-> (Double -> c)
-> (Double -> String -> [[[PRS]]] -> [[Double]])
-> String
-> Coeffs2
-> GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> FuncRep2 String Double c
procRhythmicity23F Double
k Double -> c
g Double -> String -> [[[PRS]]] -> [[Double]]
h String
choice Coeffs2
coeffs GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
hs String
us String
vs = (String -> Double) -> (Double -> c) -> FuncRep2 String Double c
forall a b c. (a -> b) -> (b -> c) -> FuncRep2 a b c
D (Double
-> String
-> (Double -> String -> [[[PRS]]] -> [[Double]])
-> Coeffs2
-> GWritingSystemPRPLX
-> [(Char, Char)]
-> CharPhoneticClassification
-> SegmentRulesG
-> String
-> String
-> String
-> Double
rhythmicity Double
k String
choice Double -> String -> [[[PRS]]] -> [[Double]]
h Coeffs2
coeffs GWritingSystemPRPLX
wrs [(Char, Char)]
ks CharPhoneticClassification
arr SegmentRulesG
hs String
us String
vs) Double -> c
g
{-# INLINE procRhythmicity23F #-}

-------------------------------------------------------------

f :: t Char -> t Char -> Char -> Maybe Char
f t Char
us t Char
vs Char
x
  | Char
x Char -> t Char -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` t Char
us = Maybe Char
forall a. Maybe a
Nothing
  | Char
x Char -> t Char -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` t Char
vs = Char -> Maybe Char
forall a. a -> Maybe a
Just Char
x
  | Bool
otherwise = Char -> Maybe Char
forall a. a -> Maybe a
Just Char
' '
{-# INLINE f #-}

words1 :: String -> [String]
words1 String
xs = if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
ts then [] else String
w String -> [String] -> [String]
forall a. a -> [a] -> [a]
: String -> [String]
words1 String
s'' -- Practically this is an optimized version for this case 'words' function from Prelude.
  where ts :: String
ts = (Char -> Bool) -> String -> String
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
' ') String
xs
        (String
w, String
s'') = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
' ') String
ts
{-# NOINLINE words1 #-}