hash_table

exception decitala.hash_table.HashTableException[source]

Bases: Exception

decitala.hash_table.generate_all_modifications(dict_in, fragment, factors, differences, try_retrograde, allow_stretch_augmentation, allow_mixed_augmentation, force_override=False, exact=False)[source]

Helper function for generating and storing all possible modifications of an input fragment.

Parameters
  • dict_in (dict) – Dictionary storing all the results.

  • fragment (decitala.fragment.GeneralFragment) – Fragment input.

  • factors (list) – Possible factors for multiplicative augmentation.

  • differences (list) – Possible differences for additive augmentation.

  • try_retrograde (bool) – Whether to also generate modifications for the retrograde of the fragment.

  • allow_mixed_augmentation (bool) – Whether to allow mixed augmentation as a modification type. Not yet supported.

  • force_override (bool) – Whether to force the given fragment to override the existing fragment in the table (if it exists). Not yet supported.

  • exact (bool) – If set to True, returns only the exact fragment in the the dictionary. Default is False.

class decitala.hash_table.FragmentHashTable(datasets=[], custom_fragments=[])[source]

Bases: object

This class holds all (relevant) modifications of a set of fragments. Currently the only supported input types to datasets are "decitala" and "greek_foot". The custom_fragments parameter allows the addition of any desired fragments; for a search on a particular set of fragments, use this latter parameter. The factors, differences, and other modification parameters are instance attributes with defaults set in the module. To change them, just re-run the load method with the desired inputs; this will clear the data and set reload it with the new desired modification techniques.

>>> from decitala.fragment import Decitala
>>> fht = FragmentHashTable(
...     datasets=["greek_foot"],
...     custom_fragments=[Decitala("Ragavardhana")]
... )
>>> # The object doesn't store anything until it is loaded.
>>> fht
<decitala.hash_table.FragmentHashTable 0 fragments>
>>> fht.load()
>>> fht
<decitala.hash_table.FragmentHashTable 2761 fragments>
>>> fht.datasets
['greek_foot']
>>> fht.custom_fragments
[<fragment.Decitala 93_Ragavardhana>]
>>> fht.data[(3.0, 0.5, 0.75, 0.5)]["fragment"]
<fragment.Decitala 93_Ragavardhana>
>>> peon_check = fht.data[(2.0, 2.0, 2.0, 4.0)]
>>> peon_check["fragment"].name == "Peon_IV"
True
load(factors=[0.125, 0.1875, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0], differences=[- 0.375, - 0.25, - 0.125, 0.0, 0.125, 0.25, 0.375, 0.5, 0.75, 0.875, 1.75, 2.625, 3.5, 4.375], try_retrograde=True, allow_stretch_augmentation=True, allow_mixed_augmentation=False, modification_hierarchy={'difference': 3, 'mixed': 9, 'ratio': 1, 'retrograde-difference': 4, 'retrograde-mixed': 10, 'retrograde-ratio': 2, 'retrograde-stretch': 8, 'retrograde-subdivision-ratio': 6, 'stretch': 7, 'subdivision-ratio': 5}, force_override=False, exact=False)[source]

Function for loading the modifications. Allows the user to override the default attributes.

class decitala.hash_table.DecitalaHashTable(exact=False)[source]

Bases: decitala.hash_table.FragmentHashTable

This class subclasses decitala.hash_table.FragmentHashTable with the datasets parameter set to ["decitala"] and automatically loads.

class decitala.hash_table.GreekFootHashTable(exact=False)[source]

Bases: decitala.hash_table.FragmentHashTable

This class subclasses decitala.hash_table.FragmentHashTable with the datasets parameter set to ["greek_foot"] and automatically loads. If you want to reload it with default modification techniques changed, simply run load with the desired parameters.

>>> ght = GreekFootHashTable()
>>> ght
<decitala.hash_table.FragmentHashTable 2717 fragments>
>>> ght.load(try_retrograde=False, allow_stretch_augmentation=False)
>>> ght
<decitala.hash_table.FragmentHashTable 755 fragments>
>>> ght_exact = GreekFootHashTable(exact=True)
>>> ght_exact
<decitala.hash_table.FragmentHashTable 32 fragments>
class decitala.hash_table.ProsodicMeterHashTable(exact=False)[source]

Bases: decitala.hash_table.FragmentHashTable

This class subclasses decitala.hash_table.FragmentHashTable with the datasets parameter set to ["prosodic_meter"] and automatically loads.

class decitala.hash_table.AllCorporaHashTable(exact=False)[source]

Bases: decitala.hash_table.FragmentHashTable

This class subclasses decitala.hash_table.FragmentHashTable with the datasets parameter set to all available datasets in the corpora directory and automatically loads.