Skip to content

Commit

Permalink
Some usability improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr-Zhabenko committed Sep 28, 2024
1 parent b28bae9 commit 73c00e3
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 43 deletions.
4 changes: 2 additions & 2 deletions Aftovolio/Basis.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{-# OPTIONS_HADDOCK show-extensions #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude, StrictData #-}

-- |
-- Module : Aftovolio.Basis
-- Copyright : (c) OleksandrZhabenko 2020-2023
-- Copyright : (c) OleksandrZhabenko 2020-2024
-- License : MIT
-- Stability : Experimental
-- Maintainer : [email protected]
Expand Down
4 changes: 2 additions & 2 deletions Aftovolio/Coeffs.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{-# OPTIONS_HADDOCK show-extensions #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude, StrictData #-}

-- |
-- Module : Aftovolio.Coeffs
-- Copyright : (c) OleksandrZhabenko 2020-2023
-- Copyright : (c) OleksandrZhabenko 2020-2024
-- License : MIT
-- Stability : Experimental
-- Maintainer : [email protected]
Expand Down
5 changes: 1 addition & 4 deletions Aftovolio/ConstraintsEncoded.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{-# OPTIONS_HADDOCK show-extensions #-}




-- |
-- Module : Aftovolio.ConstraintsEncoded
-- Copyright : (c) OleksandrZhabenko 2020-2024
Expand All @@ -13,7 +10,7 @@
-- Provides a way to encode the needed constraint with possibly less symbols.
-- Uses arrays instead of vectors.

{-# LANGUAGE FlexibleInstances, FlexibleContexts, NoImplicitPrelude, BangPatterns #-}
{-# LANGUAGE FlexibleInstances, FlexibleContexts, NoImplicitPrelude, BangPatterns, StrictData #-}

module Aftovolio.ConstraintsEncoded (
-- * Data types
Expand Down
2 changes: 1 addition & 1 deletion Aftovolio/General/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# OPTIONS_GHC -funbox-strict-fields -fobject-code #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnboxedTuples, StrictData #-}
{-# LANGUAGE MagicHash #-}

-- |
Expand Down
13 changes: 6 additions & 7 deletions Aftovolio/General/Datatype3.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- Maintainer : [email protected]

{-# OPTIONS_GHC -funbox-strict-fields #-}
{-# LANGUAGE NoImplicitPrelude, BangPatterns #-}
{-# LANGUAGE NoImplicitPrelude, BangPatterns, StrictData #-}

module Aftovolio.General.Datatype3 (
Read0
Expand All @@ -28,7 +28,7 @@ import GHC.List
import GHC.Word
import GHC.Real (floor,fromIntegral,(/))
import GHC.Float (int2Double)
import Data.List (groupBy,find)
import Data.List (groupBy,find,maximumBy,minimumBy)
import Data.Char (isDigit, isSpace,isLetter)
import Text.Read (readMaybe)
import Text.Show (Show(..))
Expand All @@ -37,6 +37,7 @@ import Data.Maybe (fromMaybe)
import Data.Tuple (fst,snd)
import qualified Data.Foldable as F (foldr)
import qualified Data.Sequence as S
import Data.Ord (comparing)
import ListQuantizer (round2GL)

-- | Is a way to read duration of the additional added time period into the line.
Expand Down Expand Up @@ -194,14 +195,12 @@ showRead0AsInsert d@(B t) = '_':(filter (/= '.') . show $ t)
showRead0AsInsert d@(C ts) = ts
{-# INLINE showRead0AsInsert #-}

-- | Is intended to be used to transform the earlier data for AFTOVolio representations durations from 'Double' to 'Word8' values. It was used during the transition from the ukrainian-phonetics-basic-array-0.7.1.1 to ukrainian-phonetics-basic-array-0.10.0.0.
-- | Is intended to be used to transform the earlier data for AFTOVolio representations durations from 'Double' to 'Word8' values. It was used during the transition from the ukrainian-phonetics-basic-array-0.7.1.1 to ukrainian-phonetics-basic-array-0.10.0.0.
zippedDouble2Word8 xs = map (\(t, u) -> (t,fromMaybe 15 . hh $ u)) xs
where !h = snd . head $ xs
!lt = snd . last $ xs
where !h = snd . minimumBy (comparing snd) $ xs
!lt = snd . maximumBy (comparing snd) $ xs
!del = (lt - h)/14.0
!ys = take 15 . iterate (+del) $ h
!zs = zip [1..15] ys
gg !u = fromMaybe lt . round2GL True (\_ _ -> EQ) ys $ u
hh !u = fmap fst . find ((== gg u) . snd) $ zs


2 changes: 1 addition & 1 deletion Aftovolio/General/Simple.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE NoImplicitPrelude, BangPatterns, DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude, BangPatterns, DeriveGeneric, StrictData #-}

module Aftovolio.General.Simple where

Expand Down
2 changes: 1 addition & 1 deletion Aftovolio/General/Syllables.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# OPTIONS_GHC -funbox-strict-fields -fobject-code #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnboxedTuples, StrictData #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
Expand Down
4 changes: 2 additions & 2 deletions Aftovolio/PermutationsRepresent.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude, StrictData #-}

-- |
-- Module : Aftovolio.PermutationsRepresent
-- Copyright : (c) OleksandrZhabenko 2022-2023
-- Copyright : (c) OleksandrZhabenko 2022-2024
-- License : MIT
-- Stability : Experimental
-- Maintainer : [email protected]
Expand Down
2 changes: 1 addition & 1 deletion Aftovolio/RGLPK/General.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude, StrictData #-}
{-# OPTIONS_HADDOCK show-extensions #-}

-- |
Expand Down
2 changes: 1 addition & 1 deletion Aftovolio/Ukrainian/Common2.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# OPTIONS_HADDOCK show-extensions #-}
{-# LANGUAGE BangPatterns, NoImplicitPrelude #-}
{-# LANGUAGE BangPatterns, NoImplicitPrelude, StrictData #-}

-- |
-- Module : Aftovolio.Ukrainian.Common2
Expand Down
2 changes: 1 addition & 1 deletion Aftovolio/Ukrainian/IO.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE NoImplicitPrelude, ScopedTypeVariables, DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude, ScopedTypeVariables, DeriveGeneric, StrictData #-}

module Aftovolio.Ukrainian.IO where

Expand Down
15 changes: 2 additions & 13 deletions Aftovolio/Ukrainian/SyllableWord8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import Data.Foldable (foldl')
import GHC.Word

s0DuratD1 :: Sound8 -> Word8
s0DuratD1 = getBFstLSorted' 5 [(1,15),(2,10),(3,13),(4,12),(5,11),(6,10),(7,1),(8,6),(9,6),(10,7),(11,7),(15,6),(16,6),(17,8),(18,8),(19,7),(20,7),(21,8),(22,8),(23,5),(24,5),(25,6),(26,6),(27,6),(28,7),(29,7),(30,8),(31,8),(32,8),(33,8),(34,5),(35,5),(36,9),(37,9),(38,5),(39,6),(40,6),(41,7),(42,7),(43,6),(44,6),(45,4),(46,4),(47,15),(48,15),(49,8),(50,12),(51,12),(52,8),(53,8),(54,8),(66,10)]
s0DuratD1 = getBFstLSorted' 5 [(1,15),(2,10),(3,13),(4,12),(5,11),(6,10),(7,1),(8,6),(9,6),(10,7),(11,7),(15,6),(16,6),(17,8),(18,8),(19,7),(20,7),(21,8),(22,8),(23,5),(24,5),(25,6),(26,6),(27,6),(28,7),(29,7),(30,8),(31,8),(32,8),(33,8),(34,5),(35,5),(36,9),(37,9),(38,5),(39,6),(40,6),(41,7),(42,7),(43,6),(44,6),(45,4),(46,4),(47,15),(48,15),(49,8),(50,12),(51,12),(52,8),(53,8),(54,8),(66,10)]
{-# INLINE s0DuratD1 #-}

-- |
s0DuratD2 :: Sound8 -> Word8
s0DuratD2 = getBFstLSorted' 5 [(1,15),(2,15),(3,15),(4,14),(5,11),(6,11),(7,1),(8,4),(9,4),(10,5),(11,5),(15,6),(16,6),(17,4),(18,4),(19,4),(20,4),(21,3),(22,3),(23,5),(24,5),(25,4),(26,4),(27,5),(28,6),(29,6),(30,8),(31,8),(32,3),(33,3),(34,4),(35,4),(36,5),(37,5),(38,3),(39,7),(40,7),(41,7),(42,7),(43,9),(44,9),(45,3),(46,3),(47,5),(48,5),(49,3),(50,3),(51,3),(52,5),(53,5),(54,4),(66,4)]
s0DuratD2 = getBFstLSorted' 5 [(1,15),(2,15),(3,15),(4,14),(5,11),(6,11),(7,1),(8,4),(9,4),(10,5),(11,5),(15,6),(16,6),(17,4),(18,4),(19,4),(20,4),(21,3),(22,3),(23,5),(24,5),(25,4),(26,4),(27,5),(28,6),(29,6),(30,8),(31,8),(32,3),(33,3),(34,4),(35,4),(36,5),(37,5),(38,3),(39,7),(40,7),(41,7),(42,7),(43,9),(44,9),(45,3),(46,3),(47,5),(48,5),(49,3),(50,3),(51,3),(52,5),(53,5),(54,4),(66,4)]
{-# INLINE s0DuratD2 #-}

s0DuratD3 :: Sound8 -> Word8
Expand All @@ -39,17 +39,6 @@ s0DuratD4 :: Sound8 -> Word8
s0DuratD4 = getBFstLSorted' 5 [(1,12),(2,12),(3,12),(4,12),(5,12),(6,12),(7,1),(8,5),(9,5),(10,10),(11,10),(15,5),(16,5),(17,8),(18,8),(19,8),(20,8),(21,13),(22,13),(23,10),(24,10),(25,5),(26,5),(27,4),(28,10),(29,10),(30,15),(31,15),(32,8),(33,8),(34,4),(35,4),(36,6),(37,6),(38,4),(39,12),(40,12),(41,14),(42,14),(43,11),(44,11),(45,6),(46,6),(47,4),(48,4),(49,6),(50,11),(51,11),(52,15),(53,15),(54,7),(66,5)]
{-# INLINE s0DuratD4 #-}

{-
help1 xs = map (\(t, u) -> (t,fromMaybe 15 . hh $ u)) xs
where !h = snd . head $ xs
!lt = snd . last $ xs
!del = (lt - h)/14.0
!ys = take 15 . iterate (+del) $ h
!zs = zip [1..15] ys
gg !u = fromMaybe lt . round2GL True (\_ _ -> EQ) ys $ u
hh !u = fmap fst . find ((== gg u) . snd) $ zs
-}

class (Eq a) => SyllableDurations4 a where
sDuratsD :: a -> Word8
sDuratsD2 :: a -> Word8
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@

* Second version. Added possibility to specify sequence of Word8 numbers as durations to be compared with in the +ln ... -ln command line arguments group.

## 0.2.1.0 -- 2024-09-28

* Second version revised A. Updated dependencies. Some minor code usability improvements.

14 changes: 7 additions & 7 deletions aftovolio.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: aftovolio
version: 0.2.0.0
version: 0.2.1.0

-- A short (one-line) description of the package.
synopsis: An AFTOVolio implementation for creating texts with special phonetic / prosodic properties.
Expand All @@ -27,8 +27,8 @@ library
exposed-modules: Aftovolio.Ukrainian.Common2, Aftovolio.Ukrainian.IO, Aftovolio.Ukrainian.PrepareText, Aftovolio.Ukrainian.ReverseConcatenations, Aftovolio.DataG, Aftovolio.StrictVG, Aftovolio.Partir, Data.ChooseLine2, Aftovolio.PermutationsArr, Aftovolio.PermutationsArrMini, Aftovolio.PermutationsArrMini1, Aftovolio.PermutationsRepresent, Aftovolio.Constraints, Aftovolio.ConstraintsEncoded, Aftovolio.Tests, Aftovolio.Ukrainian.Syllable, Aftovolio.Ukrainian.Melodics, Aftovolio.Ukrainian.SyllableWord8, Aftovolio.Basis, Aftovolio.UniquenessPeriodsG, Aftovolio.Coeffs, Aftovolio.Ukrainian.ReadDurations, Aftovolio.General.Datatype3, Aftovolio.General.Distance, Aftovolio.Halfsplit, Aftovolio.General.Parsing, Aftovolio.General.Base, Aftovolio.General.PrepareText, Aftovolio.General.Simple, Aftovolio.General.SpecificationsRead, Aftovolio.General.Syllables, Aftovolio.RGLPK.General

-- LANGUAGE extensions used by modules in this package.
other-extensions: NoImplicitPrelude, BangPatterns, DeriveGeneric
build-depends: base >=4.13 && <5, rhythmic-sequences ==0.8.0.0, cli-arguments ==0.7.0.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >= 2.2.2 && <3, mmsyn2-array ==0.3.1.1, minmax ==0.1.1.0, deepseq >=1.4.4.0 && <2, monoid-insertleft ==0.1.0.1, intermediate-structures ==0.1.1.0, quantizer ==0.3.1.0, containers >=0.5.11.0 && <1, lists-flines == 0.1.3.0
other-extensions: NoImplicitPrelude, BangPatterns, DeriveGeneric, StrictData
build-depends: base >=4.13 && <5, rhythmic-sequences ==0.8.0.0, cli-arguments ==0.7.0.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >= 2.2.2 && <3, mmsyn2-array ==0.3.1.1, minmax ==0.1.1.0, deepseq >=1.4.4.0 && <2, monoid-insertleft ==0.1.0.1, intermediate-structures ==0.1.2.0, quantizer ==0.4.0.0, containers >=0.5.11.0 && <1, lists-flines == 0.1.3.0
hs-source-dirs: .
default-language: Haskell2010

Expand All @@ -39,16 +39,16 @@ executable aftovolioUkr
other-modules: Aftovolio.Ukrainian.Common2, Aftovolio.Ukrainian.IO, Aftovolio.Ukrainian.PrepareText, Aftovolio.Ukrainian.ReverseConcatenations, Aftovolio.DataG, Aftovolio.StrictVG, Aftovolio.Partir, Data.ChooseLine2, Aftovolio.PermutationsArr, Aftovolio.PermutationsArrMini, Aftovolio.PermutationsArrMini1, Aftovolio.PermutationsRepresent, Aftovolio.Constraints, Aftovolio.ConstraintsEncoded, Aftovolio.Tests, Aftovolio.Ukrainian.Syllable, Aftovolio.Ukrainian.Melodics, Aftovolio.Ukrainian.SyllableWord8, Aftovolio.Basis, Aftovolio.UniquenessPeriodsG, Aftovolio.Coeffs, Aftovolio.Ukrainian.ReadDurations, Aftovolio.General.Datatype3, Aftovolio.General.Distance, Aftovolio.Halfsplit, Aftovolio.General.Parsing, Aftovolio.General.Base, Aftovolio.General.PrepareText, Aftovolio.General.Simple, Aftovolio.General.SpecificationsRead, Aftovolio.General.Syllables, Aftovolio.RGLPK.General
ghc-options: -threaded -rtsopts
-- LANGUAGE extensions used by modules in this package.
other-extensions: NoImplicitPrelude, BangPatterns, DeriveGeneric
build-depends: base >=4.13 && <5, rhythmic-sequences ==0.8.0.0, cli-arguments ==0.7.0.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >= 2.2.2 && <3, mmsyn2-array ==0.3.1.1, minmax ==0.1.1.0, deepseq >=1.4.4.0 && <2, monoid-insertleft ==0.1.0.1, intermediate-structures ==0.1.1.0, quantizer ==0.3.1.0, containers >=0.5.11.0 && <1, lists-flines == 0.1.3.0
other-extensions: NoImplicitPrelude, BangPatterns, DeriveGeneric, StrictData
build-depends: base >=4.13 && <5, rhythmic-sequences ==0.8.0.0, cli-arguments ==0.7.0.0, directory >=1.3.4.0 && <2, rev-scientific ==0.2.1.0, async >= 2.2.2 && <3, mmsyn2-array ==0.3.1.1, minmax ==0.1.1.0, deepseq >=1.4.4.0 && <2, monoid-insertleft ==0.1.0.1, intermediate-structures ==0.1.2.0, quantizer ==0.4.0.0, containers >=0.5.11.0 && <1, lists-flines == 0.1.3.0
hs-source-dirs: src, .
default-language: Haskell2010

executable unconcatUkr2
main-is: Main.hs
other-modules: Aftovolio.Ukrainian.ReverseConcatenations
other-extensions: BangPatterns, NoImplicitPrelude
build-depends: base >=4.13 && <5, mmsyn2-array ==0.3.1.1, intermediate-structures == 0.1.1.0
other-extensions: BangPatterns, NoImplicitPrelude, StrictData
build-depends: base >=4.13 && <5, mmsyn2-array ==0.3.1.1, intermediate-structures == 0.1.2.0
ghc-options: -threaded -rtsopts
hs-source-dirs: .
default-language: Haskell2010
Expand Down

0 comments on commit 73c00e3

Please sign in to comment.