Forced-Alignment-and-Vowel-Extraction / alignedTextGrid

aligned-textgrid links textgrid sequences together
https://forced-alignment-and-vowel-extraction.github.io/alignedTextGrid/
GNU General Public License v3.0
6 stars 1 forks source link

[Feature Request]: Refactor SequenceTier.__init__() for easier textgrid creation/splitting #168

Open chrisbrickhouse opened 7 months ago

chrisbrickhouse commented 7 months ago

What feature would you like added?

The following lines should be moved to their own (internal) function similar to __set_precedence() for easier code reuse:

        self.entry_class = entry_class
        self.superset_class = self.entry_class.superset_class
        self.subset_class =  self.entry_class.subset_class
        entry_order = np.argsort([x.start for x in self.entry_list])
        self.entry_list = [self.entry_list[idx] for idx in entry_order]
        self.sequence_list = []
        for entry in self.entry_list:
            this_seq = self.entry_class(entry)
            this_seq.set_superset_class(self.superset_class)
            this_seq.set_subset_class(self.subset_class)
            self.sequence_list += [this_seq]

What would the use case be for this feature?

I'm working on splitting up some textgrids and the workflow is mostly pretty good, but these operations need to be set manually when building a textgrid from scratch. For example, you can create an empty SequenceTier and populate it with intervals and run ST.__set_precedence() since those init operations are their own function, but if you want to set super/subset attributes or make sure everything is properly ordered, that needs to be done manually. If these operations were their own function, then I could just call that function and make code reuse easier.

Would you like to help add this feature?

Yes, and I will submit a pull request soon.

Code of Conduct