packages feed

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

raw patch · 6 files changed

+367/−0 lines, 6 filesdep +basedep +phonetic-languages-rhythmicitydep +phonetic-languages-simplified-basesetup-changed

Dependencies added: base, phonetic-languages-rhythmicity, phonetic-languages-simplified-base, ukrainian-phonetics-basic-array

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for phonetic-languages-simplified-properties-array++## 0.1.0.0 -- 2020-12-31++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2020 OleksandrZhabenko++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/Ukrainian/PropertiesFuncRepG2.hs view
@@ -0,0 +1,172 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Phonetic.Languages.Array.Ukrainian.PropertiesFuncRepG2+-- Copyright   :  (c) OleksandrZhabenko 2020+-- 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. Instead of vectors, uses arrays.++{-# LANGUAGE CPP, BangPatterns #-}++module Phonetic.Languages.Array.Ukrainian.PropertiesFuncRepG2 (+  -- * Functions with 'Int16'+  procDiverse2I+  -- * Functions with 'Float'+  , procDiverse2F+  , procBothF+  , procBothInvF+  -- ** Working with generated by r-glpk-phonetic-languages-ukrainian-durations syllable durations+  , procBoth2F+  , procBoth2InvF+  -- ** NEW Working with generated by r-glpk-phonetic-languages-ukrainian-durations syllable durations+  , procBoth3F+  , procBoth3InvF+  -- * 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.Ukrainian.PropertiesSyllablesG2+import Phonetic.Languages.Simplified.Lists.UniquenessPeriodsG.Base+import Languages.Rhythmicity+import Phonetic.Languages.Simplified.DataG.Base+import GHC.Float (int2Double)+import Melodics.ByteString.Ukrainian.Arr+import qualified Languages.Phonetic.Ukrainian.Syllable.Double.Arr as SD+import qualified Languages.Phonetic.Ukrainian.Syllable.Arr as S+import Data.Maybe (isNothing,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) => (Int16 -> c)+  -> FuncRep2 String Int16 c+procDiverse2I g = D (diverse2GL " 01-" . convertToProperUkrainianS) g+{-# INLINE procDiverse2I #-}++procDiverse2F+  :: (Ord c) => (Double -> c)+  -> FuncRep2 String Double c+procDiverse2F g = D (int2Double . fromEnum . diverse2GL " 01-" . convertToProperUkrainianS) g+{-# INLINE procDiverse2F #-}++--------------------------------------------------------------------------------------------++procRhythmicity23F+  :: (Ord c) => (Double -> c)+  -> String+  -> Coeffs2+  -> FuncRep2 String Double c+procRhythmicity23F g choice coeffs = procRhythm23F g choice rhythmicity coeffs+{-# INLINE procRhythmicity23F #-}++procBothF+  :: (Ord c) => (Double -> c)+  -> Coeffs2+  -> FuncRep2 String Double c+procBothF g coeffs  = procB2F g SD.syllableDurationsD coeffs+{-# INLINE procBothF #-}++procBothInvF+  :: (Ord c) => (Double -> c)+  -> Coeffs2+  -> FuncRep2 String Double c+procBothInvF g coeffs  = procB2InvF g SD.syllableDurationsD coeffs+{-# INLINE procBothInvF #-}++-------------------------------------------------------------------------------++procBoth2F+  :: (Ord c) => (Double -> c)+  -> Coeffs2+  -> FuncRep2 String Double c+procBoth2F g coeffs  = procB2F g SD.syllableDurationsD2 coeffs+{-# INLINE procBoth2F #-}++procBoth2InvF+  :: (Ord c) => (Double -> c)+  -> Coeffs2+  -> FuncRep2 String Double c+procBoth2InvF g coeffs  = procB2InvF g SD.syllableDurationsD2 coeffs+{-# INLINE procBoth2InvF #-}++-------------------------------------------------------------++eval23Coeffs :: Coeffs2 -> [Double] -> Double+eval23Coeffs (CF2 x y) = evalRhythmicity23K (fromMaybe 1.0 x) (fromMaybe 1.0 y)+eval23Coeffs CF0 = evalRhythmicity23++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 #-}++procB2F+  :: (Ord c) => (Double -> c)+  -> ([[[S.UZPP2]]] -> [[Double]])+  -> Coeffs2+  -> FuncRep2 String Double c+procB2F h g coeffs = D (\xs -> let ys = convertToProperUkrainianS . map (\x -> if x == '-' then ' ' else x) $ xs in  ((int2Double . fromEnum . diverse2GL " 01-" $ ys)*(eval23Coeffs coeffs . mconcat . g . map (S.divVwls . S.reSyllableCntnts . S.groupSnds . S.str2UZPP2s) . words1 . mapMaybe f $ ys))) h+{-# INLINE procB2F #-}++procB2InvF+  :: (Ord c) => (Double -> c)+  -> ([[[S.UZPP2]]] -> [[Double]])+  -> Coeffs2+  -> FuncRep2 String Double c+procB2InvF h g coeffs = D (\xs ->+  let !ys = convertToProperUkrainianS . map (\x -> if x == '-' then ' ' else x) $ xs+      !z = diverse2GL " 01-" ys in if z == 0 then  (eval23Coeffs coeffs . mconcat . g . map (S.divVwls . S.reSyllableCntnts . S.groupSnds .+         S.str2UZPP2s) . words1 . mapMaybe f $ ys) ** 2.0+        else  ((eval23Coeffs coeffs . mconcat . g . map (S.divVwls . S.reSyllableCntnts . S.groupSnds . S.str2UZPP2s) . words1 . mapMaybe f $ ys) / (int2Double . fromEnum $ z))) h+{-# INLINE procB2InvF #-}++---------------------------------------------------------------------++procBoth3F+  :: (Ord c) => (Double -> c)+  -> Coeffs2+  -> FuncRep2 String Double c+procBoth3F g coeffs  = procB2F g SD.syllableDurationsD3 coeffs+{-# INLINE procBoth3F #-}++procBoth3InvF+  :: (Ord c) => (Double -> c)+  -> Coeffs2+  -> FuncRep2 String Double c+procBoth3InvF g coeffs  = procB2InvF g SD.syllableDurationsD3 coeffs+{-# INLINE procBoth3InvF #-}++-------------------------------------------------------------++f x+  | x == '0' = Nothing+  | x /= '1' && x /= '-' = 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/Ukrainian/PropertiesSyllablesG2.hs view
@@ -0,0 +1,143 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module      :  Phonetic.Languages.Array.Ukrainian.PropertiesSyllablesG2+-- Copyright   :  (c) OleksandrZhabenko 2020+-- 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. Uses syllables information.+-- Instead of the vector-related, uses just arrays.++{-# LANGUAGE CPP, BangPatterns #-}++module Phonetic.Languages.Array.Ukrainian.PropertiesSyllablesG2 (+    -- * Newtype to work with+  CoeffTwo(..)+  , Coeffs2+  , isEmpty+  , isPair+  , fstCF+  , sndCF+  , readCF+  -- * Rhythmicity metrices (semi-empirical)+  -- ** Simple one+  , rhythmicity0+  -- ** With weight coefficients+  , rhythmicityK+  -- * Rhythmicity metrices from generated with r-glpk-phonetic-languages-ukrainian-durations package (since 0.2.0.0 version)+  -- ** Simple one+  , rhythmicity02+  -- ** With weight coefficients+  , rhythmicityK2+  -- * NEW Rhythmicity metrices from generated with r-glpk-phonetic-languages-ukrainian-durations package (since 0.2.0.0 version)+  -- ** Simple one+  , rhythmicity03+  -- ** With weight coefficients+  , rhythmicityK3+  -- * General+  , 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.Phonetic.Ukrainian.Syllable.Double.Arr+import Languages.Phonetic.Ukrainian.Syllable.Arr+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 #-}++rhythmicity0 :: String -> Double+rhythmicity0 xs+ | null xs = 0.0+ | otherwise = eval23 . syllableDurationsD . createSyllablesUkrS $ xs++rhythmicityK :: Double -> Double -> String -> Double+rhythmicityK k2 k3 xs+ | null xs = 0.0+ | otherwise = eval23K k2 k3 . syllableDurationsD . createSyllablesUkrS $ xs++-------------------------------------------------------++rhythmicity02 :: String -> Double+rhythmicity02 xs+ | null xs = 0.0+ | otherwise = eval23 . syllableDurationsD2 . createSyllablesUkrS $ xs++rhythmicityK2 :: Double -> Double -> String -> Double+rhythmicityK2 k2 k3 xs+ | null xs = 0.0+ | otherwise = eval23K k2 k3 . syllableDurationsD2 . createSyllablesUkrS $ xs++-------------------------------------------------------++rhythmicity03 :: String -> Double+rhythmicity03 xs+ | null xs = 0.0+ | otherwise = eval23 . syllableDurationsD3 . createSyllablesUkrS $ xs++rhythmicityK3 :: Double -> Double -> String -> Double+rhythmicityK3 k2 k3 xs+ | null xs = 0.0+ | otherwise = eval23K k2 k3 . syllableDurationsD3 . createSyllablesUkrS $ xs++------------------------------------------------------------------++rhythmicity :: String -> Coeffs2 -> String -> Double+rhythmicity choice CF0+  | choice == "0y" = rhythmicity0+  | choice == "02y" = rhythmicity02+  | otherwise = rhythmicity03+rhythmicity choice (CF2 x y)+  | choice == "0y" = rhythmicityK (fromMaybe 1.0 x) (fromMaybe 1.0 y)+  | choice == "02y" = rhythmicityK2 (fromMaybe 1.0 x) (fromMaybe 1.0 y)+  | otherwise = rhythmicityK3 (fromMaybe 1.0 x) (fromMaybe 1.0 y)
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ phonetic-languages-simplified-properties-array.cabal view
@@ -0,0 +1,25 @@+-- Initial phonetic-languages-simplified-properties-array.cabal generated by cabal init.+-- For further documentation, see http://haskell.org/cabal/users-guide/++name:                phonetic-languages-simplified-properties-array+version:             0.1.0.0+synopsis:            A generalization of the uniqueness-periods-vector-properties package.+description:         Is a simplified version of the functionality of the former one. Uses lists and arrays as main processment data types. Uses Double whenever applicable.+homepage:            https://hackage.haskell.org/package/phonetic-languages-simplified-properties-array+license:             MIT+license-file:        LICENSE+author:              OleksandrZhabenko+maintainer:          olexandr543@yahoo.com+copyright:           Oleksandr Zhabenko+category:            Language, Math+build-type:          Simple+extra-source-files:  CHANGELOG.md+cabal-version:       >=1.10++library+  exposed-modules:     Phonetic.Languages.Array.Ukrainian.PropertiesFuncRepG2, Phonetic.Languages.Array.Ukrainian.PropertiesSyllablesG2+  -- other-modules:+  other-extensions:    BangPatterns, CPP+  build-depends:       base >=4.8 && <4.15, phonetic-languages-rhythmicity >=0.1.2 && <1, phonetic-languages-simplified-base >=0.1 && <1, ukrainian-phonetics-basic-array >=0.1.1 && <1+  -- hs-source-dirs:+  default-language:    Haskell2010