SequenceInterval

sequences.sequences.SequenceInterval(self, interval=(None, None, None), *, Interval=None)

A class to describe an interval with precedence relationships and hierarchical relationships

Parameters

Name Type Description Default
interval list | tuple | Interval | Self A Praat textgrid Interval. This could one of: i) A list or tuple of start, end and label values (e.g. [0, 1, "foo"]); ii) A praatio.utilities.constants.Interval iii) Another SequenceInterval. In this last case, only the start, end and label values from the original SequenceInterval are preserved in the new one. (None, None, None)

Examples

A new SequenceInterval can be created from scratch by passing it a tuple of a start time, end time, and a label

from aligned_textgrid import SequenceInterval

sample_interval = SequenceInterval((0, 1, "sample"))
print(sample_interval)
Class SequenceInterval, label: sample, .superset_class: Top, .super_instance, None, .subset_class: Bottom

You can pass a SequenceInterval to another SequenceInterval or subclass (like Word) as well

from aligned_textgrid import Word

sample_word = Word(sample_interval)
print(sample_word)
Class Word, label: sample, .superset_class: Top_wp, .super_instance, None, .subset_class: Phone

Attributes

Name Type Description
start float Start time of the interval
end float End time of the interval
label Any Label of the interval
duration float The duration of the interval
intier SequenceTier The sequence tier the current interval is within.
tier_index int The index of sequence within its tier.
fol SequenceInterval Instance of the following interval. Is the same subclass as the current instance.
prev SequenceInterval Instance of the previous interval. Is the same subclass as current instance.
super_instance SequenceInterval The instance of the superset. Cannot be the same subclass as the current instance.
subset_list list[SequenceInterval] A list of subset instances. Cannot be the same subclass of the current instance.
sub_starts numpy.ndarray A numpy array of start times for the subset list
sub_ends numpy.ndarray A numpy array of end times for the subset list
sub_labels list[Any] A list of labels from the subset list

Methods

Name Description
fuse_leftwards Fuse the current segment with the previous segment
fuse_rightwards Fuse the current segment with the following segment
index Returns subset instance index
pop Pop a sequence interval from the subset list
set_feature Sets arbitrary object attribute

fuse_leftwards

sequences.sequences.SequenceInterval.fuse_leftwards(label_fun=lambda x, y: ' '.join([x, y]))

Fuse the current segment with the previous segment

Parameters

Name Type Description Default
label_fun function Function for joining interval labels. lambda x, y: ' '.join([x, y])

fuse_rightwards

sequences.sequences.SequenceInterval.fuse_rightwards(label_fun=lambda x, y: ' '.join([x, y]))

Fuse the current segment with the following segment

Parameters

Name Type Description Default
label_fun function Function for joining interval labels. lambda x, y: ' '.join([x, y])

index

sequences.sequences.SequenceInterval.index(subset_instance)

Returns subset instance index

Parameters

Name Type Description Default
subset_instance SequenceInterval A subset instance to get the index of. required

Returns

Type Description
int The index of subset_instance

pop

sequences.sequences.SequenceInterval.pop(subset_instance)

Pop a sequence interval from the subset list

Parameters

Name Type Description Default
subset_instance SequenceInterval A sequence interval to pop required

set_feature

sequences.sequences.SequenceInterval.set_feature(feature, value)

Sets arbitrary object attribute

This will be most useful for creating custom subclasses.

Parameters

Name Type Description Default
feature str New attribute name required
value Any New attribute value required

Reuse

GPLv3