packages feed

ukrainian-phonetics-basic 0.1.10.0 → 0.1.11.0

raw patch · 3 files changed

+15/−34 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -45,3 +45,10 @@  * First version revised J. Fixed issues with rare complex letter combinations in the Melodics.ByteString.Ukrainian module. The applyChanges uses now strict in the accumulator  version of the foldr -- foldr'.++## 0.1.11.0 -- 2020-11-06++* First version revised K. Some code improvements to do it more flexible in the module Melodics.ByteString.Ukrainian. Switched to the lazy version of the foldr in the applyChanges +function.++
Melodics/ByteString/Ukrainian.hs view
@@ -35,10 +35,8 @@ import qualified Data.Vector.Unboxed as V import qualified Data.Vector as VB import qualified Data.ByteString.Char8 as B-import qualified Data.Foldable as F import CaseBi.Unboxed (getBFst') import qualified CaseBi as X (getBFst')-import Data.List.InnToOut.Basic (mapI)  {- -- Inspired by: https://mail.haskell.org/pipermail/beginners/2011-October/008649.html@@ -51,40 +49,33 @@ -- It is not exact phonetically but you can make for yourself a general impression of the Ukrainian sounding. convertToProperUkrainian :: String -> V.Vector Char convertToProperUkrainian = toVector . convertToProperUkrainianS-{-# INLINE convertToProperUkrainian #-}  -- | The function that converts a written Ukrainian text into the sounding in the program phonetical respesentation. -- It is not exact phonetically but you can make for yourself a general impression of the Ukrainian sounding. convertToProperUkrainianV :: VB.Vector Char -> V.Vector Char convertToProperUkrainianV = toVector . convertToProperUkrainianV2S-{-# INLINE convertToProperUkrainianV #-}  -- | Unlike the 'convertToProperUkrainian', it returns a boxed 'VB.Vector' instead of unboxed one 'V.Vector', -- @ since 0.1.2.0 convertToProperUkrainianX :: String -> VB.Vector Char convertToProperUkrainianX = toVectorB . convertToProperUkrainianS-{-# INLINE convertToProperUkrainianX #-}  -- | Unlike the 'convertToProperUkrainianV', it returns a boxed 'VB.Vector' instead of unboxed one 'V.Vector', -- @ since 0.1.2.0 convertToProperUkrainianV2X :: VB.Vector Char -> VB.Vector Char convertToProperUkrainianV2X = toVectorB . convertToProperUkrainianV2S-{-# INLINE convertToProperUkrainianV2X #-}  convertToProperUkrainianS :: String -> String convertToProperUkrainianS = correctB . correctA . applyChanges . bsToCharUkr . createTuplesByAnalysis . secondConv . filterUkr . changeIotated .    filter (\x -> isUkrainianL x || isSpace x || isControl x || isPunctuation x) . map toLower-{-# INLINE convertToProperUkrainianS #-}  convertToProperUkrainianV2S :: VB.Vector Char -> String convertToProperUkrainianV2S = correctB . correctA . applyChanges . bsToCharUkr . createTuplesByAnalysis . secondConv . filterUkr . changeIotated . VB.toList .   VB.filter (\x -> isUkrainianL x || isSpace x || isControl x || isPunctuation x) . VB.map toLower-{-# INLINE convertToProperUkrainianV2S #-}  isUkrainianL :: Char -> Bool isUkrainianL y | (y >= '\1070' && y <= '\1097') = True                | otherwise = getBFst' (False, V.fromList . map (\x -> (x, True)) $ "'-\700\1028\1030\1031\1068\1100\1102\1103\1108\1110\1111\1168\1169\8217") y-{-# INLINE isUkrainianL #-}  changeIotated :: String -> String changeIotated (x:y:zs)@@ -110,7 +101,6 @@   where f y          | isSpace y || isControl y = B.singleton '1'          | otherwise = X.getBFst' (B.singleton y, VB.fromList $ zip "'-GHIJKLM" [B.singleton '0',B.singleton '0',"FE","Cu","Ca","Ce","Ci",B.singleton '0',B.singleton '0']) y-{-# INLINE secondConv #-}  createTuplesByAnalysis :: B.ByteString -> [(B.ByteString, Triple)] createTuplesByAnalysis x@@ -130,8 +120,7 @@        if X.getBFst' (False, VB.fromList $ zip ["cq","dB","dz","nt","sq","st","tq","ts","xh"] (repeat True)) us         then (B.copy us, T):initialA vs         else (B.singleton t, T):initialA ts-  | otherwise = case getBFst' (False, V.fromList . zip "BEFfhkpz" . repeat $ True) t of-          ~True -> (B.singleton t, T):initialA ts+  | otherwise = (B.singleton t, T):initialA ts       where (t,ts) = fromJust . B.uncons $ t1  @@ -140,7 +129,6 @@   | isSpace x || isControl x || x == '-' = O   | getBFst' (False, V.fromList $ zip "BEFcdfhknpstxz" (repeat True)) x = T   | otherwise = Z-{-# INLINE canChange #-}  bsToCharUkr :: [(B.ByteString,Triple)] -> [(Char,Triple)] bsToCharUkr zs@@ -150,10 +138,9 @@              | B.null ts = ('0',Z)              | otherwise = (X.getBFst' (B.head ts, VB.fromList . zip ["cq","dB","dz","nt","sq","st","tq","ts","xh"] $ "wjANDOPch") ts,k) - applyChanges :: [(Char, Triple)] -> [(Char, Triple)] applyChanges [] = []-applyChanges ys = F.foldr' f v ys+applyChanges ys = foldr f v ys   where v = []         f x xs           | null xs = (:[]) . (\(y,_) -> (y, Z)) $ x@@ -166,25 +153,20 @@ isVoicedObstruent :: B.ByteString -> Bool isVoicedObstruent = X.getBFst' (False, VB.fromList [("A",True),("B",True),("Q",True),("R",True),("T",True),("b",True),("d",True),("g",True),("h",True),   ("j",True),("z", True)]) . B.take 1-{-# INLINE isVoicedObstruent #-}  isVoicedObstruentH :: B.ByteString -> Bool isVoicedObstruentH = X.getBFst' (False, VB.fromList [("A",True),("B",True),("b",True),("d",True),("g",True),("h",True),("j",True),("z", True)]) . B.take 1-{-# INLINE isVoicedObstruentH #-}  isVoicedObstruentS :: B.ByteString -> Bool-isVoicedObstruentS = (`elem` ["Q","R","T"]) . B.take 1-{-# INLINE isVoicedObstruentS #-}+isVoicedObstruentS = (\u -> any (== u) ["Q","R","T"]) . B.take 1  isSoftDOrL :: [(Char, Triple)] -> Bool isSoftDOrL xs = X.getBFst' (False, VB.fromList . zip ["bq","cq","dq","fq","lq","mq","nq","pq","sq","tq","vq"] $ (repeat True)) (takeFromFT_ 2 xs) ||   X.getBFst' (False, VB.fromList . zip ["P","Q","R","S","T"] . repeat $ True) (takeFromFT_ 1 xs)-{-# INLINE isSoftDOrL #-}  isSoftDen :: [(Char, Triple)] -> Bool isSoftDen xs = X.getBFst' (False, VB.fromList . zip ["Aq","cq","dq","lq","nq","sq","tq","zq"] $ (repeat True)) (takeFromFT_ 2 xs) ||   X.getBFst' (False, VB.fromList . zip ["P","Q","R","S","T"] . repeat $ True) (takeFromFT_ 1 xs)-{-# INLINE isSoftDen #-}  -- in the further ??T functions the last (, T) means that it must be afterwards be separated with the soft sign into two tuples (1 additional function in the composition) -- need further processing means that there should be additional checks and may be transformations. May be they can be omitted@@ -327,15 +309,12 @@  takeFromFT_ :: Int -> [(Char, Triple)] -> B.ByteString takeFromFT_ n = takeFromFT n . filter (\(x, _) -> x /= '1' && x /= '0')-{-#INLINE takeFromFT_  #-}  correctA :: [(Char, Triple)] -> [Char] correctA = correctSomeW . separateSoftS-{-# INLINE correctA #-}  separateSoftS :: [(Char, Triple)] -> [Char] separateSoftS = concatMap divideToParts-{-# INLINE separateSoftS #-}  correctSomeW :: [Char] -> [Char] correctSomeW (x:y:z:xs@(t:ys))@@ -350,15 +329,12 @@ divideToParts :: (Char, Triple) -> [Char] divideToParts (x, z) = X.getBFst' ([x], VB.fromList . zip "NOPQRST" $   ["nt", "st", "tq", "Aq", "zq", "nq", "dq"]) . fst $ (x, z)-{-# INLINE divideToParts #-}  toVector :: [Char] -> V.Vector Char-toVector ts = V.fromList . correctB $ ts-{-# INLINE toVector #-}+toVector = V.fromList . correctB  toVectorB :: [Char] -> VB.Vector Char-toVectorB ts = VB.fromList . correctB $ ts-{-# INLINE toVectorB #-}+toVectorB = VB.fromList . correctB  correctB :: [Char] -> [Char] correctB ys@(x:xs)@@ -368,13 +344,11 @@  -- | A variant of the 'convertToProperUkrainian' with the 'B.ByteString' result. convertToProperUkrainianB :: String -> B.ByteString-convertToProperUkrainianB ys = B.pack . convertToProperUkrainianS $ ys-{-# INLINE convertToProperUkrainianB #-}+convertToProperUkrainianB = B.pack . convertToProperUkrainianS  -- | A variant of the 'convertToProperUkrainianV' with the 'B.ByteString' result. convertToProperUkrainianV2B :: VB.Vector Char -> B.ByteString-convertToProperUkrainianV2B v = B.pack . convertToProperUkrainianV2S $ v-{-# INLINE convertToProperUkrainianV2B #-}+convertToProperUkrainianV2B = B.pack . convertToProperUkrainianV2S  linkFileName :: Char -> Char linkFileName x = getBFst' (x,V.fromList . zip "ABCDEFLMabcdefghijklmnopqrstuvwxyz" $ "GILUbc00ABZEHXfDeFMNOPQRdSTVWCaYKJ") x
ukrainian-phonetics-basic.cabal view
@@ -2,7 +2,7 @@ -- further documentation, see http://haskell.org/cabal/users-guide/  name:                ukrainian-phonetics-basic-version:             0.1.10.0+version:             0.1.11.0 synopsis:            A library to work with the basic Ukrainian phonetics and syllable segmentation. description:         A library to work with the basic Ukrainian phonetics and syllable segmentation. Rewritten from the mmsyn6ukr and mmsyn7s packages. homepage:            https://hackage.haskell.org/package/ukrainian-phonetics-basic