packages feed

phonetic-languages-simplified-generalized-properties-array (empty) → 0.1.0.0

raw patch · 6 files changed

+490/−0 lines, 6 filesdep +basedep +phonetic-languages-phonetics-basicsdep +phonetic-languages-rhythmicitysetup-changed

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

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for phonetic-languages-simplified-generalized-properties-array++## 0.1.0.0 -- 2021-05-04++* First version. Released on an unsuspecting world. 
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2021 Oleksandr Zhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Phonetic/Languages/Array/General/PropertiesFuncRepG2.hs view
@@ -0,0 +1,226 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Phonetic.Languages.Array.General.PropertiesFuncRepG2+-- Copyright   :  (c) OleksandrZhabenko 2020-2021+-- 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.Simplified.Lists.UniquenessPeriodsG.Base+import Languages.Rhythmicity+import Languages.Rhythmicity.Factor+import Phonetic.Languages.Simplified.DataG.Base+import GHC.Float (int2Double)+import Data.Phonetic.Languages.Base+import Data.Phonetic.Languages.Syllables hiding (D)+import Data.Maybe (fromMaybe,mapMaybe)+--import Text.Read (readMaybe)++#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 wrs zs g = D (diverse2GL zs . map char . stringToXG wrs) 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 wrs zs g = D (int2Double . fromEnum . diverse2GL zs . map char . stringToXG wrs) g+{-# INLINE procDiverse2F #-}++--------------------------------------------------------------------------------------------++eval23Coeffs :: Coeffs2 -> [Double] -> Double+eval23Coeffs (CF2 x y) = evalRhythmicity23K (fromMaybe 1.0 x) (fromMaybe 1.0 y)+eval23Coeffs CF0 = evalRhythmicity23+{-# INLINE eval23Coeffs #-}++eval23CoeffsF :: Double -> Coeffs2 -> [Double] -> Double+eval23CoeffsF k (CF2 x y) = evalRhythmicity23KF k (fromMaybe 1.0 x) (fromMaybe 1.0 y)+eval23CoeffsF k CF0 = evalRhythmicity23F 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 wrs ks arr gs us vs h1 h g coeffs = D (\xs -> let ys = map char . stringToXG wrs . map (\x -> if x == '-' then ' ' else x) $ xs in+  ((int2Double . fromEnum . diverse2GL (' ':us ++ vs) $ ys)*(h1 . mconcat . g . map (divVwls . reSyllableCntnts ks gs . groupSnds .+    str2PRSs arr) . words1 . mapMaybe (f us vs) $ ys))) 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 wrs ks arr gs us vs h g coeffs = procB2FG wrs ks arr gs us vs (eval23Coeffs coeffs) h g 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 wrs ks arr gs us vs k h g coeffs = procB2FG wrs ks arr gs us vs (eval23CoeffsF k coeffs) h g 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 wrs ks arr gs us vs h1 h g coeffs = D (\xs ->+  let !ys = map char . stringToXG wrs . map (\x -> if x == '-' then ' ' else x) $ xs+      !z = diverse2GL (' ':us ++ vs) ys in if z == 0 then  (h1 . mconcat . g . map (divVwls . reSyllableCntnts ks gs . groupSnds .+         str2PRSs arr) . words1 . mapMaybe (f us vs) $ ys) ** 2.0+        else  ((h1 . mconcat . g . map (divVwls . reSyllableCntnts ks gs . groupSnds . str2PRSs arr) . words1 .+          mapMaybe (f us vs) $ ys) / (int2Double . fromEnum $ z))) 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 wrs ks arr gs us vs h g coeffs = procB2InvFG wrs ks arr gs us vs (eval23Coeffs coeffs) h g 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 wrs ks arr gs us vs k h g coeffs = procB2InvFG wrs ks arr gs us vs (eval23CoeffsF k coeffs) h g coeffs+{-# INLINE procB2InvFF #-}++---------------------------------------------------------------------++procRhythm23F+  :: (Ord c) => (Double -> c)+  -> String+  -> (String -> Coeffs2 -> String -> Double)+  -> Coeffs2+  -> FuncRep2 String Double c+procRhythm23F h choice g coeffs = D (g choice coeffs) 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 k g h choice coeffs wrs ks arr hs us vs = D (rhythmicity k choice h coeffs wrs ks arr hs us vs) g+{-# INLINE procRhythmicity23F #-}++-------------------------------------------------------------++f us vs x+  | x `elem` us = Nothing+  | x `notElem` vs = Just x+  | otherwise = Just ' '+{-# INLINE f #-}++words1 xs = if null ts then [] else w : words1 s'' -- Practically this is an optimized version for this case 'words' function from Prelude.+  where ts = dropWhile (== ' ') xs+        (w, s'') = span (/= ' ') ts+{-# NOINLINE words1 #-}
+ Phonetic/Languages/Array/General/PropertiesSyllablesG2.hs view
@@ -0,0 +1,211 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Phonetic.Languages.Array.General.PropertiesSyllablesG2+-- Copyright   :  (c) OleksandrZhabenko 2020-2021+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Generalization and extension of the functionality of the DobutokO.Poetry.Norms+-- and DobutokO.Poetry.Norms.Extended modules+-- from the @dobutokO-poetry@ package and more recent package @phonetic-languages-simplified-properties-array@.+-- Uses syllables information.+-- Instead of the vector-related, uses just arrays.+-- If you use the functionality of the Phonetic.Languages.Array.Ukrainian.PropertiesSyllablesG2 module,+-- then import it qualified (or this module) because they have many common data. Is provided as a standalone one+-- to reduce dependencies list in general case. ++{-# LANGUAGE CPP, BangPatterns #-}++module Phonetic.Languages.Array.General.PropertiesSyllablesG2 (+    -- * Newtype to work with+  CoeffTwo(..)+  , Coeffs2+  , isEmpty+  , isPair+  , fstCF+  , sndCF+  , readCF+  -- * Rhythmicity properties (semi-empirical)+  -- ** Simple one+  , rhythmicity0i+  , rhythmicity0Fi+  -- ** With weight coefficients+  , rhythmicityKi+  , rhythmicityKFi+  -- * General+  , rhythmicityG+  , rhythmicity+) 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 Languages.Rhythmicity+import Languages.Rhythmicity.Factor+import Data.Phonetic.Languages.Base+import Data.Phonetic.Languages.Syllables+import Data.Maybe (isNothing,fromMaybe)+import Text.Read (readMaybe)++#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__==708+/* code that applies only to GHC 7.8.* */+mconcat = concat+#endif+#endif++data CoeffTwo a = CF0 | CF2 (Maybe a) (Maybe a) deriving (Eq)++isEmpty :: CoeffTwo a -> Bool+isEmpty CF0 = True+isEmpty _ = False++isPair :: CoeffTwo a -> Bool+isPair CF0 = False+isPair _ = True++fstCF :: CoeffTwo a -> Maybe a+fstCF (CF2 x _) = x+fstCF _ = Nothing++sndCF :: CoeffTwo a -> Maybe a+sndCF (CF2 _ y) = y+sndCF _ = Nothing++readCF :: String -> Coeffs2+readCF xs+  | any (== '_') xs = let (!ys,!zs) = (\(ks,ts) -> (readMaybe ks::Maybe Double,readMaybe (drop 1 ts)::Maybe Double)) . break (== '_') $ xs in+     if (isNothing ys && isNothing zs) then CF0 else CF2 ys zs+  | otherwise = CF0++type Coeffs2 = CoeffTwo Double++--------------------------------------------------------------------------------------------++eval23 = evalRhythmicity23 . mconcat+{-# INLINE eval23 #-}++eval23K k2 k3 = evalRhythmicity23K k2 k3 . mconcat+{-# INLINE eval23K #-}++eval23F k = evalRhythmicity23F k . mconcat+{-# INLINE eval23F #-}++eval23KF k k2 k3 = evalRhythmicity23KF k k2 k3 . mconcat+{-# INLINE eval23KF #-}++rhythmicityG+  :: ([[[PRS]]] -> [[Double]])+  -> ([[Double]] -> Double)+  -> 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.+  -> String+  -> Double+rhythmicityG f g wrs ks arr hs us vs xs+ | null xs = 0.0+ | otherwise = g . f . createSyllablesPL wrs ks arr hs us vs $ xs+{-# INLINE rhythmicityG #-} ++-------------------------------------------------------++rhythmicity0i+  :: ([[[PRS]]] -> [[Double]])+  -> 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.+  -> String+  -> Double+rhythmicity0i f = rhythmicityG f eval23 +{-# INLINE rhythmicity0i #-}++-------------------------------------------------------++rhythmicityKi+  :: ([[[PRS]]] -> [[Double]])+  -> Double+  -> Double+  -> 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.+  -> String+  -> Double+rhythmicityKi f k2 k3 = rhythmicityG f (eval23K k2 k3)+{-# INLINE rhythmicityKi #-}++--------------------------------------------------------++rhythmicity0Fi+  :: ([[[PRS]]] -> [[Double]])+  -> Double+  -> 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.+  -> String+  -> Double+rhythmicity0Fi f k = rhythmicityG f (eval23F k)+{-# INLINE rhythmicity0Fi #-}++--------------------------------------------------------++rhythmicityKFi+  :: ([[[PRS]]] -> [[Double]])+  -> Double+  -> Double+  -> Double+  -> 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.+  -> String+  -> Double+rhythmicityKFi f k k2 k3 = rhythmicityG f (eval23KF k k2 k3)+{-# INLINE rhythmicityKFi #-}++--------------------------------------------------------++{-| It is intended to provide different functions :: 'Double' -> 'String' -> ([[['PRS']]] -> [['Double']]) for at least the+following values: \"0z\", \"02z\", \"03z\", \"04z\", \"0y\", \"02y\", \"03y\" and the default one for other variants.+The \"z\"-line uses \'F\' functions. +-}+rhythmicity+  :: Double+  -> String+  -> (Double -> String -> ([[[PRS]]] -> [[Double]]))+  -> Coeffs2+  -> GWritingSystemPRPLX+  -> [(Char,Char)]+  -> CharPhoneticClassification+  -> SegmentRulesG+  -> String+  -> String+  -> String+  -> Double+rhythmicity k choice h CF0+ | choice `elem` ["0z","02z","03z","04z"] = rhythmicity0Fi f k+ | otherwise = rhythmicity0i f+     where f = h k choice+rhythmicity k choice h (CF2 x y)+ | choice `elem` ["0z","02z","03z","04z"] = rhythmicityKFi f k (fromMaybe 1.0 x) (fromMaybe 1.0 y)+ | otherwise = rhythmicityKi f (fromMaybe 1.0 x) (fromMaybe 1.0 y)+     where f = h k choice
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ phonetic-languages-simplified-generalized-properties-array.cabal view
@@ -0,0 +1,26 @@+-- Initial phonetic-languages-simplified-generalized-properties-array.cabal+--  generated by cabal init.  For further documentation, see+-- http://haskell.org/cabal/users-guide/++name:                phonetic-languages-simplified-generalized-properties-array+version:             0.1.0.0+synopsis:            Generalization of the functionality of the phonetic-languages-simplified-properties-array.+description:         Is intended to be used with the general phonetic languages approach. +homepage:            https://hackage.haskell.org/package/phonetic-languages-simplified-generalized-properties-array+license:             MIT+license-file:        LICENSE+author:              Oleksandr Zhabenko+maintainer:          olexandr543@yahoo.com+copyright:           Oleksandr Zhabenko+category:            Language, Math, Game+build-type:          Simple+extra-source-files:  ChangeLog.md+cabal-version:       >=1.10++library+  exposed-modules:     Phonetic.Languages.Array.General.PropertiesFuncRepG2, Phonetic.Languages.Array.General.PropertiesSyllablesG2+  -- other-modules:+  other-extensions:    CPP, BangPatterns+  build-depends:       base >=4.8 && <4.15, phonetic-languages-simplified-base >=0.2 && <1, phonetic-languages-rhythmicity >=0.2 && <1, phonetic-languages-phonetics-basics >=0.6.0.1 && <1+  -- hs-source-dirs:+  default-language:    Haskell2010