equitext

A text-to-text encoding. Characters in the encoded text all have the same number of occurences. It makes the text length grow by a factor of about 1.44.

equitext.convert_factorial(index)

Convert a number into the factorial number system.

Parameters:index – The integer to convert
Returns:The digits of the number in the factorial number system, given as a list of integers. The digits are given in the reverse positional fashion, that is, digits corresponding to the highest radices are given first
equitext.decode(text)

Decode a text using equitext

Parameters:text – The string to decode
Returns:The decoded string
equitext.encode(text)

Encode a text using equitext

Parameters:text – The string to encode
Returns:The encoded string
equitext.get_alphabet_from_encoded(text)

Return the alphabet of an equitext-encoded text.

This simply returns the sorted list of characters used in the text (each character has a unique occurence in the list). While this is optimized for equitext-encoded texts, the simple sorted(list(set(text))) is fine for nondescript texts

Parameters:text – The text from which extract the alphabet
Returns:The alphabet used by the text, as a sorted list of characters
equitext.get_chunk_length(alphabet)

Return the length of chunks that equitext should use for texts using the given alphabet.

Parameters:alphabet – The alphabet, given as a list of characters
Returns:The length of chunks to use with this alphabet, an integer
equitext.get_combination(index, alphabet)

Return the combination of characters having the given index according to the given alphabet.

Parameters:
  • index – The index of the combination, given as an integer
  • alphabet – The alphabet, given as a list of characters
Returns:

The combination corresponding to the index, a string.

equitext.get_combindex(chunk, tebahpla)

Return the index of a combination of characters belonging to the given alphabet.

Parameters:
  • chunk – The combination of characters, given as a string
  • tebahpla – a dictionary containing characters of the alphabet as keys and their ordinal (that is, their position in the alphabet) as values.
Returns:

The index of the given combination, an integer.

equitext.get_permindex(permutation, alphabet)

Return the index of a permutation of the alphabet.

Parameters:
  • permutation – The permutation of the alphabet, given as a string
  • alphabet – The alphabet, given as a list of characters
Returns:

The index of the given permutation, an integer.

equitext.get_permutation(index, alphabet)

Return the permutation of the alphabet having the given index.

Parameters:
  • index – The index of the permutation, given as an integer
  • alphabet – The alphabet, given as a list of characters
Returns:

The permutation corresponding to the index, a string.

equitext.histogram(text, size=1, precision=3, occ=False, symbol='=', sort=1, reverse=True)

Print the histogram of occurences of characters in the given text

Parameters:
  • text – The text to print the histogram for
  • size – A coefficient which impacts the width of the histogram proportionally to its default width which is 80-characters
  • precision – The precision for the ratios printed at the tip of the histogram’s bar. Must be an integer.
  • occ – A boolean which indicates whether to display the absolute number of occurences of each character in addition to their ratio
  • symbol – The string which constitutes one unit of histogram’s bar
  • sort – If set to 0, sort the histogram according to the chracters Unicode code points. If set to 1, sort the histogram according to the number of occurences of each characters
  • reverse – Reverse the order of the sort
Returns:

None