rhythmic-sequences-0.3.0.0: Library to deal with rhythmicity of short sequences
Copyright(c) Oleksandr Zhabenko 2022-2023
LicenseMIT
Maintaineroleksandr.zhabenko@yahoo.com
StabilityExperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010
ExtensionsBangPatterns

Rhythmicity.MarkerSeqs

Description

Data and algorithmic basics to evaluate rhythmicity of the lists of Ord instance data type. Similar to phonetic-languages-rhythmicity on Hackage.

Synopsis

Documentation

showBin :: Int -> [Char] Source #

The similar function is since base-4.16.0.0 in the Numeric module. Is not used further, is provided here mostly for testing purposes.

unionCount :: Bits a => a -> a -> Integer Source #

Basic counting of the same bits in the Bits arguments.

countWeightsQs :: Foldable t => [t a -> Int] -> [t a] -> [[Int]] Source #

Some idea function to evaluate the rhythmicity data. Is not used further in the package, can be thought of as an alternative way of computation.

data Sort2 a Source #

Data type used to provide somewhat 'array sorting with its indices'.

Constructors

S2 

Fields

Instances

Instances details
Functor Sort2 Source # 
Instance details

Defined in Rhythmicity.MarkerSeqs

Methods

fmap :: (a -> b) -> Sort2 a -> Sort2 b #

(<$) :: a -> Sort2 b -> Sort2 a #

Show a => Show (Sort2 a) Source # 
Instance details

Defined in Rhythmicity.MarkerSeqs

Methods

showsPrec :: Int -> Sort2 a -> ShowS #

show :: Sort2 a -> String #

showList :: [Sort2 a] -> ShowS #

Eq a => Eq (Sort2 a) Source # 
Instance details

Defined in Rhythmicity.MarkerSeqs

Methods

(==) :: Sort2 a -> Sort2 a -> Bool #

(/=) :: Sort2 a -> Sort2 a -> Bool #

Ord a => Ord (Sort2 a) Source # 
Instance details

Defined in Rhythmicity.MarkerSeqs

Methods

compare :: Sort2 a -> Sort2 a -> Ordering #

(<) :: Sort2 a -> Sort2 a -> Bool #

(<=) :: Sort2 a -> Sort2 a -> Bool #

(>) :: Sort2 a -> Sort2 a -> Bool #

(>=) :: Sort2 a -> Sort2 a -> Bool #

max :: Sort2 a -> Sort2 a -> Sort2 a #

min :: Sort2 a -> Sort2 a -> Sort2 a #

data ASort3 a Source #

Data type to contain the needed for hashing algorithm information about the sorted 'array sorting with its indices'.

Constructors

As3 

Fields

Instances

Instances details
Show a => Show (ASort3 a) Source # 
Instance details

Defined in Rhythmicity.MarkerSeqs

Methods

showsPrec :: Int -> ASort3 a -> ShowS #

show :: ASort3 a -> String #

showList :: [ASort3 a] -> ShowS #

Eq a => Eq (ASort3 a) Source # 
Instance details

Defined in Rhythmicity.MarkerSeqs

Methods

(==) :: ASort3 a -> ASort3 a -> Bool #

(/=) :: ASort3 a -> ASort3 a -> Bool #

splitF :: Int -> [a] -> [[a]] Source #

Split the list into lists of n elements where n is the first parameter. Can be used efficiently just for the finite lists. Contains the modified code of the unfoldr function from the base package.

getHashes2 Source #

Arguments

:: Ord a 
=> Int8

A period of the groups (the length of the lists into which the general sequence is splitted at first).

-> [Int8]

The list must be sorted in the descending order, the elements must be greater or equal to 0 and less than the first argument of getHashes2 here; besides, there must not be repetitions (any duplicates) in the list so all the elements must be pairwise not equal.

-> [a]

A list of Ord data values that is evaluated for its rhythmic properties.

-> [[Integer]] 

Function to get basic data for hash-based evaluation of the rhythmicity of the list data. Is used internally in the countHashesG. Provided here mostly for testing purposes.

countHashesPrioritized :: Bits b => [[b]] -> [[Integer]] Source #

Convert hashes into basic simler data to evaluate rhythmicity of the list data.

count1Hashes :: Ord a => Int8 -> [Int8] -> [a] -> Integer Source #

Mostly for testing.

data HashCorrections Source #

Data type to encode the changes that are introduced by the position of the group of values in general sequence to the general result of the createHashesG function. If the second parameter in the HashCorrections is 1 then the result is more sensitive to beginning of the line; if it is set to 2 then the result is more sensitive to ending of the line; if it is greater than 2 then the result is sensitive to some user weights provided as the first parameter to HashCorrections and otherwise the computation result does not depend on the first parameter to HashCorrections (this one can be considered the basic option for the computation).

Constructors

H [Int8] Int8 

hashList :: HashCorrections -> [Int8] Source #

If the second parameter in the HashCorrections is 1 then the result is more sensitive to beginning of the line; if it is set to 2 then the result is more sensitive to ending of the line; if it is greater than 2 then the result is sensitive to some user weights provided as the first parameter to HashCorrections and otherwise the computation result does not depend on the first parameter to HashCorrections (this one can be considered the basic option for the computation).

readHashCorrections :: String -> HashCorrections Source #

If you would like to specify just your own values then specify the String "a..." where 'a' here means the minus sign '-' or some not equal to 1 or 2 digit, instead of dots specify some digits that are the beginning of the [Int8] list in HashCorrections. If 'a' is '-', then the next not equal to 'a' symbol should be some digit not equal to 1 or 2 if you want to specify your own list of [Int8] for HashCorrections.

Caution:

readHashCorrections . show $ xs /= xs
show . readHashCorrections $ xs /= xs

in general case. The default value is H [0,0..] 0. This one corresponds to usage of the hashBalancingLF2 without any corrections (equi-sensitive to all the parts of the line except probably the last syllables if the number of syllables is not wholely divisible without remainder to the groupLength parameter in the countHashesG function). And this is equivalent to just use the hashBasicLF2.

grouppingR :: String -> (Int8, [Int8]) Source #

This is used to provide the second and the third arguments to countHashesG function. The default value is (4,[3,2]). This means that the line is divided into groups of 4-syllables then there are searched for rhythmic repetitions of the positions of the most maximum values and the less maximum values. This scheme should is related to disyllables metrical feet for SaaW (syllables-as-a-whole) mode of operation for PhLADiPreLiO (see: https://oleksandrzhabenko.github.io/uk/rhythmicity/PhLADiPreLiO.Eng.21.html#SaaW). For more information on the metrical feet you can see e. g.

@article{kagerfeet,
  title={Feet and metrical stress},
  author={Kager, Rene},
  journal={This page intentionally left blank},
  pages={195}
}

countHashesG Source #

Arguments

:: Ord a 
=> HashCorrections

Data that specifies how the arguments influence the result. Somewhat the kernel of the countHashesG computation.

-> Int8

The period of the length of the initial list.

-> [Int8]

List of ordinary positions of the maximum-minimum levels for values of the list in the group. The length of the unique elements together in the list is expected to be in the list [1..7].

-> [a] 
-> [Integer] 

General implementation of the hash-based algorithm to evaluate the level of rhythmicity of the list data. The relatively greater result (for PhLADiPreLiO) corresponds to greater detected periodicity.

countHashes2G Source #

Arguments

:: Ord a 
=> Int

The first parameter for createHash2G function — the step of hashing shift. For countHashesG it is equal to 20 (the default sensible value). Is expected to be greater than 2.

-> HashCorrections

Data that specifies how the arguments influence the result. Somewhat the kernel of the countHashesG computation.

-> Int8

The period of the length of the initial list.

-> [Int8]

List of ordinary positions of the maximum-minimum levels for values of the list in the group. The length of the unique elements together in the list is expected to be in the list [1..7].

-> [a] 
-> [Integer] 

General implementation of the hash-based algorithm to evaluate the level of rhythmicity of the list data. The relatively greater result (for PhLADiPreLiO) corresponds to greater detected periodicity.

createNewHash :: [Integer] -> Integer Source #

Provided for testing.

createHashG :: (Int8 -> [Integer] -> Integer) -> Int8 -> [Integer] -> Integer Source #

General implementation of the second hashing of the data for the algorithm.

createHash2G :: Int -> HashCorrections -> Int8 -> [Integer] -> Integer Source #

General implementation of the second hashing of the data for the algorithm with the additional parameter that specifies the step of hashing (by default, e. g. in createHashG it is equal to 20, but here you can provide your own value). Therefore, is more flexible than createHashG, but can lead to not well coordinated evaluations in general case that wipe by hashing some information in the data. Is intended that the first argument is greater than 2 though it is not checked.

createNHash :: [Int8] -> [Integer] -> Integer Source #

A variant of the createHashG that actually must be equal to the createNewHash for the second argument lists with less than 8 elements. For greater values is not correctly defined, so do not use it for the lists with 8 or more elements in them. Actually should be equal to createNewHash for the second argument.

idList :: Eq a => [Int8] -> [ASort3 a] -> [Int8] Source #

Function to filter the elements by the second parameter of the ASort3 data and then to get the first ones.

toNum :: [Int8] -> Integer Source #

Function to create bitwise representation of the intermediate data for the algorithm. Should be very optimized to run fast.

toNum2 :: [Int8] -> Integer Source #

The alternative implementation of the toNum (on the Linux x86_64 for some CPU is slower than the former one).