phonetic-languages-phonetics-basics 0.7.0.0 → 0.8.0.0
raw patch · 3 files changed
+44/−11 lines, 3 filesdep +mmsyn3PVP ok
version bump matches the API change (PVP)
Dependencies added: mmsyn3
API changes (from Hackage documentation)
+ Data.Phonetic.Languages.PrepareText: growLinesN :: Int -> [String] -> [String]
+ Data.Phonetic.Languages.PrepareText: prepareGrowTextN :: Int -> [[String]] -> String -> String -> [String]
Files
- ChangeLog.md +5/−0
- Data/Phonetic/Languages/PrepareText.hs +36/−8
- phonetic-languages-phonetics-basics.cabal +3/−3
ChangeLog.md view
@@ -90,3 +90,8 @@ in the written text being pronounced and the introduction more general concept of phonemes that creates syllable instead of simpler vowel notion. Removed the module Data.Phonetic.Languages.Undefined as one being not necessary.++## 0.8.0.0 -- 2021-07-24++* Eigth version. Added new functions to the Data.Phonetic.Languages.PrepareText module to 'grow' the phonetic+languages text. Some code improvements in the module.
Data/Phonetic/Languages/PrepareText.hs view
@@ -27,8 +27,6 @@ module Data.Phonetic.Languages.PrepareText ( Concatenations -- * Basic functions- , prepareText- , prepareTextN , complexWords , splitLines , splitLinesN@@ -37,6 +35,11 @@ , toSequentialApp , prepareConcats , complexNWords+ -- * The end-user functions+ , prepareText+ , prepareTextN+ , growLinesN+ , prepareGrowTextN -- * Used to transform after convertToProperphonetic language from mmsyn6ukr package , isPLL ) where@@ -66,8 +69,8 @@ -> String -- ^ A sorted 'String' of possible characters in the phonetic language representation. -> String -> [String]-prepareText ysss xs = filter (any (isPLL xs)) . splitLines . map (unwords . complexNWords ysss . words .- filter (\t -> isAlpha t || isSpC t)) . filter (not . null) . lines+prepareText = prepareTextN 7+{-# INLINE prepareText #-} sort2Concat :: [[String]]@@ -137,10 +140,8 @@ -- | The function is recursive and is applied so that all returned elements ('String') are no longer than 7 words in them. splitLines :: [String] -> [String]-splitLines xss- | null xss = []- | otherwise = mapI (\xs -> compare (length . words $ xs) 7 == GT) (\xs -> let yss = words xs in- splitLines . map unwords . (\(q,r) -> [q,r]) . splitAt (length yss `quot` 2) $ yss) $ xss+splitLines = splitLinesN 7+{-# INLINE splitLines #-} -- | A generalized variant of the 'splitLines' with the arbitrary maximum number of the words in the lines given as the first argument. splitLinesN :: Int -> [String] -> [String]@@ -149,3 +150,30 @@ | otherwise = mapI (\xs -> compare (length . words $ xs) n == GT) (\xs -> let yss = words xs in splitLines . map unwords . (\(q,r) -> [q,r]) . splitAt (length yss `quot` 2) $ yss) $ xss +------------------------------------------------++{-| @ since 0.8.0.0+Given a positive number and a list tries to rearrange the list's 'String's by concatenation of the several elements of the list+so that the number of words in every new 'String' in the resulting list is not greater than the 'Int' argument. If some of the+'String's have more than that number quantity of the words then these 'String's are preserved.+-}+growLinesN :: Int -> [String] -> [String]+growLinesN n xss+ | null xss || n < 0 = []+ | otherwise = unwords yss : growLinesN n zss+ where l = length . takeWhile (<= n) . scanl1 (+) . map (length . words) $ xss -- the maximum number of lines to be taken+ (yss,zss) = splitAt (max l 1) xss++{-| @ since 0.8.0.0+The function combines the 'prepareTextN' and 'growLinesN' function. Applies needed phonetic language preparations+to the text and tries to \'grow\' the resulting 'String's in the list so that the number of the words in every+of them is no greater than the given 'Int' number. +-} +prepareGrowTextN+ :: Int -- ^ A maximum number of the words or their concatenations in the resulting list of 'String's.+ -> [[String]] -- ^ Is intended to become a valid 'Concatenations'.+ -> String -- ^ A sorted 'String' of possible characters in the phonetic language representation.+ -> String+ -> [String]+prepareGrowTextN n ysss xs = growLinesN n . prepareTextN n ysss xs+{-# INLINE prepareGrowTextN #-}
phonetic-languages-phonetics-basics.cabal view
@@ -3,7 +3,7 @@ -- http://haskell.org/cabal/users-guide/ name: phonetic-languages-phonetics-basics-version: 0.7.0.0+version: 0.8.0.0 synopsis: A library for working with generalized phonetic languages usage. description: There already exists a Ukrainian implementation for the phonetic languages approach published at: https://hackage.haskell.org/package/phonetic-languages-simplified-examples-array. It is optimized for the Ukrainian only and needs to be rewritten for every new language mostly from scratch using it as a template. To avoid this boilerplate, this one is provided. It can be used for different languages and even for music or other fields. Now it combines the functionality of the @r-glpk-phonetic-languages-ukrainian-durations@ and @phonetic-languages-ukrainian-array@ and some dependencies of the mentioned one. homepage: https://hackage.haskell.org/package/phonetic-languages-phonetics-basics@@ -22,7 +22,7 @@ other-modules: Main other-extensions: CPP, BangPatterns, UnboxedTuples, MagicHash, MultiParamTypeClasses, FlexibleInstances ghc-options: -funbox-strict-fields -fobject-code- build-depends: base >=4.8 && <4.15, mmsyn2-array >=0.1.3 && <1, mmsyn5 >=0.5 && <1, lists-flines >=0.1.1 && <1, foldable-ix >=0.2 && <1+ build-depends: base >=4.8 && <4.15, mmsyn2-array >=0.1.3 && <1, mmsyn3 >= 0.1.5 && <1, mmsyn5 >=0.5 && <1, lists-flines >=0.1.1 && <1, foldable-ix >=0.2 && <1 -- hs-source-dirs: default-language: Haskell2010 @@ -30,6 +30,6 @@ main-is: Main.hs other-modules: Data.Phonetic.Languages.Base, Data.Phonetic.Languages.Syllables, Numeric.Wrapper.R.GLPK.Phonetic.Languages.Durations, Data.Phonetic.Languages.SpecificationsRead, Data.Phonetic.Languages.PrepareText -- other-extensions:- build-depends: base >=4.8 && <4.15, mmsyn2-array >=0.1.1 && <1, mmsyn5 >=0.5 && <1, lists-flines >=0.1.1 && <1, foldable-ix >=0.1 && <1+ build-depends: base >=4.8 && <4.15, mmsyn2-array >=0.1.1 && <1, mmsyn3 >= 0.1.5 && <1, mmsyn5 >=0.5 && <1, lists-flines >=0.1.1 && <1, foldable-ix >=0.1 && <1 -- hs-source-dirs: default-language: Haskell2010