phonetic-languages-rhythmicity 0.1.0.1 → 0.1.1.0
raw patch · 3 files changed
+23/−19 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- Languages/Rhythmicity.hs +17/−18
- phonetic-languages-rhythmicity.cabal +1/−1
CHANGELOG.md view
@@ -7,3 +7,8 @@ ## 0.1.0.1 -- 2020-10-08 * First version revised A. Improved computational simplicity.++## 0.1.1.0 -- 2020-10-19++* First version revised B. Some code improvements.+
Languages/Rhythmicity.hs view
@@ -15,40 +15,39 @@ maxPosition2 :: (RealFrac a) => [a] -> a maxPosition2 xs | null xs = 0.0- | otherwise = let !mx2 = maxP22 xs 0.0 in if mx2 == 0.0 then 2.0 * abs (maxP21 xs 0.0) else abs (maxP21 xs 0.0 / mx2)- where maxP2 [t, u]- | compare t u == LT = 1.0- | otherwise = -1.0- maxP2 xs = 0.0- maxP21 (x:y:xs) !acc1 = maxP21 xs (maxP2 [x,y] + acc1)+ | otherwise = if mx2 == 0.0 then 2.0 * abs (maxP21 xs 0.0) else abs (maxP21 xs 0.0 / mx2)+ where maxP21 (x:y:ys) !acc1 = maxP21 ys (if x < y then acc1 + 1.0 else acc1 - 1.0) maxP21 _ !acc1 = acc1- maxP22 (x:y:xs) !acc1 = maxP22 (y:xs) (maxP2 [x,y] + acc1)+ maxP22 (x:y:ys) !acc1 = maxP22 (y:ys) (if x < y then acc1 + 1.0 else acc1 - 1.0) maxP22 _ !acc1 = acc1+ !mx2 = maxP22 xs 0.0 posMaxIn3 :: (Ord a) => a -> a -> a -> Int-posMaxIn3 x y z = let !mx = max (max x y) z in- case mx of- x -> 1- y -> 2- _ -> 3+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- | length xs `rem` 3 == 0 = 3.0 * go (h xs) (0.0, 0.0, 0.0)- | otherwise = go xs (0.0, 0.0, 0.0)+ | length xs `rem` 3 == 0 = 3.0 * fromIntegral (go (h xs) ((0, 0, 0)::(Int,Int,Int)))+ | otherwise = fromIntegral (go xs ((0, 0, 0)::(Int,Int,Int))) where h (x:y:z:ys) = posMaxIn3 x y z:h ys h _ = []- go [] (!acc21,!acc22,!acc23) = if acc21 > max acc22 acc23 then acc21 else if acc22 > max acc21 acc23 then acc22 else acc23+ go [] (!acc21,!acc22,!acc23)+ | acc21 > acc22 = if acc21 > acc23 then acc21 else acc23+ | acc22 > acc23 = acc22+ | otherwise = acc23 go (x:zs) (!acc21,!acc22,!acc23) = go zs (h1 x (acc21,acc22,acc23)) h1 !x (!t,!u,!w)- | x == 1 = (t + 1.0, u, w)- | x == 2 = (t, u + 1.0, w)- | otherwise = (t,u,w + 1.0)+ | x == 1 = (t + 1, u, w)+ | x == 2 = (t, u + 1, w)+ | otherwise = (t,u,w + 1) evalRhythmicity23 :: (RealFrac a, Floating a) => [a] -> a evalRhythmicity23 xs = maxPosition2 xs * maxPosition2 xs + maxPosition3 xs * maxPosition3 xs
phonetic-languages-rhythmicity.cabal view
@@ -2,7 +2,7 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/ name: phonetic-languages-rhythmicity-version: 0.1.0.1+version: 0.1.1.0 synopsis: Allows to estimate the rhythmicity metrices for the text (usually, the Ukrainian poetic one) description: Allows to estimate (somewhat to say, evaluate) the rhythmicity metrices for the text (usually, the Ukrainian poetic one, but it can be extrapolated to other ones). Inspired by the ancient Greek and Latin poetry.