Skip to content

[Feature Request]: SequenceInterval splitting #171

@JoFrhwld

Description

@JoFrhwld

What feature would you like added?

Right now, it is only possible to fuse intervals leftwards or rightwards, but impossible to split an interval. Thinking about how the SequenceInterval.split() could work:

Splitting

On timestamps

interval.split(at_times = [2.31, 2.35])

This should add new interval boundaries at the given times (with the interval's start and end time implicit). This example would result in 3 intervals.

On percentage time

interval.split(at_proportion = [0.2, 0.7]

This would place boundaries at 20% and 70% of the duration of the interval, resulting in 3 intervals.

On the subset

interval.split(on_subset = True)

This should, perhaps, be the default behavior. This would split the interval into sub-intervals based on the timestamps of its subset intervals.

Labelling

Explicit labels

interval.split(
  at_proportion = [0.2, 0.7],
  labels = ["a", "b", "c"]
)

Label Fun

def label_sequential(label, sequence_len):
  label_rep = label * sequence_len
  labels = [
    f"{lab}-{num}" 
    for lab, num in zip(label_rep, range(sequence_len))
  ]
  return labels

def label_rep(label, sequence_len):
  label_rep = label * sequence_len
  return label_rep

def label_blank(label, sequence_len):
  label_rep = "" * sequence_len
  return label_rep


interval.split(
  at_proportion = [0.2, 0.7],
  label_fun = sequential_number
)

What would the use case be for this feature?

When creating new-sub-interval tiers based in analytical landmarks. E.g.

  • Splitting an initial phrase interval into sub-phrases based on the presence of silences in the aligned word-tier.
  • Splitting a word interval into morphemic components, based on timing in the phone tier.
  • Splitting a phone interval into onset, target, offset components, based on acoustic measurements.

Would you like to help add this feature?

Yes, and I will submit a pull request soon.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions