packages feed

phonetic-languages-simplified-common 0.2.1.0 → 0.3.0.0

raw patch · 3 files changed

+74/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Phonetic.Languages.Simplified.Lists.UniquenessPeriodsG: diverse2G :: Eq a => [a] -> Vector a -> Int16
+ Phonetic.Languages.Simplified.Lists.UniquenessPeriodsG: diverse2GL :: Foldable t => [Char] -> t Char -> Int16

Files

CHANGELOG.md view
@@ -9,8 +9,11 @@ * Second version. Added new functions to the Phonetic.Languages.Simplified.StrictVG module accordingly to the updated dependency of phonetic-languages-permutations. - ## 0.2.1.0 -- 2020-11-20  * Second version revised A. Fixed issue with not exporting the new functions. Some documentation improvements. +## 0.3.0.0 -- 2020-11-25++* Third version. Added a new module Phonetic.Languages.Simplified.Lists.UniquenessPeriodsG with simplified versions of the functions from the+uniqueness-periods-vector and Languages.UniquenessPeriods.Vector.PropertiesG module from phonetic-languages-properties packages.
+ Phonetic/Languages/Simplified/Lists/UniquenessPeriodsG.hs view
@@ -0,0 +1,67 @@+-- |+-- Module      :  Phonetic.Languages.Simplified.Lists.UniquenessPeriodsG+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Generalization of the uniqueness-periods and uniqueness-periods-general+-- packages functionality.+--++{-# LANGUAGE BangPatterns #-}++module Phonetic.Languages.Simplified.Lists.UniquenessPeriodsG (+  -- * Vector functions+  diverse2G+  -- * List functions+  , diverse2GL+)where++import GHC.Int+import qualified Data.Vector as VB+import Data.List+import Data.Maybe (mapMaybe)+++-- | A vectors simplified variant of the diverse2 metrics from the @phonetic-languages-properties@ package.+diverse2G whspss v+ | VB.null v = 0+ | otherwise = VB.sum . VB.mapMaybe (helpG sum whspss) . VB.unfoldr f . VB.map (\(j,t) -> (toEnum j,t)) $ v1+     where !v1 = VB.indexed v+           !vs = VB.toList . VB.map toEnum . VB.findIndices (`elem` whspss) $ v+           f !x = if VB.null x then Nothing else let !idX0 = snd . VB.unsafeIndex x $ 0 in Just . (\vws (v2,v3) -> ((helpUPV3 vws [] . VB.toList .+                    VB.map fst $ v2,snd . VB.unsafeIndex v2 $ 0),v3)) vs . VB.partition (\(_,xs) -> xs == idX0) $ x++-- | A lists variant of the diverse2 metrics from the @phonetic-languages-properties@ package.+diverse2GL whspss ws+ | null ws = 0+ | otherwise = sum . mapMaybe (helpG sum whspss) . unfoldr f $ ks+     where !ks = indexedL '\00' ws+           !vs = mapMaybe g ks+           g x+            | (`elem` whspss) . snd $ x = Just (fst x)+            | otherwise = Nothing+           {-# INLINE g #-}+           f !x = if null x then Nothing else let !idX0 = snd . head $ x in Just . (\vws (v2,v3) -> ((helpUPV3 vws [] .+                    map fst $ v2,snd . head $ v2),v3)) vs . partition (\(_,xs) -> xs == idX0) $ x++-- | The first and the third list arguments of numbers (if not empty) must be sorted in the ascending order.+helpUPV3 :: [Int16] -> [Int16] -> [Int16] -> [Int16]+helpUPV3 (z:zs) !acc (x:y:xs)+ | compare ((x - z) * (y - z)) 0 == LT = helpUPV3 zs ((y - x):acc) (y:xs)+ | compare y z == GT = helpUPV3 zs acc (x:y:xs)+ | otherwise = helpUPV3 (z:zs) acc (y:xs)+helpUPV3 _ !acc _ = acc++indexedL :: Foldable t => b -> t b -> [(Int16, b)]+indexedL y = foldr f v+  where v = [(1::Int16,y)]+        f x ((j,z):ys) = (j-1,x):(j,z):ys++helpG :: (Eq a) => ([b] -> b) -> [a] -> ([b], a) -> Maybe b+helpG h xs (ts, x)+  | null ts = Nothing+  | x `elem` xs = Nothing+  | otherwise = Just (h ts)+{-# INLINE helpG #-}
phonetic-languages-simplified-common.cabal view
@@ -3,7 +3,7 @@ -- http://haskell.org/cabal/users-guide/  name:                phonetic-languages-simplified-common-version:             0.2.1.0+version:             0.3.0.0 synopsis:            A simplified version of the phonetic-languages-functionality description:         A simplified version of the phonetic-languages-functionality. Tries to use only necessary functionality and reduce the other one. homepage:            https://hackage.haskell.org/package/phonetic-languages-simlified-common@@ -18,9 +18,9 @@ cabal-version:       >=1.10  library-  exposed-modules:     Phonetic.Languages.Simplified.DataG, Phonetic.Languages.Simplified.StrictVG+  exposed-modules:     Phonetic.Languages.Simplified.DataG, Phonetic.Languages.Simplified.StrictVG, Phonetic.Languages.Simplified.Lists.UniquenessPeriodsG   -- other-modules:-  other-extensions:    BangPatterns, FlexibleContexts+  other-extensions:    BangPatterns, FlexibleContexts, MultiParamTypeClasses   build-depends:       base >=4.8 && <4.15, subG >=0.4.2 && <1, subG-instances >=0.1 && <1, vector >=0.11 && <0.14, phonetic-languages-permutations >=0.2 && <1   -- hs-source-dirs:   default-language:    Haskell2010