packages feed

phonetic-languages-phonetics-basics 0.6.0.1 → 0.6.1.0

raw patch · 3 files changed

+56/−13 lines, 3 files

Files

ChangeLog.md view
@@ -67,3 +67,8 @@ ## 0.6.0.1 -- 2021-05-04  * Sixth version revised A. Extended the data in the EnglishConcatenated.txt file. Fixed some issues with the README.md file. ++## 0.6.1.0 -- 2021-05-07++* Sixth version revised B. Fixed issues with wrong order of the concatenations in the Data.Phonetic.Languages.PrepareText+functions. Added some new functions for this.
Data/Phonetic/Languages/PrepareText.hs view
@@ -33,6 +33,10 @@   , splitLines   , splitLinesN   , isSpC+  , sort2Concat+  , toSequentialApp+  , prepareConcats+  , complexNWords   -- * Used to transform after convertToProperphonetic language from mmsyn6ukr package   , isPLL ) where@@ -41,6 +45,7 @@ import Data.List.InnToOut.Basic (mapI) import Data.Char (isAlpha,toLower) import GHC.Arr+import Data.List (sort,sortOn)  {-| The lists in the list are sorted in the descending order by the word counts in the inner 'String's. All the 'String's in each inner list have the same number of words, and if there is no 'String' with some intermediate number of words (e. g. there@@ -57,25 +62,58 @@ -- words that \"should\" be paired and not dealt with separately -- to avoid the misinterpretation and preserve maximum of the semantics for the -- \"phonetic\" language on the phonetic language basis.-prepareText :: Concatenations -> String -> String -> [String]-prepareText ysss xs = filter (any (isPLL xs)) . splitLines . map (unwords . complexWords ysss ysss . words .+prepareText+  :: [[String]] -- ^ Is intended to become a valid 'Concatenations'.+  -> 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 +sort2Concat :: [[String]] -> Concatenations+sort2Concat xsss+ | null xsss = []+ | otherwise = map sort . reverse . sortOn (map (length . words)) $ xsss++toSequentialApp :: Concatenations -> [Concatenations]+toSequentialApp ysss@(xss:xsss)+ | null xss = toSequentialApp xsss+ | otherwise = [xss, replicate (n - 1) []] : toSequentialApp xsss+     where n = length . words . head $ xss+toSequentialApp _ = []++prepareConcats :: [[String]] -> [Concatenations]+prepareConcats = toSequentialApp . sort2Concat+{-# INLINABLE prepareConcats #-}++complexNWords :: [[String]] -> [String] -> [String]+complexNWords xsss yss = complexNWords' tssss yss+  where tssss = prepareConcats xsss+        complexNWords' tssss@(ysss:zssss) uss = complexNWords' zssss . complexWords ysss ysss $ uss+        complexNWords' _ uss = uss+ -- | Concatenates complex words in phonetic language so that they are not separated further by possible words order rearrangements (because they are treated -- as a single word). This is needed to preserve basic grammar in phonetic languages. complexWords :: Concatenations -> Concatenations -> [String] -> [String]-complexWords rsss ysss@(yss:tsss) zss@(ts:xss)- | null yss = complexWords rsss tsss zss- | otherwise =-    let y = length . words . head $ yss-        uwxs = unwords . take y $ zss in getBFstL' (complexWords rsss tsss zss) (map (\ys ->-           (ys,complexWords rsss tsss ((filter (/= ' ') ys ++ ts):xss))) yss) uwxs-complexWords rsss [] zss@(xs:xss) = xs:complexWords rsss rsss xss-complexWords _ _ [] = []+complexWords rsss ysss zss+ = map (\(ts,_,_) -> ts) . foldr f v $ zss+    where v = [([],rsss,ysss)]+          f z rs@((t,rsss,(yss:tsss)):ks)+            | null yss = f z ((t,rsss,tsss):ks)+            | getBFstL' False (zip yss . replicate 10000 $ True) uwxs = (filter (/= ' ') uwxs `mappend` t,rsss,rsss):ks+            | otherwise = f z ((t,rsss,tsss):ks)+                  where y = length . words . head $ yss+                        uwxs = unwords . take y . map (\(q,_,_) -> q) $ rs+          f z rs@((t,rsss,[]):ks) = (z,rsss,rsss):rs  -- | A generalized variant of the 'prepareText' with the arbitrary maximum number of the words in the lines given as the first argument.-prepareTextN :: Int -> Concatenations -> String -> String -> [String]-prepareTextN n ysss xs = filter (any (isPLL xs)) . splitLinesN n . map (unwords . complexWords ysss ysss . words .+prepareTextN+ :: 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]+prepareTextN n ysss xs = filter (any (isPLL xs)) . splitLinesN n . map (unwords . complexNWords ysss . words .   filter (\t -> isAlpha t || isSpC t)) . filter (not . null) . lines  isSpC :: Char -> Bool
phonetic-languages-phonetics-basics.cabal view
@@ -3,7 +3,7 @@ -- http://haskell.org/cabal/users-guide/  name:                phonetic-languages-phonetics-basics-version:             0.6.0.1+version:             0.6.1.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