packages feed

phonetic-languages-ukrainian-array 0.8.2.0 → 0.9.0.0

raw patch · 3 files changed

+52/−33 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Phonetic.Languages.Ukrainian.PrepareText: isParticipleAppended :: String -> Bool
+ Phonetic.Languages.Ukrainian.PrepareText: isPrepended :: String -> Bool
+ Phonetic.Languages.Ukrainian.PrepareText: jottedCnv :: String -> String

Files

ChangeLog.md view
@@ -59,3 +59,9 @@ ## 0.8.2.0 -- 2022-01-13  * Eigth version revised B. Fixed issue with just partially defined participleConc function.++## 0.9.0.0 -- 2022-01-14++* Ninth version. Changed the behaviour of many functions in case of sequences of official parts of language like participles,+prepositions etc, so that they are concatenated together with the next word. This is not always suitable, but is sensible+in many cases and allows to preserve more meaning.
Phonetic/Languages/Ukrainian/PrepareText.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Phonetic.Languages.Ukrainian.PrepareText--- Copyright   :  (c) OleksandrZhabenko 2020-2021+-- Copyright   :  (c) OleksandrZhabenko 2020-2022 -- License     :  MIT -- Stability   :  Experimental -- Maintainer  :  olexandr543@yahoo.com@@ -29,11 +29,14 @@   , splitLinesN   , auxiliary1   , isPreposition+  , isParticipleAppended+  , isPrepended   , isConcatenated   , isSpC   , isUkrainianL   , concatenated2   , jottedConv+  , jottedCnv   -- * The end-user functions   , prepareText   , prepareTextN@@ -50,6 +53,7 @@ import Data.Char (isAlpha,toLower) import GHC.Arr import GHC.List (scanl1)+import Data.Monoid (mappend)  -- | Is used to convert a Ukrainian text into list of 'String' each of which is ready to be -- used by the functions of the modules for the phonetic languages approach.@@ -67,50 +71,50 @@ complexWords wwss@(xs:ys:zs:ts:xss) =  getBFstLSorted' (xs:complexWords (ys:zs:ts:xss)) ([("\1074",     if ys == "\1084\1110\1088\1091" && zs == "\1090\1086\1075\1086" &&-    ts == "\1103\1082" then auxiliary2Inner (xs ++ ys ++ zs ++ ts) xss else auxiliary4 wwss),+    ts == "\1103\1082" then auxiliary2Inner (xs `mappend` ys `mappend` zs `mappend` ts) xss else auxiliary4 wwss),     ("\1076\1072\1088\1084\1072", if ys == "\1097\1086"     then auxiliary3 wwss else auxiliary4 wwss), ("\1076\1083\1103",     if ys == "\1090\1086\1075\1086" && zs == "\1097\1086\1073"-    then auxiliary2Inner (xs ++ ys ++ zs ++ ts) xss+    then auxiliary2Inner (xs `mappend` ys `mappend` zs `mappend` ts) xss     else auxiliary4 wwss), ("\1079",       case ys of         "\1090\1080\1084" -> if zs == "\1097\1086\1073"-          then auxiliary2Inner (xs ++ ys ++ zs) (ts:xss)+          then auxiliary2Inner (xs `mappend` ys `mappend` zs) (ts:xss)           else auxiliary4 wwss         "\1090\1086\1075\1086" -> if zs == "\1095\1072\1089\1091" && ts == "\1103\1082"-          then auxiliary2Inner (xs ++ ys ++ zs ++ "\1081\1072\1082") xss+          then auxiliary2Inner (xs `mappend` ys `mappend` zs `mappend` "\1081\1072\1082") xss           else auxiliary4 wwss         _ -> auxiliary4 wwss), ("\1079\1072\1083\1077\1078\1085\1086",     if ys == "\1074\1110\1076" then auxiliary3 wwss else auxiliary4 wwss),     ("\1079\1072\1084\1110\1089\1090\1100",     if ys == "\1090\1086\1075\1086" && zs == "\1097\1086\1073"-    then auxiliary2Inner (xs ++ ys ++ zs) (ts:xss)+    then auxiliary2Inner (xs `mappend` ys `mappend` zs) (ts:xss)     else auxiliary4 wwss), ("\1087\1086\1087\1088\1080",-    if ys == "\1090\1077" && zs == "\1097\1086" then auxiliary2Inner (xs ++ ys ++ zs) (ts:xss)+    if ys == "\1090\1077" && zs == "\1097\1086" then auxiliary2Inner (xs `mappend` ys `mappend` zs) (ts:xss)     else auxiliary4 wwss),("\1085\1077\1079\1072\1083\1077\1078\1085\1086",     if ys == "\1074\1110\1076" then auxiliary3 wwss else auxiliary4 wwss),     ("\1085\1077\1079\1074\1072\1078\1072\1102\1095\1080", if ys == "\1085\1072" then-    if zs == "\1090\1077" && ts == "\1097\1086" then auxiliary2Inner (xs ++ ys ++ zs ++ ts) xss+    if zs == "\1090\1077" && ts == "\1097\1086" then auxiliary2Inner (xs `mappend` ys `mappend` zs `mappend` ts) xss     else auxiliary3 wwss else auxiliary4 wwss),     ("\1087\1088\1080",     if ys == "\1094\1100\1086\1084\1091" then auxiliary3 wwss     else auxiliary4 wwss), ("\1087\1110\1089\1083\1103",-    if ys == "\1090\1086\1075\1086" && zs == "\1103\1082" then auxiliary2Inner (xs ++ ys ++ zs) (ts:xss)+    if ys == "\1090\1086\1075\1086" && zs == "\1103\1082" then auxiliary2Inner (xs `mappend` ys `mappend` zs) (ts:xss)     else auxiliary4 wwss), ("\1090\1072\1082", if (ys == "\1097\1086") || (ys == "\1103\1082")     then auxiliary3 wwss else auxiliary4 wwss),     ("\1090\1080\1084\1095\1072\1089\1086\1084", if ys == "\1103\1082"     then auxiliary3 wwss else auxiliary4 wwss),-    ("\1090\1086\1084\1091", if ys == "\1103\1082" then auxiliary2Inner (xs ++ "\1081\1072\1082") (zs:ts:xss)+    ("\1090\1086\1084\1091", if ys == "\1103\1082" then auxiliary2Inner (xs `mappend` "\1081\1072\1082") (zs:ts:xss)     else auxiliary4 wwss), ("\1091",     if (ys == "\1079\1074'\1103\1079\1082\1091" || ys == "\1079\1074\x02BC\1103\1079\1082\1091") && zs == "\1079"-    then auxiliary2Inner (xs ++ "\1079\1074\1081\1072\1079\1082\1091" ++ zs) (ts:xss)+    then auxiliary2Inner (xs `mappend` "\1079\1074\1081\1072\1079\1082\1091" `mappend` zs) (ts:xss)     else if ys == "\1084\1110\1088\1091" && zs == "\1090\1086\1075\1086" && ts == "\1103\1082"-    then auxiliary2Inner (xs ++ ys ++ zs ++ ts) xss else auxiliary4 wwss),+    then auxiliary2Inner (xs `mappend` ys `mappend` zs `mappend` ts) xss else auxiliary4 wwss),     ("\1093\1086\1095", if ys == "\1073\1080" then auxiliary3 wwss     else auxiliary4 wwss), ("\1093\1086\1095\1072", if ys == "\1073"     then auxiliary3 wwss else auxiliary4 wwss),     ("\1095\1077\1088\1077\1079", if ys == "\1090\1077" && zs == "\1097\1086"-    then auxiliary2Inner (xs ++ ys ++ zs) (ts:xss) else auxiliary4 wwss)]) xs+    then auxiliary2Inner (xs `mappend` ys `mappend` zs) (ts:xss) else auxiliary4 wwss)]) xs complexWords wwss@(xs:ys:zs:xss) =  getBFstLSorted' (xs:complexWords [ys,zs]) ([("\1076\1072\1088\1084\1072", if ys == "\1097\1086"     then auxiliary3 wwss else auxiliary4 wwss), ("\1079\1072\1083\1077\1078\1085\1086",@@ -123,26 +127,26 @@     then auxiliary3 wwss else auxiliary4 wwss),     ("\1090\1080\1084\1095\1072\1089\1086\1084", if ys == "\1103\1082"     then auxiliary3 wwss else auxiliary4 wwss),-    ("\1090\1086\1084\1091", if ys == "\1103\1082" then auxiliary2Inner (xs ++ "\1081\1072\1082") (zs:xss)+    ("\1090\1086\1084\1091", if ys == "\1103\1082" then auxiliary2Inner (xs `mappend` "\1081\1072\1082") (zs:xss)     else auxiliary4 wwss), ("\1093\1086\1095", if ys == "\1073\1080" then auxiliary3 wwss     else auxiliary4 wwss), ("\1093\1086\1095\1072", if ys == "\1073"     then auxiliary3 wwss else auxiliary4 wwss)]) xs complexWords [xs,ys]- | ys `elem` ["\1073","\1073\1060","\1078\1077","\1078"] = [xs ++ ys]- | xs == "\1076\1072\1088\1084\1072" && ys == "\1097\1086" = [xs ++ ys]+ | ys `elem` ["\1073","\1073\1060","\1078\1077","\1078"] = [xs `mappend` ys]+ | xs == "\1076\1072\1088\1084\1072" && ys == "\1097\1086" = [xs `mappend` ys]  | otherwise = [xs,ys] complexWords xss = xss  auxiliary2Inner :: String -> [String] -> [String] auxiliary2Inner ts (xs:ys:xss)   | (concatenated2 . auxiliary1 $ [xs,ys]) /= [xs,ys] = let (rs,ws) = splitAt 1 (concatenated2 . auxiliary1 $ [xs,ys]) in-       (ts ++ head rs):complexWords (concat [ws,xss])-  | otherwise = (ts ++ xs):complexWords (ys:xss)-auxiliary2Inner ts [xs] = [ts ++ xs]+       (ts `mappend` head rs):complexWords (concat [ws,xss])+  | otherwise = (ts `mappend` xs):complexWords (ys:xss)+auxiliary2Inner ts [xs] = [ts `mappend` xs] auxiliary2Inner ts _ = [ts]  auxiliary3 :: [String] -> [String]-auxiliary3 (xs:ys:xss) = auxiliary2Inner (xs ++ ys) xss+auxiliary3 (xs:ys:xss) = auxiliary2Inner (xs `mappend` ys) xss auxiliary3 xss = xss {-# INLINE auxiliary3 #-} @@ -166,25 +170,34 @@ -- | A generalized variant of the 'prepareText' with the arbitrary maximum number of the words in the lines given as the first argument. prepareTextN :: Int -> String -> [String] prepareTextN n = filter (any isUkrainianL) . splitLinesN n .-  map (unwords . concatenated2. auxiliary1 . participleConc . complexWords . words . filter (\t -> isAlpha t || isSpC t)) .+  map (unwords . concatenated2. auxiliary1 . complexWords . words . filter (\t -> isAlpha t || isSpC t)) .        filter (not . null) . lines  participleConc :: [String] -> [String] participleConc xss@(xs:ys:yss)-  | ys `elem` ["\1073","\1073\1060","\1078\1077","\1078"] = (xs ++ ys):participleConc yss+  | ys `elem` ["\1073","\1073\1060","\1078\1077","\1078"] = (xs `mappend` ys):participleConc yss   | otherwise = xs:participleConc (ys:yss) participleConc yss = yss +isParticipleAppended :: String -> Bool+isParticipleAppended xs = xs `elem` ["\1073","\1073\1060","\1078\1077","\1078"]++isPrepended :: String -> Bool+isPrepended xs+ | isParticipleAppended xs = True+ | isPreposition xs = True+ | otherwise = isConcatenated xs++jottedCnv :: String -> String+jottedCnv xs = drop 1 . jottedConv $ ' ':xs+ auxiliary1 :: [String] -> [String]-auxiliary1 (xs:ys:zs:xss)-  | isConcatenated ys || isPreposition ys =-      auxiliary1 (xs:auxiliary1 ((ys ++ (drop 1 . jottedConv $ ' ':zs)):xss))-  | isConcatenated xs || isPreposition xs = auxiliary1 ((xs ++ (drop 1 . jottedConv $ ' ':ys)):zs:xss)-  | otherwise = xs:auxiliary1 (ys:zs:xss)-auxiliary1 x@(xs:ys:xss)-  | isConcatenated xs || isPreposition xs = auxiliary1 ((xs ++ (drop 1 . jottedConv $ ' ':ys)):xss)-  | otherwise = x-auxiliary1 xss = xss+auxiliary1 yss@(xs:xss)+ | isPrepended xs = concatMap jottedCnv (tss `mappend` wss):auxiliary1 vss+ | otherwise = xs:auxiliary1 xss+      where (tss,uss) = break (not . isPrepended) yss+            (wss,vss) = splitAt 1 uss+auxiliary1 _ = []  isPreposition :: String -> Bool isPreposition ts =@@ -265,7 +278,7 @@  "\1087\1088\1086\1090\1077","\1089\1072\1084\1077","\1089\1077\1073\1090\1086","\1090\1072\1082\1080",  "\1090\1086\1073\1090\1086","\1090\1110\1083\1100\1082\1080","\1093\1072\1081","\1093\1086\1095",  "\1093\1110\1073\1072","\1094\1077\1073\1090\1086","\1097\1086\1073","\1103\1082\1073\1080",- "\1103\1082\1088\1072\1079","\1103\1082\1097\1086"] $ replicate 200 ((xs ++ (drop 1 . jottedConv $ ' ':ys)):concatenated2 xss)) xs+ "\1103\1082\1088\1072\1079","\1103\1082\1097\1086"] $ replicate 200 ((xs `mappend` jottedCnv ys):concatenated2 xss)) xs concatenated2 xss = xss  isSpC :: Char -> Bool
phonetic-languages-ukrainian-array.cabal view
@@ -2,7 +2,7 @@ --  further documentation, see http://haskell.org/cabal/users-guide/  name:                phonetic-languages-ukrainian-array-version:             0.8.2.0+version:             0.9.0.0 synopsis:            Prepares Ukrainian text to be used as a phonetic language text description:         Applies needed minimal grammar connections so that the text afterwards can be processed by dobutokO-poetry or phonetic languages approach related programs. Uses arrays instead of vectors. Besides can be used to reverse many of the done concatenations. homepage:            https://hackage.haskell.org/package/phonetic-languages-ukrainian-array