phonetic-languages-simplified-properties-lists (empty) → 0.1.0.0
raw patch · 6 files changed
+453/−0 lines, 6 filesdep +basedep +phonetic-languages-rhythmicitydep +phonetic-languages-simplified-commonsetup-changed
Dependencies added: base, phonetic-languages-rhythmicity, phonetic-languages-simplified-common, ukrainian-phonetics-basic, vector
Files
- CHANGELOG.md +6/−0
- LICENSE +20/−0
- Phonetic/Languages/Lists/Ukrainian/PropertiesFuncRepG.hs +247/−0
- Phonetic/Languages/Lists/Ukrainian/PropertiesSyllablesG.hs +153/−0
- Setup.hs +2/−0
- phonetic-languages-simplified-properties-lists.cabal +25/−0
+ CHANGELOG.md view
@@ -0,0 +1,6 @@+# Revision history for phonetic-languages-properties++## 0.1.0.0 -- 2020-11-25++* 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/Lists/Ukrainian/PropertiesFuncRepG.hs view
@@ -0,0 +1,247 @@+-- |+-- Module : Phonetic.Languages.Lists.Ukrainian.PropertiesFuncRepG+-- 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.++{-# LANGUAGE CPP, BangPatterns #-}++module Phonetic.Languages.Lists.Ukrainian.PropertiesFuncRepG (+ -- * Functions with 'Int16'+ procDiverse2I+ , procDiverse2Ineg+ -- * Functions with 'Float'+ , procDiverse2F+ , procDiverse2Fneg+ , procRhythmicity23F+ , procRhythmicity23Fneg+ , procBothF+ , procBothFneg+ , procBothInvF+ , procBothInvFneg+ -- ** Working with generated by r-glpk-phonetic-languages-ukrainian-durations syllable durations+ , procRhythmicity232F+ , procRhythmicity232Fneg+ , procBoth2F+ , procBoth2Fneg+ , procBoth2InvF+ , procBoth2InvFneg+) 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 qualified Data.Vector as VB+import qualified Data.Vector.Unboxed as V+import Phonetic.Languages.Lists.Ukrainian.PropertiesSyllablesG+import Phonetic.Languages.Simplified.Lists.UniquenessPeriodsG+import Languages.Rhythmicity+import Phonetic.Languages.Simplified.DataG+import GHC.Float (int2Float)+import Melodics.ByteString.Ukrainian+import qualified Languages.Phonetic.Ukrainian.Syllable as S+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++procDiverse2I+ :: (Ord c) => (Int16 -> c)+ -> FuncRep2 String Int16 c+procDiverse2I g = D (diverse2GL " 01-" . convertToProperUkrainianS) g+{-# INLINE procDiverse2I #-}++-- | Can be used to find out the minimum element.+procDiverse2Ineg+ :: (Ord c) => (Int16 -> c)+ -> FuncRep2 String Int16 c+procDiverse2Ineg g = D (negate . diverse2GL " 01-" . convertToProperUkrainianS) g+{-# INLINE procDiverse2Ineg #-}++procDiverse2F+ :: (Ord c) => (Float -> c)+ -> FuncRep2 String Float c+procDiverse2F g = D (int2Float . fromEnum . diverse2GL " 01-" . convertToProperUkrainianS) g+{-# INLINE procDiverse2F #-}++procDiverse2Fneg+ :: (Ord c) => (Float -> c)+ -> FuncRep2 String Float c+procDiverse2Fneg g = D (int2Float . negate . fromEnum . diverse2GL " 01-" . convertToProperUkrainianS) g+{-# INLINE procDiverse2Fneg #-}++--------------------------------------------------------------------------------------------++procRhythmicity23F+ :: (Ord c) => (Float -> c)+ -> String+ -> Coeffs2+ -> FuncRep2 String Float c+procRhythmicity23F g choice coeffs = procRhythm23F g choice rhythmicity coeffs+{-# INLINE procRhythmicity23F #-}++-- | Can be used to find out the minimum element.+procRhythmicity23Fneg+ :: (Ord c) => (Float -> c)+ -> String+ -> Coeffs2+ -> FuncRep2 String Float c+procRhythmicity23Fneg g choice coeffs = procRhythm23Fneg g choice rhythmicity coeffs+{-# INLINE procRhythmicity23Fneg #-}++procBothF+ :: (Ord c) => (Float -> c)+ -> Coeffs2+ -> FuncRep2 String Float c+procBothF g coeffs = procB2F g S.syllableDurations coeffs+{-# INLINE procBothF #-}++-- | Can be used to find out the minimum element.+procBothFneg+ :: (Ord c) => (Float -> c)+ -> Coeffs2+ -> FuncRep2 String Float c+procBothFneg g coeffs = procB2Fneg g S.syllableDurations coeffs+{-# INLINE procBothFneg #-}++procBothInvF+ :: (Ord c) => (Float -> c)+ -> Coeffs2+ -> FuncRep2 String Float c+procBothInvF g coeffs = procB2InvF g S.syllableDurations coeffs+{-# INLINE procBothInvF #-}++-- | Can be used to find out the minimum element.+procBothInvFneg+ :: (Ord c) => (Float -> c)+ -> Coeffs2+ -> FuncRep2 String Float c+procBothInvFneg g coeffs = procB2InvFneg g S.syllableDurations coeffs+{-# INLINE procBothInvFneg #-}++-------------------------------------------------------------------------------++procRhythmicity232F+ :: (Ord c) => (Float -> c)+ -> String+ -> Coeffs2+ -> FuncRep2 String Float c+procRhythmicity232F g choice coeffs = procRhythm23F g choice rhythmicity coeffs+{-# INLINE procRhythmicity232F #-}++-- | Can be used to find out the minimum element.+procRhythmicity232Fneg+ :: (Ord c) => (Float -> c)+ -> String+ -> Coeffs2+ -> FuncRep2 String Float c+procRhythmicity232Fneg g choice coeffs = procRhythm23Fneg g choice rhythmicity coeffs+{-# INLINE procRhythmicity232Fneg #-}++procBoth2F+ :: (Ord c) => (Float -> c)+ -> Coeffs2+ -> FuncRep2 String Float c+procBoth2F g coeffs = procB2F g S.syllableDurations2 coeffs+{-# INLINE procBoth2F #-}++-- | Can be used to find out the minimum element.+procBoth2Fneg+ :: (Ord c) => (Float -> c)+ -> Coeffs2+ -> FuncRep2 String Float c+procBoth2Fneg g coeffs = procB2Fneg g S.syllableDurations2 coeffs+{-# INLINE procBoth2Fneg #-}++procBoth2InvF+ :: (Ord c) => (Float -> c)+ -> Coeffs2+ -> FuncRep2 String Float c+procBoth2InvF g coeffs = procB2InvF g S.syllableDurations2 coeffs+{-# INLINE procBoth2InvF #-}++-- | Can be used to find out the minimum element.+procBoth2InvFneg+ :: (Ord c) => (Float -> c)+ -> Coeffs2+ -> FuncRep2 String Float c+procBoth2InvFneg g coeffs = procB2InvFneg g S.syllableDurations2 coeffs+{-# INLINE procBoth2InvFneg #-}++-------------------------------------------------------------++eval23Coeffs :: Coeffs2 -> [Float] -> Float+eval23Coeffs (CF2 x y) = evalRhythmicity23K (fromMaybe 1.0 x) (fromMaybe 1.0 y)+eval23Coeffs CF0 = evalRhythmicity23++procRhythm23F+ :: (Ord c) => (Float -> c)+ -> String+ -> (String -> Coeffs2 -> String -> Float)+ -> Coeffs2+ -> FuncRep2 String Float c+procRhythm23F h choice g coeffs = D (g choice coeffs) h+{-# INLINE procRhythm23F #-}++procRhythm23Fneg+ :: (Ord c) => (Float -> c)+ -> String+ -> (String -> Coeffs2 -> String -> Float)+ -> Coeffs2+ -> FuncRep2 String Float c+procRhythm23Fneg h choice g coeffs = D (negate . g choice coeffs) h+{-# INLINE procRhythm23Fneg #-}++procB2F+ :: (Ord c) => (Float -> c)+ -> ([[[S.UZPP2]]] -> [[Float]])+ -> Coeffs2+ -> FuncRep2 String Float c+procB2F h g coeffs = D (\xs -> let ys = convertToProperUkrainianS . map (\x -> if x == '-' then ' ' else x) $ xs in ((int2Float . fromEnum . diverse2GL " 01-" $ ys)*(eval23Coeffs coeffs . mconcat . g . S.createSyllablesUkrS $ ys))) h+{-# INLINE procB2F #-}++-- | Can be used to find out the minimum element.+procB2Fneg+ :: (Ord c) => (Float -> c)+ -> ([[[S.UZPP2]]] -> [[Float]])+ -> Coeffs2+ -> FuncRep2 String Float c+procB2Fneg h g coeffs = D (\xs -> let ys = convertToProperUkrainianS . map (\x -> if x == '-' then ' ' else x) $ xs in ((int2Float . negate . fromEnum . diverse2GL " 01-" $ ys)*(eval23Coeffs coeffs . mconcat . g . S.createSyllablesUkrS $ ys))) h+{-# INLINE procB2Fneg #-}++procB2InvF+ :: (Ord c) => (Float -> c)+ -> ([[[S.UZPP2]]] -> [[Float]])+ -> Coeffs2+ -> FuncRep2 String Float 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 ((evalRhythmicity23 . mconcat . g . S.createSyllablesUkrS $ ys) * (eval23Coeffs coeffs . mconcat . g . S.createSyllablesUkrS $ ys)) else ((eval23Coeffs coeffs . mconcat . g . S.createSyllablesUkrS $ ys) / (int2Float . fromEnum $ z))) h+{-# INLINE procB2InvF #-}++-- | Can be used to find out the minimum element.+procB2InvFneg+ :: (Ord c) => (Float -> c)+ -> ([[[S.UZPP2]]] -> [[Float]])+ -> Coeffs2+ -> FuncRep2 String Float c+procB2InvFneg 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 (negate (eval23Coeffs coeffs . mconcat . g . S.createSyllablesUkrS $ ys) * (eval23Coeffs coeffs .+ mconcat . g . S.createSyllablesUkrS $ ys)) else ((eval23Coeffs coeffs . mconcat . g . S.createSyllablesUkrS $ ys) / (int2Float . negate .+ fromEnum $ z))) h+{-# INLINE procB2InvFneg #-}
+ Phonetic/Languages/Lists/Ukrainian/PropertiesSyllablesG.hs view
@@ -0,0 +1,153 @@+-- |+-- Module : Phonetic.Languages.Lists.Ukrainian.PropertiesSyllablesG+-- 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.++{-# LANGUAGE CPP, BangPatterns #-}++module Phonetic.Languages.Lists.Ukrainian.PropertiesSyllablesG (+ -- * Newtype to work with+ CoeffTwo(..)+ , Coeffs2+ , isEmpty+ , isPair+ , fstCF+ , sndCF+ , readCF+ -- * Rhythmicity metrices (semi-empirical)+ -- ** Simple ones+ , rhythmicity0+ , rhythmicityV0+ -- ** With weight coefficients+ , rhythmicityVK+ , rhythmicityK+ -- * Rhythmicity metrices from generated with r-glpk-phonetic-languages-ukrainian-durations package (since 0.2.0.0 version)+ -- ** Simple ones+ , rhythmicity02+ , rhythmicityV02+ -- ** With weight coefficients+ , rhythmicityVK2+ , rhythmicityK2+ -- * General+ , rhythmicity+ , rhythmicityV+) 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 qualified Data.Vector as VB+import Languages.Rhythmicity+import Languages.Phonetic.Ukrainian.Syllable+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 Float,readMaybe (drop 1 ts)::Maybe Float)) . break (== '_') $ xs in+ if (isNothing ys && isNothing zs) then CF0 else CF2 ys zs+ | otherwise = CF0++type Coeffs2 = CoeffTwo Float++--------------------------------------------------------------------------------------------++eval23 = evalRhythmicity23 . mconcat+{-# INLINE eval23 #-}++eval23K k2 k3 = evalRhythmicity23K k2 k3 . mconcat+{-# INLINE eval23K #-}++rhythmicity0 :: String -> Float+rhythmicity0 xs+ | null xs = 0.0+ | otherwise = eval23 . syllableDurations . createSyllablesUkr $ xs++rhythmicityK :: Float -> Float -> String -> Float+rhythmicityK k2 k3 xs+ | null xs = 0.0+ | otherwise = eval23K k2 k3 . syllableDurations . createSyllablesUkrP $ xs++rhythmicityV0 :: VB.Vector Char -> Float+rhythmicityV0 v+ | VB.null v = 0.0+ | otherwise = eval23 . syllableDurations . createSyllablesUkrV $ v++rhythmicityVK :: Float -> Float -> VB.Vector Char -> Float+rhythmicityVK k2 k3 v+ | VB.null v = 0.0+ | otherwise = eval23K k2 k3 . syllableDurations . createSyllablesUkrVP $ v++-------------------------------------------------------++rhythmicity02 :: String -> Float+rhythmicity02 xs+ | null xs = 0.0+ | otherwise = eval23 . syllableDurations2 . createSyllablesUkr $ xs++rhythmicityK2 :: Float -> Float -> String -> Float+rhythmicityK2 k2 k3 xs+ | null xs = 0.0+ | otherwise = eval23K k2 k3 . syllableDurations2 . createSyllablesUkrP $ xs++rhythmicityV02 :: VB.Vector Char -> Float+rhythmicityV02 v+ | VB.null v = 0.0+ | otherwise = eval23 . syllableDurations2 . createSyllablesUkrV $ v++rhythmicityVK2 :: Float -> Float -> VB.Vector Char -> Float+rhythmicityVK2 k2 k3 v+ | VB.null v = 0.0+ | otherwise = eval23K k2 k3 . syllableDurations2 . createSyllablesUkrVP $ v++------------------------------------------------------------------++rhythmicity :: String -> Coeffs2 -> String -> Float+rhythmicity choice CF0+ | choice == "0y" = rhythmicity0+ | otherwise = rhythmicity02+rhythmicity choice (CF2 x y)+ | choice == "0y" = rhythmicityK (fromMaybe 1.0 x) (fromMaybe 1.0 y)+ | otherwise = rhythmicityK2 (fromMaybe 1.0 x) (fromMaybe 1.0 y)++rhythmicityV :: String -> Coeffs2 -> VB.Vector Char -> Float+rhythmicityV choice CF0+ | choice == "0y" = rhythmicityV0+ | otherwise = rhythmicityV02+rhythmicityV choice (CF2 x y)+ | choice == "0y" = rhythmicityVK (fromMaybe 1.0 x) (fromMaybe 1.0 y)+ | otherwise = rhythmicityVK2 (fromMaybe 1.0 x) (fromMaybe 1.0 y)
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ phonetic-languages-simplified-properties-lists.cabal view
@@ -0,0 +1,25 @@+-- Initial phonetic-languages-properties.cabal generated by cabal init.+-- For further documentation, see http://haskell.org/cabal/users-guide/++name: phonetic-languages-simplified-properties-lists+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 as main processment data.+homepage: https://hackage.haskell.org/package/phonetic-languages-simplified-properties-lists+license: MIT+license-file: LICENSE+author: OleksandrZhabenko+maintainer: olexandr543@yahoo.com+-- copyright:+category: Language+build-type: Simple+extra-source-files: CHANGELOG.md+cabal-version: >=1.10++library+ exposed-modules: Phonetic.Languages.Lists.Ukrainian.PropertiesFuncRepG, Phonetic.Languages.Lists.Ukrainian.PropertiesSyllablesG+ -- other-modules:+ other-extensions: BangPatterns, CPP+ build-depends: base >=4.7 && <4.15, vector >=0.11 && <0.14, phonetic-languages-rhythmicity >=0.1.2 && <1, phonetic-languages-simplified-common >=0.3 && <1, ukrainian-phonetics-basic >=0.3 && <1+ -- hs-source-dirs:+ default-language: Haskell2010