phonetic-languages-phonetics-basics 0.10.1.0 → 0.11.0.0
raw patch · 9 files changed
+51/−39 lines, 9 filesdep +intermediate-structuresdep −foldable-ixdep −mmsyn3dep −mmsyn5PVP ok
version bump matches the API change (PVP)
Dependencies added: intermediate-structures
Dependencies removed: foldable-ix, mmsyn3, mmsyn5
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- LICENSE +1/−1
- Phladiprelio/General/Base.hs +2/−2
- Phladiprelio/General/PrepareText.hs +9/−8
- Phladiprelio/General/SpecificationsRead.hs +2/−1
- Phladiprelio/General/Syllables.hs +15/−12
- Phladiprelio/RGLPK/General.hs +5/−6
- README.md +6/−3
- phonetic-languages-phonetics-basics.cabal +7/−6
ChangeLog.md view
@@ -142,3 +142,7 @@ representations where possible to use one less level of redirection for the compiler (experimental and not well tested move). Added a devotion to the README.md file. +## 0.11.0.0 -- 2024-01-30++* Eleventh version. Removed deprecated dependencies, switched to more lightweight ones. Some minor code improvements. Added bug-tracker.+
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2021-2023 Oleksandr Zhabenko+Copyright (c) 2021-2024 Oleksandr Zhabenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
Phladiprelio/General/Base.hs view
@@ -7,12 +7,12 @@ -- | -- Module : Phladiprelio.General.Base--- Copyright : (c) Oleksandr Zhabenko 2021-2023+-- Copyright : (c) Oleksandr Zhabenko 2021-2024 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com ----- This is a computational scheme for generalized usage of the phonetic languages approach. +-- This is a computational scheme for generalized usage of the phonetic languages and PhLADiPreLiO approach. -- It is intended to be exported qualified, so that the functions in every language -- implementation have the same names and signatures as these ones and the data type used here. -- It is may be not the most efficient implementation.
Phladiprelio/General/PrepareText.hs view
@@ -1,10 +1,10 @@ {-# OPTIONS_HADDOCK show-extensions #-} -{-# LANGUAGE MultiWayIf, NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude #-} -- | -- Module : Phladiprelio.General.PrepareText--- Copyright : (c) Oleksandr Zhabenko 2020-2023+-- Copyright : (c) Oleksandr Zhabenko 2020-2024 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com@@ -52,7 +52,7 @@ import Data.Bits (shiftR) import GHC.Num ((+),(-),abs) import CaseBi.Arr (getBFstL',getBFst')-import Data.List.InnToOut.Basic (mapI)+import Data.IntermediateStructures1 (mapI) import Data.Char (isAlpha,toLower) import GHC.Arr import Data.Tuple (fst)@@ -111,10 +111,11 @@ pairCompl (f,xs) = (f [],xs) splitWords :: ConcatenationsArr -> [String] -> String -> (String,String)-splitWords ysss tss zs = let (ws,us) = pairCompl . complexWords2 ysss $ zs in if- | null . words $ zs -> (mconcat tss,[])- | null ws -> (\(xss,uss) -> (mconcat (tss `mappend` xss), unwords uss)) . splitAt 1 . words $ zs- | otherwise -> splitWords ysss (tss `mappend` [ws]) us+splitWords ysss tss zs + | null . words $ zs = (mconcat tss,[])+ | null ws = (\(xss,uss) -> (mconcat (tss `mappend` xss), unwords uss)) . splitAt 1 . words $ zs+ | otherwise = splitWords ysss (tss `mappend` [ws]) us+ where (ws,us) = pairCompl . complexWords2 ysss $ zs concatWordsFromLeftToRight :: ConcatenationsArr -> String -> [String] concatWordsFromLeftToRight ysss zs = let (ws,us) = splitWords ysss [] zs in@@ -146,7 +147,7 @@ -- | A predicate to check whether the given character is one of the \"\' \\x2019\\x02BC-\". isSpC :: Char -> Bool-isSpC x = x == '\'' || x == ' ' || x == '\x2019' || x == '\x02BC' || x == '-'+isSpC x = x == '\'' || x == ' ' || x == '\x2019' || x == '\x02BC' || x == '-' || x == '_' || x == '=' {-# INLINE isSpC #-} {-# DEPRECATED #-}
Phladiprelio/General/SpecificationsRead.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Phladiprelio.General.SpecificationsRead--- Copyright : (c) Oleksandr Zhabenko 2021-2023+-- Copyright : (c) Oleksandr Zhabenko 2021-2024 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com@@ -27,6 +27,7 @@ charLine :: Char -> String -> Bool charLine c = (== [c]) . take 1+{-# INLINE charLine #-} groupBetweenChars :: Char -- ^ A delimiter (can be used probably multiple times) used between different parts of the data.
Phladiprelio/General/Syllables.hs view
@@ -10,7 +10,7 @@ -- | -- Module : Phladiprelio.General.Syllables--- Copyright : (c) Oleksandr Zhabenko 2021-2023+-- Copyright : (c) Oleksandr Zhabenko 2021-2024 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com@@ -57,13 +57,12 @@ import GHC.Base import GHC.List-import Data.Monoid import qualified Data.List as L (groupBy,find,intercalate,words) import Phladiprelio.General.Base import CaseBi.Arr import GHC.Arr import GHC.Exts-import Data.List.InnToOut.Basic (mapI)+import Data.IntermediateStructures1 (mapI) import Data.Maybe (mapMaybe,fromJust) import GHC.Int import Text.Read (Read(..),readMaybe)@@ -96,7 +95,7 @@ data PhoneticType = P {-# UNPACK #-} !Int8 deriving (Eq, Ord, Read) instance Show PhoneticType where- show (P x) = "P " `mappend` show x+ show (P x) = 'P':' ':show x fromPhoneticType :: PhoneticType -> Int fromPhoneticType (P x) = fromEnum x@@ -126,7 +125,6 @@ | otherwise = Nothing where !n# = (i# +# j#) `quotInt#` 2# !p = unsafeAt arr (I# n#)-{-# INLINABLE gBF4 #-} findC :: Char@@ -136,10 +134,12 @@ where !(I# i#,I# j#) = bounds arr !k = unsafeAt arr (I# i#) !m = unsafeAt arr (I# i#)+{-# INLINE findC #-} str2PRSs :: CharPhoneticClassification -> String -> StringRepresentation str2PRSs arr = map (\c -> fromJust . findC c $ arr)- +{-# INLINE str2PRSs #-}+ -- | Function-predicate 'createsSyllable' checks whether its argument is a phoneme representation that -- every time being presented in the text leads to the creation of the new syllable (in the 'PRS' format). -- Usually it is a vowel, but in some languages there can be syllabic phonemes that are not considered to be@@ -150,18 +150,18 @@ -- | Function-predicate 'isSonorous1' checks whether its argument is a sonorous consonant representation in the 'PRS' format. isSonorous1 :: PRS -> Bool-isSonorous1 = (`elem` [P 1,P 2]) . phoneType+isSonorous1 = (`elem` [1,2]) . fromPhoneticType . phoneType {-# INLINE isSonorous1 #-} -- | Function-predicate 'isVoicedC1' checks whether its argument is a voiced consonant representation in the 'PRS' format. isVoicedC1 :: PRS -> Bool-isVoicedC1 = (`elem` [P 3,P 4]) . phoneType+isVoicedC1 = (`elem` [3,4]) . fromPhoneticType . phoneType {-# INLINE isVoicedC1 #-} -- | Function-predicate 'isVoiceless1' checks whether its argument is a voiceless consonant representation in the 'PRS' format. isVoicelessC1 :: PRS -> Bool-isVoicelessC1 = (`elem` [P 5,P 6]) . phoneType-{-# INLINE isVoicelessC1 #-}+isVoicelessC1 = (`elem` [5,6]) . fromPhoneticType . phoneType+{-# INLINE isVoicelessC1 #-} -- | Binary function-predicate 'notCreatesSyllable2' checks whether its arguments are both consonant representations in the 'PRS' format. notCreatesSyllable2 :: PRS -> PRS -> Bool@@ -181,15 +181,18 @@ | otherwise = cx /= cy where !cx = charS x !cy = charS y+{-# INLINE notEqC #-} -- | Function 'sndGroups' converts a word being a list of 'PRS' to the list of phonetically similar (consonants grouped with consonants and each vowel separately) -- sounds representations in 'PRS' format. sndGroups :: [PRS] -> [[PRS]] sndGroups ys@(_:_) = L.groupBy notCreatesSyllable2 ys sndGroups _ = []+{-# INLINE sndGroups #-} groupSnds :: [PRS] -> [[PRS]] groupSnds = L.groupBy (\x y -> createsSyllable x == createsSyllable y)+{-# INLINE groupSnds #-} data SegmentationInfo1 = SI { fieldN :: !Int8, -- ^ Number of fields in the pattern matching that are needed to apply the segmentation rules. Not less than 1.@@ -235,11 +238,11 @@ instance Eval2Bool (SegmentationPredFData PRS (Char, Char)) where eval2Bool (L i js arr) | all (<= n) js && i <= n && i >= 1 && all (>=1) js = fromPhoneticType (phoneType (unsafeAt arr $ i - 1)) `elem` js- | otherwise = error "Data.Phonetic.Languages.Syllables.eval2Bool: 'L' element is not properly defined. "+ | otherwise = error "Phladiprelio.General.Syllables.eval2Bool: 'L' element is not properly defined. " where n = numElements arr eval2Bool (NEC i j arr ks) | i >= 1 && j >= 1 && i /= j && i <= n && j <= n = notEqC ks (unsafeAt arr $ i - 1) (unsafeAt arr $ j - 1)- | otherwise = error "Data.Phonetic.Languages.Syllables.eval2Bool: 'NEC' element is not properly defined. "+ | otherwise = error "Phladiprelio.General.Syllables.eval2Bool: 'NEC' element is not properly defined. " where n = numElements arr eval2Bool (C x y) = eval2Bool x && eval2Bool y eval2Bool (D x y) = eval2Bool x || eval2Bool y
Phladiprelio/RGLPK/General.hs view
@@ -3,7 +3,7 @@ -- | -- Module : Phladiprelio.RGLPK.General--- Copyright : (c) Oleksandr Zhabenko 2020-2023+-- Copyright : (c) Oleksandr Zhabenko 2020-2024 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com@@ -43,12 +43,11 @@ import GHC.Num ((+),(-),(*),abs) import Data.Bits (shiftR) import Data.Lists.FLines (newLineEnding)-import Data.Foldable.Ix (findIdx1) import Text.Show (Show(..)) createCoeffsObj :: Int -> [String] -> [Double] createCoeffsObj l xss- | length xss < l = f (xss `mappend` replicate (l - length xss) "1.0")+ | length xss < l = f xss `mappend` replicate (l - length xss) 1.0 | otherwise = f (take l xss) where f = map (\ts -> fromMaybe 1.0 (readMaybe ts::Maybe Double)) @@ -58,10 +57,10 @@ | otherwise = map (length . filter (== x)) xss matrix1Column :: PairwiseC -> [String] -> String -> Char -> [Int]-matrix1Column pw xss js x = pairwiseComparings x pw (mconcat [countCharInWords xss x, rs, rs])+matrix1Column pw xss js x = pairwiseComparings x pw . mconcat $ [countCharInWords xss x, rs, rs] where l = length js- iX = fromMaybe (-l - 1) . findIdx1 x $ js- rs = if iX < 0 then [] else mconcat [replicate iX 0, [1], replicate (l - 1 - iX) 0]+ iX = fromMaybe (-l - 1) . elemIndex x $ js+ rs = if iX < 0 then [] else replicate iX 0 `mappend` (1:replicate (l - 1 - iX) 0) pairwiseComparings :: Char -> PairwiseC -> [Int] -> [Int] pairwiseComparings x y zs = zs `mappend` pairs' y x
README.md view
@@ -75,14 +75,17 @@ Devotion ======== --P.S.: the author would like to devote this project to support the [Foundation+The author would like to devote this project to support the [Foundation Gastrostars](https://gastrostars.nl). On the 22/09/2023 there is Nathalie's Kok birthday, the mother of the founder of the Foundation, [Emma Kok](https://www.emmakok.nl), and the member of the Foundation board. -If you would like to share some financial support, please, contact the mentioned foundation+On the 06/01/2024 there was Sophie's Kok, a sister of Emma Kok, 19th Birthday (she is 18). Therefore, the version 0.11.0.0 is additionally devoted also to her.++All support is welcome, including donations for the needs of the Ukrainian army, IDPs and refugees. ++If you would like to share some financial support with the Foundation Gastrostars, please, contact the mentioned foundation using the URL: [Contact Foundation GASTROSTARS](https://gastrostars.nl/hou-mij-op-de-hoogte)
phonetic-languages-phonetics-basics.cabal view
@@ -3,10 +3,11 @@ -- http://haskell.org/cabal/users-guide/ name: phonetic-languages-phonetics-basics-version: 0.10.1.0+version: 0.11.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.+description: There already exists a Ukrainian implementation for the phonetic languages approach published at: https://hackage.haskell.org/package/phonetic-languages-simplified-examples-array and PhLADiPreLiO implementation with newer ideas also for Ukrainian published at: https://hackage.haskell.org/package/phladiprelio-ukrainian-simple. They are optimized for the Ukrainian only and much of their functionalities need to be rewritten for every new language mostly from scratch using them as templates. 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 ones. homepage: https://hackage.haskell.org/package/phonetic-languages-phonetics-basics+bug-reports: https://github.com/Oleksandr-Zhabenko/phonetic-languages-phonetics-basics/issues license: MIT license-file: LICENSE author: OleksandrZhabenko@@ -20,16 +21,16 @@ library exposed-modules: Phladiprelio.General.Base, Phladiprelio.General.Syllables, Phladiprelio.RGLPK.General, Phladiprelio.General.SpecificationsRead, Phladiprelio.General.PrepareText other-modules: Main- other-extensions: BangPatterns, UnboxedTuples, MagicHash, MultiParamTypeClasses, FlexibleInstances, MultiWayIf, NoImplicitPrelude+ other-extensions: BangPatterns, UnboxedTuples, MagicHash, MultiParamTypeClasses, FlexibleInstances, NoImplicitPrelude ghc-options: -funbox-strict-fields -fobject-code- build-depends: base >=4.13 && <5, mmsyn2-array ==0.3.1.1, mmsyn3 == 0.2.0.0, mmsyn5 == 0.6.0.0, lists-flines == 0.1.3.0, foldable-ix ==0.3.0.0- -- hs-source-dirs:+ build-depends: base >=4.13 && <5, mmsyn2-array ==0.3.1.1, intermediate-structures ==0.1.1.0, lists-flines == 0.1.3.0+ hs-source-dirs: default-language: Haskell2010 executable pldPL main-is: Main.hs other-modules: Phladiprelio.General.Base, Phladiprelio.General.Syllables, Phladiprelio.RGLPK.General, Phladiprelio.General.SpecificationsRead, Phladiprelio.General.PrepareText -- other-extensions:- build-depends: base >=4.13 && <5, mmsyn2-array == 0.3.1.1, mmsyn3 == 0.2.0.0, mmsyn5 == 0.6.0.0, lists-flines == 0.1.3.0, foldable-ix ==0.3.0.0+ build-depends: base >=4.13 && <5, mmsyn2-array == 0.3.1.1, intermediate-structures == 0.1.1.0, lists-flines == 0.1.3.0 -- hs-source-dirs: default-language: Haskell2010