custom_classes

custom_classes.custom_classes(class_list=[], return_order=None, points=[])

Generate custom interval classes

Passing custom_classes() a list of Sequence names wil return a list of SequenceInterval subclasses with those names. The first name passed to class_list will be at the top of the hierarchy, the second name will be the subset class of the first, and so on.

Examples

To change the order in which the custom classes are returned, specify return_order with either indices or class names. For example, if you have Words, Syllables, and Phones in a hierarchical relationship in a textgrid, you can run the following:

from aligned_textgrid import custom_classes

custom_classes(["Word", "Syllable", "Phone"])
[aligned_textgrid.sequences.sequences.Word,
 aligned_textgrid.sequences.sequences.Syllable,
 aligned_textgrid.sequences.sequences.Phone]

But if the order of the textgrid tiers has Word as the bottom tier and Phone as the top, you can specify return_order like so:

custom_classes(
    class_list = ["Word", "Syllable", "Phone"],
    return_order = [2, 1, 0]
    # or
    # return_order = ["Phone", "Syllable", "Word]
)
[aligned_textgrid.sequences.sequences.Phone,
 aligned_textgrid.sequences.sequences.Syllable,
 aligned_textgrid.sequences.sequences.Word]

This way, you can use custom_classes() directly as the entry_classes argument in AlignedTextGrid

AlignedTextGrid(
    textgrid_path = "syllables.TextGrid",
    entry_classes = custom_classes(
        class_list = ["Word", "Syllable", "Phone"],
        return_order = [2, 1, 0]
    )
)

Parameters

Name Type Description Default
class_list list[str] A list of desired class names, in their hierarchical order. Defaults to []. []
return_order list[str] | list[int] | None A return order for the custom classes, if not in hierarchical order. Defaults to None. None
points list[int] Indices of which classes should be points, rather than intervals []

Returns

Type Description
list[Type[SequenceInterval]] A list of custom SequenceInterval subclasses

Reuse

GPLv3