string-interpreter (empty) → 0.1.0.0
raw patch · 5 files changed
+89/−0 lines, 5 filesdep +basesetup-changed
Dependencies added: base
Files
- ChangeLog.md +5/−0
- Interpreter/StringConversion.hs +37/−0
- LICENSE +20/−0
- Setup.hs +2/−0
- string-interpreter.cabal +25/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for string-interpreter++## 0.1.0.0 -- 2021-08-16++* First version. Released on an unsuspecting world.
+ Interpreter/StringConversion.hs view
@@ -0,0 +1,37 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module : Interpreter.StringConversion+-- Copyright : (c) OleksandrZhabenko 2021+-- License : MIT+-- Stability : Experimental+-- Maintainer : olexandr543@yahoo.com+--+-- A library that has commonly used function for the phonetic-languages implementations.++module Interpreter.StringConversion where++import Text.Read (readMaybe)+import Data.Maybe+import Data.Char (isDigit)+import Data.List (sort,nub,intercalate,(\\))+import Data.Monoid (mappend)++convStringInterpreter :: String -> String -> String+convStringInterpreter contrs xs+ | null contrs = xs+ | length (nub . filter (\t -> t >= '1' && [t] <= show (length . words $ xs)) $ contrs) < 2 = xs+ | otherwise = let cntrs = nub . filter (\t -> t >= '1' && [t] <= show (length . words $ xs)) $ contrs+ tss = words xs in+ case length cntrs of+ 2 -> let pos = fromJust (readMaybe (take 1 cntrs)::Maybe Int)+ number = fromJust (readMaybe (drop 1 cntrs)::Maybe Int)+ (zss,yss) = splitAt (pos - 1) tss+ (kss,lss) = splitAt number yss in+ if length tss < pos + number - 1 then xs+ else if null zss then concat kss `mappend` " " `mappend` intercalate " " lss+ else intercalate " " zss `mappend` " " `mappend` concat kss `mappend` " " `mappend` intercalate " " lss+ _ -> let idxs = map (\x -> fromJust (readMaybe [x]::Maybe Int)) $ cntrs+ wordsN = map (\i -> tss !! (i - 1)) idxs+ restWords = tss \\ wordsN+ in intercalate " " restWords `mappend` " " `mappend` concat wordsN
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2021 OleksandrZhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ string-interpreter.cabal view
@@ -0,0 +1,25 @@+-- Initial string-interpreter.cabal generated by cabal init. For further+-- documentation, see http://haskell.org/cabal/users-guide/++name: string-interpreter+version: 0.1.0.0+synopsis: A library that has commonly used function for the phonetic-languages implementations+description: Provides a way to use recersive interactive mode.+homepage: https://hackage.haskell.org/package/string-interpreter+license: MIT+license-file: LICENSE+author: OleksandrZhabenko+maintainer: olexandr543@yahoo.com+copyright: OleksandrZhabenko+category: Language+build-type: Simple+extra-source-files: ChangeLog.md+cabal-version: >=1.10++library+ exposed-modules: Interpreter.StringConversion+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.8 && <4.16+ -- hs-source-dirs:+ default-language: Haskell2010