packages feed

phonetic-languages-properties (empty) → 0.1.0.0

raw patch · 7 files changed

+334/−0 lines, 7 filesdep +basedep +phonetic-languages-commondep +phonetic-languages-rhythmicitysetup-changed

Dependencies added: base, phonetic-languages-common, phonetic-languages-rhythmicity, phonetic-languages-vector, ukrainian-phonetics-basic, vector

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for phonetic-languages-properties++## 0.1.0.0 -- 2020-10-30++* 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.
+ Languages/UniquenessPeriods/Vector/PropertiesFuncRepG.hs view
@@ -0,0 +1,107 @@+-- |+-- Module      :  Languages.UniquenessPeriods.Vector.PropertiesFuncRepG+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Generalization of the functionality of the DobutokO.Poetry.Norms+-- and DobutokO.Poetry.Norms.Extended modules+-- from the @dobutokO-poetry@ package.++{-# LANGUAGE CPP, BangPatterns #-}++module Languages.UniquenessPeriods.Vector.PropertiesFuncRepG (+  -- * Functions with 'Int16'+  procDiverse2I+  , procDiverse2Ineg+  -- * Functions with 'Float'+  , procDiverse2F+  , procDiverse2Fneg+  , procRhythmicity23F+  , procRhythmicity23Fneg+  , procBothF+  , procBothFneg+  , procBothInvF+  , procBothInvFneg+) where++#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__>=710+/* code that applies only to GHC 7.10.* and higher versions */+import GHC.Base (mconcat)+#endif+#endif+import GHC.Int+import qualified Data.Vector as VB+import qualified Data.Vector.Unboxed as V+import String.Languages.UniquenessPeriods.VectorG+import Languages.UniquenessPeriods.Vector.PropertiesSyllablesG+import Languages.UniquenessPeriods.Vector.PropertiesG+import Languages.Rhythmicity+import Languages.UniquenessPeriods.Vector.DataG+import GHC.Float (int2Float)+import Melodics.ByteString.Ukrainian+import Languages.Phonetic.Ukrainian.Syllable++#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__==708+/* code that applies only to GHC 7.8.* */+mconcat = concat+#endif+#endif++procDiverse2I :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Int16]+procDiverse2I = D2 (uniquenessPeriodsVector3 " 01-" . convertToProperUkrainianV2X) ((:[]) . diverse2)+{-# INLINE procDiverse2I #-}++-- | Can be used to find out the minimum element.+procDiverse2Ineg :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Int16]+procDiverse2Ineg = D2 (uniquenessPeriodsVector3 " 01-" . convertToProperUkrainianV2X) ((:[]) . negate . diverse2)+{-# INLINE procDiverse2Ineg #-}++procDiverse2F :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Float]+procDiverse2F = D2 (uniquenessPeriodsVector3 " 01-" . convertToProperUkrainianV2X) ((:[]) . int2Float . fromEnum . diverse2)+{-# INLINE procDiverse2F #-}++procDiverse2Fneg :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Float]+procDiverse2Fneg = D2 (uniquenessPeriodsVector3 " 01-" . convertToProperUkrainianV2X) ((:[]) . int2Float . negate . fromEnum . diverse2)+{-# INLINE procDiverse2Fneg #-}++procRhythmicity23F :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Float]+procRhythmicity23F = U1 ((:[]) . rhythmicityV0)+{-# INLINE procRhythmicity23F #-}++-- | Can be used to find out the minimum element.+procRhythmicity23Fneg :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Float]+procRhythmicity23Fneg = U1 ((:[]) . negate . rhythmicityV0)+{-# INLINE procRhythmicity23Fneg #-}++procBothF :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Float]+procBothF = U1 (\v -> let ys = convertToProperUkrainianV2S . VB.map (\x -> if x == '-' then ' ' else x) $ v in (:[]) ((int2Float . fromEnum . diverse2 . uniquenessPeriodsVector3 " 01-" . VB.fromList $ ys)*(evalRhythmicity23 . mconcat . syllableDurations . map (divVwls . reSyllableCntnts . groupSnds . vec2UZPP2s) . vecWords . V.filter (/='0') . V.fromList $ ys)))+{-# INLINE procBothF #-}++-- | Can be used to find out the minimum element.+procBothFneg :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Float]+procBothFneg = U1 (\v -> let ys = convertToProperUkrainianV2S . VB.map (\x -> if x == '-' then ' ' else x) $ v in (:[]) ((int2Float . negate . fromEnum . diverse2 . uniquenessPeriodsVector3 " 01-" .+    VB.fromList$ ys)*(evalRhythmicity23 . mconcat . syllableDurations . map (divVwls . reSyllableCntnts . groupSnds . vec2UZPP2s) . vecWords . V.filter (/='0') . V.fromList $ ys)))+{-# INLINE procBothFneg #-}++procBothInvF :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Float]+procBothInvF = U1 (\v ->+  let !ys = convertToProperUkrainianV2S . VB.map (\x -> if x == '-' then ' ' else x) $ v+      !zs = uniquenessPeriodsVector3 " 01-" . VB.fromList $ ys in if VB.null zs then (:[]) ((evalRhythmicity23 . mconcat . syllableDurations . map (divVwls .+     reSyllableCntnts . groupSnds . vec2UZPP2s) . vecWords . V.filter (/='0') . V.fromList $ ys) * (evalRhythmicity23 . mconcat . syllableDurations . map (divVwls . reSyllableCntnts .+       groupSnds . vec2UZPP2s) . vecWords . V.filter (/='0') . V.fromList $ ys)) else (:[]) ((evalRhythmicity23 . mconcat . syllableDurations . map (divVwls . reSyllableCntnts . groupSnds .+         vec2UZPP2s) . vecWords . V.filter (/='0') . V.fromList $ ys) / (int2Float . fromEnum . diverse2 $ zs)))+{-# INLINE procBothInvF #-}++-- | Can be used to find out the minimum element.+procBothInvFneg :: FuncRep (VB.Vector Char) (UniquenessGeneral2 Char) [Float]+procBothInvFneg = U1 (\v ->+   let !ys = convertToProperUkrainianV2S . VB.map (\x -> if x == '-' then ' ' else x) $ v+       !zs = uniquenessPeriodsVector3 " 01-" .VB.fromList $ ys in if VB.null zs then (:[]) (negate (evalRhythmicity23 . mconcat . syllableDurations . map (divVwls .+     reSyllableCntnts . groupSnds . vec2UZPP2s) . vecWords . V.filter (/='0') . V.fromList $ ys) * (evalRhythmicity23 . mconcat . syllableDurations . map (divVwls . reSyllableCntnts .+       groupSnds . vec2UZPP2s) . vecWords . V.filter (/='0') . V.fromList $ ys)) else (:[]) ((evalRhythmicity23 . mconcat . syllableDurations . map (divVwls . reSyllableCntnts . groupSnds .+         vec2UZPP2s) . vecWords . V.filter (/='0') . V.fromList $ ys) / (int2Float . negate .  fromEnum . diverse2 $ zs)))+{-# INLINE procBothInvFneg #-}
+ Languages/UniquenessPeriods/Vector/PropertiesG.hs view
@@ -0,0 +1,116 @@+-- |+-- Module      :  Languages.UniquenessPeriods.Vector.PropertiesG+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Generalization of the functionality of the DobutokO.Poetry.Norms+-- and DobutokO.Poetry.Norms.Extended modules+-- from the @dobutokO-poetry@ package.++{-# LANGUAGE BangPatterns #-}++module Languages.UniquenessPeriods.Vector.PropertiesG where++import GHC.Int+import qualified Data.Vector as VB+import String.Languages.UniquenessPeriods.VectorG++-- | The function is inteded to be used after 'uniquenessPeriodsVector2' application to obtain the first argument. So generally, it is used as follows:+--+-- > diverse . uniquenessPeriodsVector2 y whspss $ v+--+-- The maximum value of the function corresponds to possibly more smoothly changing and mixing elements in the list. If they are used to represent+-- sounds (especially some text, may be poetic) then the resulting maximum possible 'diverse' value corresponds to more \"diverse\" (phonetically) text intervals.+-- Is somewhat similar to the @norm4@ function from the DobutokO.Poetry.Norms module from @dobutokO-poetry@ package+-- See: https://hackage.haskell.org/package/dobutokO-poetry-general-0.1.0.0/docs/DobutokO-Poetry-Norms.html.+diverse ::+  Eq a => UniquenessGeneral2 a -- ^ Is gotten after the application of the 'uniquenessPeriodsVector2'.+  -> Int16  -- ^ The resulting value.+diverse v+  | VB.null v = 0+  | otherwise = VB.sum . VB.map (\(xs,_) -> if null xs then 0::Int16 else minimum xs) $ v++-- | The function is inteded to be used after 'uniquenessPeriodsVector2' application to obtain the first argument. So generally, it is used as follows:+--+-- > diverse1 . uniquenessPeriodsVector2 y whspss $ v+--+-- The maximum value of the function corresponds to possibly more smoothly changing and mixing elements in the list. If they are used to represent+-- sounds (especially some text, may be poetic) then the resulting maximum possible 'diverse' value corresponds to more \"diverse\" (phonetically) text intervals.+-- Is somewhat similar to the @norm4@ function from the DobutokO.Poetry.Norms module from @dobutokO-poetry@ package. Unlike the 'diverse' function 'diverse1'+-- takes into account that in the word possibly there can be doubled or prolonged sounds that can be represented by repetition of the same sound+-- representation (in some cases). These repetitions do not depend on the words order and, therefore, do not change with it so are not informative on the possible+-- words order rearrangement that is essential to the phonetic languages as the one important application.+-- See: https://hackage.haskell.org/package/dobutokO-poetry-general-0.1.0.0/docs/DobutokO-Poetry-Norms.html.+diverse1 ::+  Eq a => UniquenessGeneral2 a -- ^ Is gotten after the application of the 'uniquenessPeriodsVector2'.+  -> Int16  -- ^ The resulting value.+diverse1 v+  | VB.null v = 0+  | otherwise = VB.sum . VB.map (\(xs,_) -> if null (filter (/= 1) xs) then 0::Int16 else minimum (filter (/= 1) xs)) $ v++-- | Is used similarly to 'diverse1', but uses another approach based on the 'sumPositiveWithoutMax' application, so generally can give another result.+-- It computes sum of the lists of 'Int' where each one is without the maximum value respectively and is without the elements that equal to 1.+diverse1s ::+  Eq a => UniquenessGeneral2 a -- ^ Is gotten after the application of the 'uniquenessPeriodsVector2'.+  -> Int16  -- ^ The resulting value.+diverse1s v+  | VB.null v = 0+  | otherwise = VB.sum . VB.map (\(xs,_) -> if null (filter (/= 1) xs) then 0::Int16 else sumPositiveWithoutMax (filter (/= 1) xs)) $ v++-- | For the list of positive 'Num' elements (this is not checked so it is up to the user to check positiveness) finds out the sum of the list+-- and the maximum value if the first argument is in the form (0, 0). For the empty list returns (0, 0) in such a case. For another first+-- argument has more complex behaviour. Tries to be tail-recursive.+sumPositiveAndMaxTuple :: (Num a, Ord a) => (a, a) -> [a] -> (a, a)+sumPositiveAndMaxTuple (x1,x2) (x:xs)+  | compare x2 x == GT = sumPositiveAndMaxTuple (x1 + x, x2) xs+  | otherwise = sumPositiveAndMaxTuple (x1 + x, x) xs+sumPositiveAndMaxTuple (x1, x2) [] = (x1, x2)++-- | Unlike 'sumPositiveAndMaxTuple', it is strict by its first argument's inner elements (by both of them).+sumPositiveAndMaxTuple' :: (Num a, Ord a) => (a, a) -> [a] -> (a, a)+sumPositiveAndMaxTuple' (!x1,!x2) (x:xs)+  | compare x2 x == GT = sumPositiveAndMaxTuple' (x1 + x, x2) xs+  | otherwise = sumPositiveAndMaxTuple' (x1 + x, x) xs+sumPositiveAndMaxTuple' (!x1, !x2) [] = (x1, x2)++-- | For the list of positive 'Num' elements (this is not checked so it is up to the user to check positiveness) finds out the sum of the list+-- without the maximum value.+sumPositiveWithoutMax :: (Num a, Ord a) => [a] -> a+sumPositiveWithoutMax = uncurry (-) . sumPositiveAndMaxTuple (0, 0)++-- | The strict variant the of the 'sumPositiveWithoutMax' function.+sumPositiveWithoutMax' :: (Num a, Ord a) => [a] -> a+sumPositiveWithoutMax' = uncurry (-) . sumPositiveAndMaxTuple' (0, 0)++-- | The function is inteded to be used after 'uniquenessPeriodsVector3' application to obtain the first argument. So generally, it is used as follows:+--+-- > diverse2 . uniquenessPeriodsVector3 whspss $ v+--+-- The maximum value of the function corresponds to possibly more smoothly changing and mixing elements in the list. If they are used to represent+-- sounds (especially some text, may be poetic) then the resulting maximum possible 'diverse2' value corresponds to more \"diverse\" (phonetically) text intervals.+-- Is somewhat similar to the @norm4@ function from the DobutokO.Poetry.Norms module from @dobutokO-poetry@ package. Unlike the 'diverse' and 'diverse1' and+-- 'diverse1s' functions 'diverse2' depends much more significantly on the words order. Possibly, the most accurate among \"diverse\" functions in the module.+-- See: https://hackage.haskell.org/package/dobutokO-poetry-general-0.1.0.0/docs/DobutokO-Poetry-Norms.html.+diverse2 ::+  Eq a => UniquenessGeneral2 a -- ^ Is gotten after the application of the 'uniquenessPeriodsVector3'.+  -> Int16  -- ^ The resulting value.+diverse2 v+  | VB.null v = 0+  | otherwise = VB.sum . VB.map (sum . fst) $ v+{-# INLINE diverse2 #-}++-- | Is intended to be used in the 'VB.Vector' @([b] -> b)@ where just the first value in the list is used. The simplest case among all possible ones. For an empty+-- list returns 'error' with an informative message.+oneProperty :: Ord b => [b] -> b+oneProperty xs+ | null xs = error "Languages.UniquenessPeriods.Vector.PropertiesG.oneProperty: empty list. "+ | otherwise = head xs+{-# INLINE oneProperty #-}++-- | Converts just one value to the needed list to be used as a \"property\". Is provided here for explanation purposes (just as a meaningful alias). Therefore, it is+-- an auxiliary function.+justOneValue2Property :: Ord b => b -> [b]+justOneValue2Property = (:[])+{-# INLINE justOneValue2Property #-}
+ Languages/UniquenessPeriods/Vector/PropertiesSyllablesG.hs view
@@ -0,0 +1,59 @@+-- |+-- Module      :  Languages.UniquenessPeriods.Vector.PropertiesSyllablesG+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Generalization and extension of the functionality of the DobutokO.Poetry.Norms+-- and DobutokO.Poetry.Norms.Extended modules+-- from the @dobutokO-poetry@ package. Uses syllables information.++{-# LANGUAGE CPP #-}++module Languages.UniquenessPeriods.Vector.PropertiesSyllablesG (+  -- * Rhythmicity metrices+  -- ** A simple one+  rhythmicity0+  , rhythmicityV0+  -- ** With weight coefficients+  , rhythmicityVK+  , rhythmicityK+) where++#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__>=710+/* code that applies only to GHC 7.10.* and higher versions */+import GHC.Base (mconcat)+#endif+#endif+import qualified Data.Vector as VB+import Languages.Rhythmicity+import Languages.Phonetic.Ukrainian.Syllable++#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__==708+/* code that applies only to GHC 7.8.* */+mconcat = concat+#endif+#endif++rhythmicity0 :: String -> Float+rhythmicity0 xs+ | null xs = 0.0+ | otherwise = evalRhythmicity23 . mconcat . syllableDurations . createSyllablesUkr $ xs++rhythmicityK :: Float -> Float -> String -> Float+rhythmicityK k2 k3 xs+ | null xs = 0.0+ | otherwise = evalRhythmicity23K k2 k3 . mconcat . syllableDurations . createSyllablesUkrP $ xs++rhythmicityV0 :: VB.Vector Char -> Float+rhythmicityV0 v+ | VB.null v = 0.0+ | otherwise = evalRhythmicity23 . mconcat . syllableDurations . createSyllablesUkrV $ v++rhythmicityVK :: Float -> Float -> VB.Vector Char -> Float+rhythmicityVK k2 k3 v+ | VB.null v = 0.0+ | otherwise = evalRhythmicity23K k2 k3 . mconcat . syllableDurations . createSyllablesUkrVP $ v
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ phonetic-languages-properties.cabal view
@@ -0,0 +1,25 @@+-- Initial phonetic-languages-properties.cabal generated by cabal init.+-- For further documentation, see http://haskell.org/cabal/users-guide/++name:                phonetic-languages-properties+version:             0.1.0.0+synopsis:            A generalization of the uniqueness-periods-vector-properties package.+-- description:+homepage:            https://hackage.haskell.org/package/phonetic-languages-properties+license:             MIT+license-file:        LICENSE+author:              OleksandrZhabenko+maintainer:          olexandr543@yahoo.com+-- copyright:+category:            Language+build-type:          Simple+extra-source-files:  CHANGELOG.md+cabal-version:       >=1.10++library+  exposed-modules:     Languages.UniquenessPeriods.Vector.PropertiesG, Languages.UniquenessPeriods.Vector.PropertiesFuncRepG, Languages.UniquenessPeriods.Vector.PropertiesSyllablesG+  -- other-modules:+  other-extensions:    BangPatterns, CPP+  build-depends:       base >=4.7 && <4.15, vector >=0.11 && <0.14, phonetic-languages-vector >=0.1 && <1, phonetic-languages-rhythmicity >=0.1.2 && <1, phonetic-languages-common >=0.1.1 && <1, ukrainian-phonetics-basic >=0.1.7 && <1+  -- hs-source-dirs:+  default-language:    Haskell2010