packages feed

phonetic-languages-rhythmicity 0.4.0.0 → 0.5.0.0

raw patch · 3 files changed

+93/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Rhythmicity.PolyRhythm: P0 :: String -> ParseChRh
+ Rhythmicity.PolyRhythm: P1 :: Choices -> RhythmBasis -> Int -> ParseChRh
+ Rhythmicity.PolyRhythm: P2 :: PolyChoices -> PolyRhythmBasis -> Int -> Int -> ParseChRh
+ Rhythmicity.PolyRhythm: data ParseChRh
+ Rhythmicity.PolyRhythm: instance GHC.Classes.Eq Rhythmicity.PolyRhythm.ParseChRh
+ Rhythmicity.PolyRhythm: isChRh3 :: ParseChRh -> Bool
+ Rhythmicity.PolyRhythm: isChRhPoly :: ParseChRh -> Bool
+ Rhythmicity.PolyRhythm: isChRhString :: ParseChRh -> Bool
+ Rhythmicity.PolyRhythm: readRhythmicity :: String -> Maybe ParseChRh

Files

CHANGELOG.md view
@@ -38,3 +38,7 @@  * Fourth version. Fixed some issues with the Rhythmicity.TwoFourth module. Added a new module Rhythmicity.PolyRhythm. Added GHC extension usage of MultiWayIf.++## 0.5.0.0 -- 2021-07-28++* Fifth version. Added special data type and related parsing functionality to the module Rhythmicity.PolyRhythm.
Rhythmicity/PolyRhythm.hs view
@@ -17,9 +17,11 @@ module Rhythmicity.PolyRhythm where  import Data.List (sort)-import Data.Maybe (fromJust)-import Data.Char (toLower)+import Data.Maybe (fromJust,fromMaybe)+import Data.Char (toLower,isDigit) import GHC.Float (int2Double)+import qualified Rhythmicity.TwoFourth as TF+import Text.Read (readMaybe)  data Marker4s = D | E | F | G deriving (Eq,Ord,Show) @@ -345,3 +347,85 @@   -> Double -- ^ In case of positive previous 'Double' arguments this is a positive value. The greater one corresponds to (probably) more rhythmic list. rhythmicityPoly0 x0 r choices rhythm = similarityPoly0 'a' x0 . getPolyChRhData 'a' r choices rhythm {-# INLINE rhythmicityPoly0 #-}++-------------------------------------------------------------------++{-| Data type that is used to implement some parameter language to encode in the 'String' argument information+that is sufficient to transform the 'String' into 'Double' using the needed additional information provided by+some other means.++-}+data ParseChRh =+  P0 String+  | P1+     TF.Choices+     TF.RhythmBasis+     Int -- ^ The number of the one of the functions to convert the phonetic languages elements into 'Double' values (usually, durations).+  | P2+     PolyChoices+     PolyRhythmBasis+     Int -- ^ The value for the 'Int' parameter in the 'getPolyChRhData' function that uses two previous arguments.+     Int -- ^ The number of the one of the functions to convert the phonetic languages elements into 'Double' values (usually, durations).+      deriving Eq++isChRhString :: ParseChRh -> Bool+isChRhString (P0 _) = True+isChRhString _ = False++isChRh3 :: ParseChRh -> Bool+isChRh3 (P1 _ _ _) = True+isChRh3 _ = False++isChRhPoly :: ParseChRh -> Bool+isChRhPoly (P2 _ _ _ _) = True+isChRhPoly _ = False++{-| A parser function to get the 'ParseChRh' data. In case of success returns 'Just' 'ParseChRh' value.+Nevertheless, the further checks (e. g. 'validPolyChRhPair' or 'validChRhPair') is not applied by it, so+they must be applied further during the usage. Examples of the usage:+\"c114+112=2\" returns 'Just' @P1 (Ch 1 1 4) (Rhythm 1 1 2) 2@+\"ctttff7+112111=7*3\" returns 'Just' @P2 (PolyCh [True,True,True,False,False] 7) (PolyRhythm [1,1,2,1,1,1]) 7 3@.+-}+readRhythmicity :: String -> Maybe ParseChRh+readRhythmicity ys@(x:xs)+ | x == 'c' && not (null xs) = if+                                | isDigit . head $ xs -> let x = readMaybe (take 1 ts)::Maybe Int+                                                             y = readMaybe (drop 1 . take 2 $ ts)::Maybe Int+                                                             z = readMaybe (drop 2 ts)::Maybe Int +                                                             ch = case (x,y,z) of+                                                                   (Just x1, Just y1, Just z1) -> Just (TF.Ch x1 y1 z1)+                                                                   _ -> Nothing+                                                             x2 = readMaybe (take 1 ws)::Maybe Int+                                                             y2 = readMaybe (drop 1 . take 2 $ ws)::Maybe Int+                                                             z2 = readMaybe (drop 2 ws)::Maybe Int +                                                             rh = case (x2,y2,z2) of+                                                                   (Just x3, Just y3, Just z3) -> Just (TF.Rhythm x3 y3 z3)+                                                                   _ -> Nothing+                                                             n = readMaybe ks::Maybe Int in+                                                               case (ch,rh,n) of+                                                                 (Just ch1,Just rh1,Just n1) -> Just . P1 ch1 rh1 $ f n1+                                                                 _ -> Just . P0 $ ys+                                | head xs == 't' || head xs == 'f' ->+                                                         let z = readMaybe qs::Maybe Int +                                                             ch = case z of+                                                                   Just z1 -> Just (PolyCh rs z1)+                                                                   _ -> Nothing+                                                             n = readMaybe ps::Maybe Int+                                                             m = readMaybe ms::Maybe Int in+                                                               case (ch,n,m) of+                                                                 (Just ch1,Just n1,Just m1) -> Just . P2 ch1 (PolyRhythm vs) n1 $ f m1+                                                                 _ -> Just . P0 $ ys +                                | otherwise -> Just . P0 $ ys+ | otherwise = Just . P0 $ ys+     where (ts, us) = break (== '+') xs+           (ws,zs) = break (== '=') . drop 1 $ us+           ks = drop 1 zs+           (ps,ns) = break (== '*') ks+           ms = drop 1 ns+           vs = map (fromMaybe 0 . (\t -> readMaybe t::Maybe Int) . (:[])) ws+           (ls,qs) = break isDigit ts+           rs = map (\t -> if t == 't' then True else False) ls+           f k+             | k `rem` 4 < 0 = 5 + (k `rem` 4)+             | otherwise = 1 + (k `rem` 4)+           
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.4.0.0-synopsis:            Allows to estimate the rhythmicity properties for the text (usually, the Ukrainian poetic one)-description:         Allows to estimate (somewhat to say, evaluate) the rhythmicity properties for the text (usually, the Ukrainian poetic one, but it can be extrapolated to other ones). Inspired by the ancient Greek and Latin poetry.+version:             0.5.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.  homepage:            https://hackage.haskell.org/package/phonetic-languages-rhythmicity license:             MIT