packages feed

phonetic-languages-simplified-generalized-examples-array-0.6.2.0: Phonetic/Languages/Simplified/Array/General/FuncRep2RelatedG2.hs

-- |
-- Module      :  Phonetic.Languages.Simplified.Array.General.FuncRep2RelatedG2
-- Copyright   :  (c) OleksandrZhabenko 2020-2021
-- License     :  MIT
-- Stability   :  Experimental
-- Maintainer  :  olexandr543@yahoo.com
--
-- Functions to choose from the 'FuncRep2' variants for the general phonetic languages approach.

{-# LANGUAGE BangPatterns #-}

module Phonetic.Languages.Simplified.Array.General.FuncRep2RelatedG2 where

import CaseBi.Arr (getBFstL')
import Phonetic.Languages.Simplified.DataG.Base
import Phonetic.Languages.Array.General.PropertiesFuncRepG2
import Phonetic.Languages.Array.General.PropertiesSyllablesG2
import Data.Monoid (mappend)
import Data.Phonetic.Languages.Base
import Data.Phonetic.Languages.Syllables

-- | Allows to choose the variant of the computations in case of usual processment. The coefficient 1.3 (anyway, it must
-- be greater than 1.0) )is an empirical and approximate, you can use your own if you like.
chooseMax
  :: (Ord c) => 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 -- ^ The 'Array' 'Int' 'PRS' must be sorted in the ascending order to be used in the module correctly.
  -> 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)
  -> (Double -> String -> ([[[PRS]]] -> [[Double]])) -- ^ The function that is needed in the 'procRhythmicity23F' function.
 -- Specifies a way how the syllables represented in the phonetic language approach transforms into their durations and
 -- depends on two parameters.
  -> Coeffs2
  -> [([[[PRS]]] -> [[Double]])] -- ^ A list of 4 different functions that specifies the syllables durations, analogues of the
  -- syllableDurationsD functions from the @ukrainian-phonetics-basics-array@ package. The last one must be probably the most
  -- exact one and, therefore, the default one.
  -> String -- ^ Is intended to be one of the following strings: \"02y\", \"02z\", \"03y\", \"03z\", \"04y\", \"04z\",
 -- \"0y\", \"0z\", \"y\", \"y0\", \"y2\", \"y3\", \"y4\", \"yy\", \"yy2\", \"yy3\", \"z\", \"z2\", \"z3\", \"z4\",
 -- \"zz\", \"zz2\", \"zz3\", \"zz4\" or some other one (that is the default one). Since the 0.5.0.0 version
 -- you can use also \"w\" and \"x\"-based lines of properties. Specifies the applied properties
 -- to get the result. The \"z\"-line uses \'F\' functions. 
  -> FuncRep2 String Double c
chooseMax = chooseMaxG 1.3
{-# INLINE chooseMax #-}

-- | Allows to choose the variant of the computations in case of usual processment.
chooseMaxG
  :: (Ord c) => Double -- ^ Must be greater than 1.0 though it is not checked.
  -> 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 -- ^ The 'Array' 'Int' 'PRS' must be sorted in the ascending order to be used in the module correctly.
  -> 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)
  -> (Double -> String -> ([[[PRS]]] -> [[Double]])) -- ^ The function that is needed in the 'procRhythmicity23F' function.
 -- Specifies a way how the syllables represented in the phonetic language approach transforms into their durations and
 -- depends on two parameters.
  -> Coeffs2
  -> [([[[PRS]]] -> [[Double]])] -- ^ A list of 4 different functions that specifies the syllables durations, analogues of the
  -- syllableDurationsD functions from the @ukrainian-phonetics-basics-array@ package. The last one must be probably the most
  -- exact one and, therefore, the default one.
  -> String -- ^ Is intended to be one of the following strings: \"02y\", \"02z\", \"03y\", \"03z\", \"04y\", \"04z\",
 -- \"0y\", \"0z\", \"y\", \"y0\", \"y2\", \"y3\", \"y4\", \"yy\", \"yy2\", \"yy3\", \"z\", \"z2\", \"z3\", \"z4\",
 -- \"zz\", \"zz2\", \"zz3\", \"zz4\" or some other one (that is the default one). Since the 0.5.0.0 version
 -- you can use also \"w\" and \"x\"-based lines of properties. Specifies the applied properties
 -- to get the result. The \"z\"-line uses \'F\' functions.
 -- @ since 0.6.0.0 -- There is also the possibility to use \'line growing\' that is to use the 'prepereGrowTextMN' function
 -- with the 'Int' arguments from the first argument tuple. This allows to rearrange the given text and then
 -- to rewrite it.
 -- Besides there are new lines of the arguments for the 'String' argument that can begin with \"c\", \"s\", \"t\",
 -- \"u\", \"v\" letters. For more information, please, refer to the 'Phonetic.Languages.Array.Ukrainian.PropertiesSyllablesG2.rhythmicity'.
  -> FuncRep2 String Double c
chooseMaxG k wrs ks arr gs us vs g h coeffs xs choice
 | take 1 choice == "c" = procRhythmicity23F k g h choice coeffs wrs ks arr gs us vs
 | getBFstL' False (zip ["02y","02z","03y","03z","04y","04z","0y","0z","s01","s02","s03","s04",
     "s11","s12","s13","s14","s21","s22","s23","s24","s31","s32","s33","s34","s41","s42","s43","s44",
     "s51","s52","s53","s54","s61","s62","s63","s64","s71","s72","s74","t01","t02","t03","t04","t11",
     "t12","t13","t14","t21","t22","t23","t24","t31","t32","t33","t34","t41","t42","t43","t44","t51",
     "t52","t53","t54","t61","t62","t63","t64","t71","t72","t74","u01","u02","u03","u04","u11","u12",
     "u13","u14","u21","u22","u23","u24","u31","u32","u33","u34","u41","u42","u43","u44","u51","u52",
     "u53","u54","u61","u62","u63","u64","u71","u72","u74","v01","v02","v03","v04","v11","v12","v13",
     "v14","v21","v22","v23","v24","v31","v32","v33","v34","v41","v42","v43","v44","v51","v52","v53",
     "v54","v61","v62","v63","v64","v71","v72","v74","w01","w02","w03","w04","w11","w12","w13","w14",
     "w21","w22","w23","w24","w31","w32","w33","w34","x01","x02","x03","x04","x11","x12","x13","x14",
     "x21","x22","x23","x24","x31","x32","x33","x34"] . replicate 1000 $ True) choice =
        procRhythmicity23F k g h choice coeffs wrs ks arr gs us vs
 | otherwise = getBFstL' (procB2F wrs ks arr gs us vs g (xs !! 0) coeffs)
     [("y",procB2F wrs ks arr gs us vs g (xs !! 0) coeffs),
      ("y0",procDiverse2F wrs (' ':us `mappend` vs) g),
      ("y2",procB2F wrs ks arr gs us vs g (xs !! 1) coeffs),
      ("y3",procB2F wrs ks arr gs us vs g (xs !! 2) coeffs),
      ("y4",procB2F wrs ks arr gs us vs g (xs !! 3) coeffs),
      ("yy",procB2InvF wrs ks arr gs us vs g (xs !! 0) coeffs),
      ("yy2",procB2InvF wrs ks arr gs us vs g (xs !! 1) coeffs),
      ("yy3",procB2InvF wrs ks arr gs us vs g (xs !! 2) coeffs),
      ("z",procB2FF wrs ks arr gs us vs k g (xs !! 0) coeffs),
      ("z2",procB2FF wrs ks arr gs us vs k g (xs !! 1) coeffs),
      ("z3",procB2FF wrs ks arr gs us vs k g (xs !! 2) coeffs),
      ("z4",procB2FF wrs ks arr gs us vs k g (xs !! 3) coeffs),
      ("zz",procB2InvFF wrs ks arr gs us vs k g (xs !! 0) coeffs),
      ("zz2",procB2InvFF wrs ks arr gs us vs k g (xs !! 1) coeffs),
      ("zz3",procB2InvFF wrs ks arr gs us vs k g (xs !! 2) coeffs),
      ("zz4", procB2InvFF wrs ks arr gs us vs k g (xs !! 3) coeffs)] choice
 
-- | Allows to choose precision in the Numeric.showFDouble function being given a choice parameter.
precChoice
 :: String -- ^ Is intended to be one of the following strings: \"02y\", \"02z\", \"03y\", \"03z\", \"04y\", \"04z\",
 -- \"0y\", \"0z\", \"y\", \"y0\", \"y2\", \"y3\", \"y4\", \"yy\", \"yy2\", \"yy3\", \"z\", \"z2\", \"z3\", \"z4\",
 -- \"zz\", \"zz2\", \"zz3\", \"zz4\" or some other one (that is the default one). Since the 0.5.0.0 version
 -- you can use also \"w\" and \"x\"-based lines of properties. Specifies the applied properties
 -- to get the result. The \"z\"-line uses \'F\' functions.
 -- @ since 0.6.0.0 -- There is also the possibility to use \'line growing\' that is to use the 'prepereGrowTextMN' function
 -- with the 'Int' arguments from the first argument tuple. This allows to rearrange the given text and then
 -- to rewrite it.
 -- Besides there are new lines of the arguments for the 'String' argument that can begin with \"c\", \"s\", \"t\",
 -- \"u\", \"v\" letters. For more information, please, refer to the 'Phonetic.Languages.Array.Ukrainian.PropertiesSyllablesG2.rhythmicity'.
 -> Maybe Int
precChoice = getBFstL' (Just 4) [("02y",Just 0),("02z",Just 0),("03y",Just 0),("03z",Just 0),("04y",Just 0),
  ("04z",Just 0),("0y",Just 0),("0z",Just 0),("y",Just 0),("y0",Just 0),("y2",Just 0),("y3",Just 0), ("y4",Just 0),
    ("z",Just 0),("z0",Just 0),("z2",Just 0),("z3",Just 0), ("z4",Just 0)]