packages feed

phonetic-languages-simplified-common (empty) → 0.1.0.0

raw patch · 6 files changed

+222/−0 lines, 6 filesdep +basedep +phonetic-languages-permutationsdep +subGsetup-changed

Dependencies added: base, phonetic-languages-permutations, subG, subG-instances, vector

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for phonetic-languages-simplified-common++## 0.1.0.0 -- 2020-11-19++* 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/Simplified/DataG.hs view
@@ -0,0 +1,117 @@+-- |+-- Module      :  Phonetic.Languages.Simplified.DataG+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Simplified version of the @phonetic-languages-common@ and @phonetic-languages-general@ packages.+++{-# LANGUAGE BangPatterns, FlexibleContexts #-}++module Phonetic.Languages.Simplified.DataG where++import qualified Data.Foldable as F+import Data.Monoid+import Data.SubG+import Data.MinMax.Preconditions++data Result t a b c = R {line :: !(t a), metrices :: !b,  transMetrices :: !c} deriving Eq++instance (Ord (t a), Ord b, Ord c) => Ord (Result t a b c) where+  compare x y+    = case compare (transMetrices x) (transMetrices y) of+       EQ -> case compare (metrices x) (metrices y) of+              EQ -> compare (line x) (line y)+              z -> z+       z0 -> z0++data FuncRep2 a b c = D (a -> b) (b -> c)++getAC :: FuncRep2 a b c -> (a -> c)+getAC (D f g) = g . f++getAB :: FuncRep2 a b c -> (a -> b)+getAB (D f _) = f++getBC :: FuncRep2 a b c -> (b -> c)+getBC (D _ g) = g++maximumEl+  :: (Foldable t2, Ord c) => FuncRep2 (t a) b c+  -> t2 (t a)+  -> Result t a b c+maximumEl frep2 data0 =+  let l = F.maximumBy (\x y -> compare (getAC frep2 x) (getAC frep2 y)) data0+      m = getAB frep2 l+      tm = getBC frep2 m in R {line = l, metrices = m, transMetrices = tm}++minMaximumEls+  :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord (t a), Ord c) => FuncRep2 (t a) b c+  -> t2 (t a)+  -> (Result t a b c,Result t a b c)+minMaximumEls frep2 data0 =+  let (ln,lx) = minMax11ByC (\x y -> compare (getAC frep2 x) (getAC frep2 y)) data0+      mn = getAB frep2 ln+      mx = getAB frep2 lx+      tmn = getBC frep2 mn+      tmx = getBC frep2 mx in (R {line = ln, metrices = mn, transMetrices = tmn}, R {line = lx, metrices = mx, transMetrices = tmx})++maximumElR+  :: (Foldable t2, Ord c) => t2 (Result t a b c)+  -> Result t a b c+maximumElR = F.maximumBy (\x y -> compare (transMetrices x) (transMetrices y))++minMaximumElRs+  :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), Ord (t a), Ord b, Ord c) => t2 (Result t a b c)+  -> (Result t a b c,Result t a b c)+minMaximumElRs = minMax11ByC (\x y -> compare (transMetrices x) (transMetrices y))++-----------------------------------------------------------------------------------++innerPartitioning+  :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c) => FuncRep2 (t a) b c+  -> t2 (t a)+  -> (t2 (t a), t2 (t a))+innerPartitioning frep2 data0 =+  let l = getAC frep2 . F.maximumBy (\x y -> compare (getAC frep2 x) (getAC frep2 y)) $ data0 in partitionG ((== l) . getAC frep2) data0++maximumGroupsClassification+  :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, Integral d) => d+  -> FuncRep2 (t a) b c+  -> (t2 (t a), t2 (t a))+  -> (t2 (t a), t2 (t a))+maximumGroupsClassification nGroups frep2 (dataT,dataF)+ | nGroups <= 0 = (dataT,dataF)+ | otherwise = maximumGroupsClassification (nGroups - 1) frep2 (dataT `mappend` partT,partF)+     where (partT,partF) = innerPartitioning frep2 dataF++maximumGroupsClassification1+  :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, Integral d) => d+  -> FuncRep2 (t a) b c+  -> t2 (t a)+  -> (t2 (t a), t2 (t a))+maximumGroupsClassification1 nGroups frep2 data0+ | nGroups <= 0 = innerPartitioning frep2 data0+ | otherwise = maximumGroupsClassification (nGroups - 1) frep2 . innerPartitioning frep2 $ data0++maximumGroupsClassificationR+  :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), Ord c, Integral d) => d+  -> FuncRep2 (t a) b c+  -> t2 (Result t a b c)+  -> (t2 (Result t a b c), t2 (Result t a b c))+maximumGroupsClassificationR nGroups frep2 data0+ | nGroups <= 1 = (partT,partF)+ | otherwise = (partT `mappend` (fst . maximumGroupsClassificationR (nGroups - 1) frep2 $ partF),snd . maximumGroupsClassificationR (nGroups - 1) frep2 $ partF)+     where maxE0 = transMetrices . F.maximumBy (\x y -> compare (transMetrices x) (transMetrices y)) $ data0+           (partT,partF) = partitionG ((== maxE0) . transMetrices) data0++toResultR+  :: FuncRep2 (t a) b c+  -> t a+  -> Result t a b c+toResultR frep2 ys = R { line = ys, metrices = m, transMetrices = tm}+  where m = getAB frep2 ys+        tm = getBC frep2 m+
+ Phonetic/Languages/Simplified/StrictVG.hs view
@@ -0,0 +1,52 @@+-- |+-- Module      :  Phonetic.Languages.Simplified.StrictVG+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Simplified version of the @phonetic-languages-common@ package.++{-# LANGUAGE BangPatterns #-}++module Phonetic.Languages.Simplified.StrictVG (+  uniquenessVariants2GNB+  , uniquenessVariants2GNPB+) where++import Phonetic.Languages.Permutations+import qualified Data.Vector as VB+import Phonetic.Languages.Simplified.DataG+import qualified Data.Foldable as F+import Data.SubG+import Data.SubG.InstancesPlus ()+import Data.Monoid++uniquenessVariants2GNB ::+  (Eq a, Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => a -- ^ The first most common element in the \"whitespace symbols\" structure+  -> (t a -> VB.Vector a) -- ^ The function that is used internally to convert to the boxed 'VB.Vector' of @a@ so that the function can process further the permutations+  -> ((t (t a)) -> VB.Vector (VB.Vector a)) -- ^ The function that is used internally to convert to the boxed 'VB.Vector' of 'VB.Vector' of @a@ so that the function can process further+  -> (VB.Vector a -> t a) -- ^ The function that is used internally to convert from the boxed 'VB.Vector' of @a@ so that the function can process further+  -> VB.Vector (VB.Vector Int) -- ^ The list of permutations of 'Int' indices starting from 0 and up to n (n is probably less than 8).+  -> t (t a) -- ^ Must be obtained as 'subG' @whspss xs@+  -> VB.Vector (t a)+uniquenessVariants2GNB !hd f1 f2 f3 perms !subs = uniquenessVariants2GNPB mempty mempty hd f1 f2 f3 perms subs+{-# INLINE uniquenessVariants2GNB #-}++uniquenessVariants2GNPB ::+  (Eq a, Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => t a+  -> t a+  ->  a -- ^ The first most common element in the whitespace symbols structure+  -> (t a -> VB.Vector a) -- ^ The function that is used internally to convert to the boxed 'VB.Vector' of @a@ so that the function can process further the permutations+  -> ((t (t a)) -> VB.Vector (VB.Vector a)) -- ^ The function that is used internally to convert to the boxed 'VB.Vector' of 'VB.Vector' of @a@ so that the function can process further+  -> (VB.Vector a -> t a) -- ^ The function that is used internally to convert from the boxed 'VB.Vector' of @a@ so that the function can process further+  -> VB.Vector (VB.Vector Int) -- ^ The list of permutations of 'Int' indices starting from 0 and up to n (n is probably less than 7).+  -> t (t a) -- ^ Must be obtained as @subG whspss xs@+  -> VB.Vector (t a)+uniquenessVariants2GNPB !ts !us !hd f1 f2 f3 perms !subs+  | F.null subs = VB.empty+  | otherwise =+     let !uss = (hd %@ us) %^ mempty+         !baseV = VB.map (hd `VB.cons`) . f2 $ subs+         !ns = universalSetG ts uss f1 f2 perms baseV in VB.map f3 ns+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ phonetic-languages-simplified-common.cabal view
@@ -0,0 +1,26 @@+-- Initial phonetic-languages-simplified-common.cabal generated by cabal+-- init.  For further documentation, see+-- http://haskell.org/cabal/users-guide/++name:                phonetic-languages-simplified-common+version:             0.1.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+license:             MIT+license-file:        LICENSE+author:              OleksandrZhabenko+maintainer:          olexandr543@yahoo.com+copyright:           Oleksandr Zhabenko+category:            Language,Math,Game+build-type:          Simple+extra-source-files:  CHANGELOG.md+cabal-version:       >=1.10++library+  exposed-modules:     Phonetic.Languages.Simplified.DataG, Phonetic.Languages.Simplified.StrictVG+  -- other-modules:+  other-extensions:    BangPatterns, FlexibleContexts+  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.1.1 && <1+  -- hs-source-dirs:+  default-language:    Haskell2010