-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 94601da
Showing
8 changed files
with
910 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Revision history for dobutokO-poetry-general-languages | ||
|
||
## 0.1.0.0 -- 2020-08-18 | ||
|
||
* First version. Released on an unsuspecting world. | ||
|
||
## 0.2.0.0 -- 2020-08-18 | ||
|
||
* Second version. Added new functions uniqueness2nG and uniquenessPeriodsN to the DobutokO.Poetry.Languages.UniquenessPeriodsG module. Some documentation improvements | ||
for the module. Changed the dependency boundaries for the uniqueness-periods-general. |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
-- | | ||
-- Module : DobutokO.Poetry.Languages.UniquenessPeriodsG | ||
-- Copyright : (c) OleksandrZhabenko 2020 | ||
-- License : MIT | ||
-- Stability : Experimental | ||
-- Maintainer : olexandr543@yahoo.com | ||
-- | ||
-- Helps to order the 7 or less words (or their concatenations) | ||
-- to obtain (to some extent) suitable for poetry or music text. This module | ||
-- provides a functionality to define more complex uniquenessPeriods functions. | ||
-- For all the used conversion functions of the type @g :: String -> Vector String@ | ||
-- it is important that they are stable for the repeated application (their result after | ||
-- the first application cannon be changed by the rules in the function into new variants). | ||
-- Otherwise, the recursive scheme of the functions in the module will lead to wrong results. | ||
-- So the conversion function should work the following way (@xs@ denotes a word in the language) in GHCi: | ||
-- | ||
-- > let v = g xs | ||
-- > let ys = concat . toList $ v | ||
-- > let v2 = g ys | ||
-- > v == v2 | ||
-- > True | ||
-- | ||
-- Or in the other words, for the single word, @g . concat . toList . g = g@; | ||
-- | ||
|
||
{-# LANGUAGE CPP #-} | ||
|
||
module DobutokO.Poetry.Languages.UniquenessPeriodsG where | ||
|
||
#ifdef __GLASGOW_HASKELL__ | ||
#if __GLASGOW_HASKELL__>=710 | ||
/* code that applies only to GHC 7.10.* and higher versions */ | ||
import GHC.Base (mconcat) | ||
#endif | ||
#endif | ||
|
||
import qualified Data.Vector as V | ||
import Data.List ((\\),nubBy) | ||
import String.UniquenessPeriodsG | ||
|
||
#ifdef __GLASGOW_HASKELL__ | ||
#if __GLASGOW_HASKELL__==708 | ||
/* code that applies only to GHC 7.8.* */ | ||
mconcat = concat | ||
#endif | ||
#endif | ||
|
||
-- | More complicated and longer variant of the 'uniquenessPeriods' that takes into account the second order structure of uniqueness with 'uniquenessP2' and | ||
-- can be therefore more fruitful (probably, it is a hypothesis itself that is needed to be tested). Is provided here as an example of the more complex | ||
-- \"uniqueness function\". Uses both 'uniqueness2' and 'uniqueness2n' inside and is actually their composition with some (hopefully, natural) parameter functions. | ||
-- The first argument must be a list of 'String', | ||
-- each of which is a representation for the white space (or more generally, non-sound symbol representation). The second argument is a function that | ||
-- converts a 'String' of the text into the 'V.Vector' of sound representations for that language. | ||
uniquenessPeriods2 :: [String] -> (String -> V.Vector String) -> Int -> String -> [Int] | ||
uniquenessPeriods2 whspss g x = uniqueness2n (show7snc whspss) (length) x . uniqueness2 (show7s6 whspss g) (uniquenessP2) | ||
|
||
-- | Parameterized way to prepare the result that can be used with 'uniqueness2n'. | ||
uniqueness2 :: (String -> [[String]]) -> ([[String]] -> [[String]]) -> String -> ([[String]],[String]) | ||
uniqueness2 f h xs | ||
| null xs = ([],[]) | ||
| otherwise = | ||
let ys = f xs | ||
y2s = mconcat . h $ ys in (ys,y2s) | ||
|
||
-- | Being given two functions as parameters uses them to create a longer list of 'Int' than just application of only one of them. Besides, it can take into | ||
-- account the possible 0 and to create a non-negative list of 'Int' that can be used e. g. by 'DobutokO.Poetry.Norms.splitNorm'. | ||
uniqueness2n :: ([String] -> [Int]) -> ([String] -> Int) -> Int -> ([[String]], [String]) -> [Int] | ||
uniqueness2n h f2 x (ys,y2s) | ||
| x == 0 = fmap f2 ys ++ (0:h y2s) | ||
| otherwise = fmap f2 ys ++ h y2s | ||
|
||
-- | Approximates the higher order computational scheme of the 'uniqueness2n' function considering the latter one as the second order computational scheme. Because | ||
-- of the possible concatenation and other not phonetic coversions it cannot be considered the exact one, but in some cases can give more information about phonetic | ||
-- \"uniqueness periods\" structure, so is provided here for exploration. | ||
uniqueness2nG :: [String] -> (String -> V.Vector String) -> Int -> ([String] -> [Int]) -> ([String] -> Int) -> Int -> ([[String]], [String]) -> [Int] | ||
uniqueness2nG whspss g n h f2 x (ys,y2s) | ||
| compare n 2 == LT = error "DobutokO.Poetry.Languages.UniquenessPeriodsG.uniqueness2nG: undefined for that third argument. " | ||
| n == 2 = uniqueness2n h f2 x (ys,y2s) | ||
| x == 0 = fmap f2 ys ++ (0:(uniqueness2nG whspss g (n - 1) h f2 0 . uniqueness2 (show7s6 whspss g) (uniquenessP2) . mconcat $ y2s)) | ||
| otherwise = fmap f2 ys ++ (uniqueness2nG whspss g (n - 1) h f2 x . uniqueness2 (show7s6 whspss g) (uniquenessP2) . mconcat $ y2s) | ||
|
||
-- | Approximates the higher order computational scheme of the 'uniquenessPeriods2' function considering the latter one as the second order computational | ||
-- scheme. Because of the possible concatenation and other not phonetic coversions it cannot be considered the exact one, but in some cases can give more | ||
-- information about phonetic \"uniqueness periods\" structure, so is provided here for exploration. | ||
uniquenessPeriodsN :: [String] -> (String -> V.Vector String) -> Int -> Int -> String -> [Int] | ||
uniquenessPeriodsN whspss g n x = uniqueness2nG whspss g n (show7snc whspss) (length) x . uniqueness2 (show7s6 whspss g) (uniquenessP2) | ||
|
||
-- | Filters a given arguments so that each element 'String' in the result is filtered from the element, which is doubled the first in the next 'String' | ||
-- (usually, it equals to the head of it, if used as expected). Can be interpreted as a preparation to the second application of the 'uniquenessPeriods' | ||
-- function because it removes the elements that splitted the input into lists and can be seen as a second deeper (so, probably less significant) factor | ||
-- of the uniqueness phonetic structure. | ||
uniquenessP2 :: [[String]] -> [[String]] | ||
uniquenessP2 (yss:ysss) | ||
| null ysss = [yss] | ||
| otherwise = if length yss == 1 then uniquenessP2 ysss else (yss \\ [mconcat . take 1 . mconcat . take 1 $ ysss]):uniquenessP2 ysss | ||
uniquenessP2 _ = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2020 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
The package is a generalisation for the functionality of the library of | ||
the [https://hackage.haskell.org/package/dobutokO-poetry](dobutokO-poetry) | ||
package not only for the Ukrainian, but also for other languages (may be | ||
for some of them because of their peculiarities it is not suitable). | ||
|
||
----------------------------------------------------------- | ||
|
||
There are different languages. They have different structure and rules. | ||
But there is a possibility to create and use the "phonetic" language more suitable | ||
for poetry and music. Even there can be different variants of the phonetic | ||
language. This work proposes to create at least two | ||
new "phonetic" languages on the another known one basis. | ||
|
||
Imagine, you can understand the information in the text no matter of | ||
the words order and only with the most needed grammar | ||
preserved (for example, the rule not to separate the preposition and | ||
the next word is preserved). Understand just like you can | ||
read the text (after some instruction and training might be) | ||
with the words where only the first and the last letters | ||
are preserved on their places and the rest are interchangeably mixed. | ||
So imagine, you can understand (and express your thoughts, | ||
feeling, motives and so on) the message of the text with no strict | ||
word order preserved. | ||
|
||
In such a case, you can rearrange words (preserving the most important | ||
rules in this case to reduce or even completely | ||
eliminate ambiguity) so that they can obtain more interesting phonetic | ||
sounding. You can try to create poetic (at least somewhat | ||
rhythmic and expressive) text or music. This can be an inspiring and | ||
developing exercise itself. But how can you quickly find out | ||
which combinations are more or less suitable? Besides, can the complexity | ||
of the algorithms be reduced? | ||
|
||
These are some of the interesting questions. The work does not at | ||
the moment answers them, but is experimental, still may be valuable. | ||
|
||
Ukrainian (for which the functionality here is provided first of all, see | ||
the mentioned dobutokO-poetry package) is the language with no strict | ||
words order needed (though there do exist some preferences in it) and | ||
have rather pleasant sounding. So it can be a good example and instance. | ||
Besides for the author it is a native language. | ||
|
||
Even if you would not like to create and use "phonetic" languages | ||
where phonetics is of more importance than the grammar, then you | ||
can evaluate the phonetic potential of the words used in the text | ||
in producing specially sounding texts. This can also be helpful | ||
in poetry writing and other probably related fields. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- Initial dobutokO-poetry.cabal generated by cabal init. For further | ||
-- documentation, see http://haskell.org/cabal/users-guide/ | ||
|
||
name: dobutokO-poetry-general-languages | ||
version: 0.2.0.0 | ||
synopsis: Helps to order the 7 or less words to obtain somewhat suitable for poetry or music text | ||
description: Helps to order the 7 or less words (or their concatenations) to obtain somewhat suitable for poetry or music text. Can be also used as a research instrument with generalized functions. | ||
|
||
homepage: https://hackage.haskell.org/package/dobutokO-poetry-general-languages | ||
license: MIT | ||
license-file: LICENSE | ||
author: OleksandrZhabenko | ||
maintainer: olexandr543@yahoo.com | ||
copyright: Oleksandr Zhabenko | ||
category: Language, Game | ||
build-type: Simple | ||
extra-source-files: ChangeLog.md, README.md | ||
cabal-version: >=1.10 | ||
|
||
library | ||
exposed-modules: DobutokO.Poetry.Languages.UniquenessPeriodsG, DobutokO.Poetry.Languages.General, DobutokO.Poetry.Languages.General.Debug | ||
-- other-modules: | ||
other-extensions: CPP | ||
build-depends: base >=4.7 && <4.15, vector >=0.11 && <0.14, mmsyn3 >=0.1.5 && <1, mmsyn6ukr >=0.8 && <1, uniqueness-periods-general >=0.2 && <1, dobutokO-poetry-general >=0.1 && <1 | ||
-- hs-source-dirs: | ||
default-language: Haskell2010 |