phonetic-languages-rhythmicity 0.10.2.0 → 0.11.0.0
raw patch · 4 files changed
+6/−156 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Phladiprelio.Rhythmicity.Factor: F :: !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> Factors
- Phladiprelio.Rhythmicity.Factor: data Factors
- Phladiprelio.Rhythmicity.Factor: defFactors :: Factors
- Phladiprelio.Rhythmicity.Factor: defFactorsStr :: String
- Phladiprelio.Rhythmicity.Factor: evalRhythmicity23F :: Factors -> Double -> [Double] -> Double
- Phladiprelio.Rhythmicity.Factor: evalRhythmicity23KF :: Factors -> Double -> Double -> Double -> [Double] -> Double
- Phladiprelio.Rhythmicity.Factor: instance GHC.Classes.Eq Phladiprelio.Rhythmicity.Factor.Factors
- Phladiprelio.Rhythmicity.Factor: instance GHC.Show.Show Phladiprelio.Rhythmicity.Factor.Factors
- Phladiprelio.Rhythmicity.Factor: maxPosition2F :: Factors -> Double -> [Double] -> Double
- Phladiprelio.Rhythmicity.Factor: readFactors :: String -> Factors
- Phladiprelio.Rhythmicity.Simple: evalRhythmicity23 :: (RealFrac a, Floating a) => [a] -> a
- Phladiprelio.Rhythmicity.Simple: evalRhythmicity23K :: (RealFrac a, Floating a) => a -> a -> [a] -> a
- Phladiprelio.Rhythmicity.Simple: maxPosition2 :: RealFrac a => [a] -> a
- Phladiprelio.Rhythmicity.Simple: maxPosition3 :: RealFrac a => [a] -> a
- Phladiprelio.Rhythmicity.Simple: posMaxIn3 :: Ord a => a -> a -> a -> Int16
Files
- CHANGELOG.md +3/−0
- Phladiprelio/Rhythmicity/Factor.hs +0/−86
- Phladiprelio/Rhythmicity/Simple.hs +0/−67
- phonetic-languages-rhythmicity.cabal +3/−3
CHANGELOG.md view
@@ -110,3 +110,6 @@ * Tenth version revised B. Normed the functions in the Phladiprelio.Rhythmicity.Simple and Phladiprelio.Rhythmicity.Factor modules. +## 0.11.0.0 -- 2023-03-13++* Eleventh version. Moved the shared by different implementations functionality to a new package. Some documentation changes.
− Phladiprelio/Rhythmicity/Factor.hs
@@ -1,86 +0,0 @@-{-# LANGUAGE BangPatterns, NoImplicitPrelude, MultiWayIf #-}-{-# OPTIONS_HADDOCK show-extensions #-}-{-# OPTIONS_GHC -funbox-strict-fields #-}---- |--- Module : Phladiprelio.Rhythmicity.Factor--- Copyright : (c) Oleksandr Zhabenko 2020-2023--- License : MIT--- Stability : Experimental--- Maintainer : oleksandr.zhabenko@yahoo.com------ Allows to evaluate (approximately, so better to say, to estimate) the--- rhythmicity properties for the text (usually, the poetic one). Tries to use--- somewhat \'improved\' versions of the functions similar to the ones in the--- Phladiprelio.Rhythmicity.Simple module.--module Phladiprelio.Rhythmicity.Factor where--import GHC.Base-import GHC.Int-import GHC.Num (Num,(+),(-),(*),abs)-import GHC.Real-import GHC.Float-import GHC.List-import Text.Show-import Text.Read (read)-import Phladiprelio.Rhythmicity.Simple-import Data.Char (isDigit)--data Factors = F !Double !Double !Double !Double !Double !Double !Double !Double !Double !Double deriving (Eq, Show)--readFactors :: String -> Factors-readFactors xs - | length xs == 10 = let (x1:x2:x3:x4:x5:x6:x7:x8:x9:[x10]) = map f2 xs in F x1 x2 x3 x4 x5 x6 x7 x8 x9 x10- | otherwise = defFactors- where f2 x - | isDigit x = read [x]::Double- | otherwise = case x of { 'p' -> 4.743; 'i' -> 4.153; ~rrr -> 0 }---- | The first argument must be greater than 1 and the values in the list greater than 0 though it is not checked.-maxPosition2F :: Factors -> Double -> [Double] -> Double-maxPosition2F ff !k xs- | null xs = 0.0- | otherwise = maxP21 ff k xs 0- where maxP21 ff k (x:ks@(y:t:ys)) !acc1 - | abs (x - t) / max x t < 0.05 = maxP21 ff k ks (acc1 + f1 ff k s y w)- | otherwise = maxP21 ff k ks (acc1 + f ff k s y w)- where (s, w) - | t > x = (x, t)- | otherwise = (t, x)- f ff@(F x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) k s y w- | y > w = if - | y >= k * s && y <= k*w -> x1 -- the default is 5.0- | y < k*s -> x2 -- the default is 4.0- | otherwise -> x3 -- the default is 3.0- | y > s = x4 -- the default is 2.0- | y < s = x5 -- the default is 1.0- | y == w = x6 -- the default is 4.743- | otherwise = x7 -- the default is 4.153- f1 ff@(F x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) k s y w- | y > w = x8 -- the default is 5.0- | y < s = x9 -- the default is 4.0- | otherwise = x10 -- the default is 3.0- maxP21 _ _ _ !acc1 = acc1--defFactors :: Factors-defFactors = F 5 4 3 2 1 4.743 4.153 5 4 3---- | --- > readFactors defFactorsStr == defFactors-defFactorsStr :: String-defFactorsStr = "54321pi543"--evalRhythmicity23F :: Factors -> Double -> [Double] -> Double-evalRhythmicity23F ff k xs = maxPosition2F ff k xs + 14.37 * maxPosition3 xs-{-# INLINE evalRhythmicity23F #-}--evalRhythmicity23KF- :: Factors- -> Double- -> Double- -> Double- -> [Double]- -> Double-evalRhythmicity23KF ff k k2 k3 xs = k2 * maxPosition2F ff k xs + k3 * 14.37 * maxPosition3 xs-{-# INLINE evalRhythmicity23KF #-}
− Phladiprelio/Rhythmicity/Simple.hs
@@ -1,67 +0,0 @@-{-# LANGUAGE BangPatterns, NoImplicitPrelude #-}-{-# OPTIONS_HADDOCK show-extensions #-}---- |--- Module : Phladiprelio.Rhythmicity.Simple--- Copyright : (c) Oleksandr Zhabenko 2020-2023--- License : MIT--- Stability : Experimental--- Maintainer : oleksandr.zhabenko@yahoo.com------ Allows to evaluate (approximately, so better to say, to estimate) the--- rhythmicity properties for the text (usually, the poetic one).--module Phladiprelio.Rhythmicity.Simple where--import GHC.Base-import GHC.Int-import GHC.Num ((+),(-),(*),abs)-import GHC.Real-import GHC.Float-import GHC.List---- | Is well defined just for positive values in the list.-maxPosition2 :: (RealFrac a) => [a] -> a-maxPosition2 xs- | null xs = 0.0- | otherwise = maxP21 xs 0- where maxP21 (x:ks@(y:t:ys)) !acc1 - | (x - y) * (t - y) <= 0 = maxP21 ks (acc1::Int16)- | otherwise = maxP21 ks ((acc1 + 1)::Int16)- maxP21 _ !acc1 = fromIntegral acc1- -posMaxIn3- :: (Ord a) => a- -> a- -> a- -> Int16-posMaxIn3 x y z - | x < y = if y < z then 3 else 2- | x < z = 3- | otherwise = 1--maxPosition3 :: RealFrac a => [a] -> a-maxPosition3 xs- | null xs = 0.0- | otherwise = fromIntegral (go (h xs) ((0, 0, 0)::(Int16,Int16,Int16)))- where h (x:y:z:ys) = posMaxIn3 x y z:h ys- h _ = []- go (x:zs) (!acc21,!acc22,!acc23) = go zs (h1 x (acc21,acc22,acc23))- go _ (!acc21,!acc22,!acc23)- | acc21 > acc22 = if acc21 > acc23 then acc21 else acc23- | acc22 > acc23 = acc22- | otherwise = acc23- h1 !x (!t,!u,!w)- | x == 1 = (t + (1::Int16), u, w)- | x == 2 = (t, u + (1::Int16), w)- | otherwise = (t,u,w + (1::Int16))--evalRhythmicity23 :: (RealFrac a, Floating a) => [a] -> a-evalRhythmicity23 xs = maxPosition2 xs + 1.31 * maxPosition3 xs--evalRhythmicity23K- :: (RealFrac a, Floating a) => a- -> a- -> [a]- -> a-evalRhythmicity23K k2 k3 xs = k2 * maxPosition2 xs + k3 * 1.31 * maxPosition3 xs
phonetic-languages-rhythmicity.cabal view
@@ -2,9 +2,9 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/ name: phonetic-languages-rhythmicity-version: 0.10.2.0+version: 0.11.0.0 synopsis: Allows to estimate the rhythmicity properties for the text-description: Allows to estimate (somewhat to say, evaluate) the rhythmicity properties for the text. Inspired by the ancient Greek and Latin poetry.+description: Allows to estimate (somewhat to say, evaluate) the rhythmicity properties for the text. Inspired by the ancient Greek and Latin poetry. Since the 0.11.0.0 version part of the functionality moved to the other package to reduce code duplication. homepage: https://hackage.haskell.org/package/phonetic-languages-rhythmicity license: MIT@@ -18,7 +18,7 @@ cabal-version: >=1.10 library- exposed-modules: Phladiprelio.Rhythmicity.Simple, Phladiprelio.Rhythmicity.Factor, Phladiprelio.Rhythmicity.TwoFourth, Phladiprelio.Rhythmicity.PolyRhythm+ exposed-modules: Phladiprelio.Rhythmicity.TwoFourth, Phladiprelio.Rhythmicity.PolyRhythm -- other-modules: other-extensions: BangPatterns, MultiWayIf, NoImplicitPrelude ghc-options: -funbox-strict-fields