<commit_before>"""
Example of algorithm for MSAF
"""
from msaf.algorithms.interface import SegmenterInterface
from vmo.analysis.segmentation import segmentation
import sklearn.preprocessing as pre
import vmo
import librosa


class Segmenter(SegmenterInterface):
    def processFlat(self):
        """Main process.
        Returns
        -------
        est_idxs : np.array(N)
            Estimated indeces the segment boundaries in frame indeces.
        est_labels : np.array(N-1)
            Estimated labels for the segments.
        """
        # Preprocess to obtain features (array(n_frames, n_features))

        F = self._preprocess()
        F = librosa.feature.stack_memory(F.T).T
        F = pre.normalize(F, axis=0)
        ideal_t = vmo.find_threshold(F, dim=F.shape[1])
        oracle = vmo.build_oracle(F,flag='a', threshold=ideal_t[0][1], dim=F.shape[1])

        my_bounds, my_labels = segmentation(oracle, method=self.config['method'],
                                            connectivity=self.config['connectivity'])
        # Post process estimations
        est_idxs, est_labels = self._postprocess(my_bounds, my_labels)
        # We're done!
        return est_idxs, est_labels
<commit_msg>tiny changes<commit_after>"""
Example of algorithm for MSAF
"""
from msaf.algorithms.interface import SegmenterInterface
from vmo.analysis.segmentation import segmentation
import sklearn.preprocessing as pre
import vmo
import librosa


class Segmenter(SegmenterInterface):
    def processFlat(self):
        """Main process.
        Returns
        -------
        est_idxs : np.array(N)
            Estimated indeces the segment boundaries in frame indeces.
        est_labels : np.array(N-1)
            Estimated labels for the segments.
        """
        # Preprocess to obtain features (array(n_frames, n_features))

        F = self._preprocess()
        F = librosa.feature.stack_memory(F.T).T
        F = pre.normalize(F, axis=0)
        ideal_t = vmo.find_threshold(F, dim=F.shape[1])
        oracle = vmo.build_oracle(F, flag='a', threshold=ideal_t[0][1], dim=F.shape[1])

        my_bounds, my_labels = segmentation(oracle,
                                            method=self.config['method'],
                                            connectivity=self.config['connectivity'])
        # Post process estimations
        est_idxs, est_labels = self._postprocess(my_bounds, my_labels)
        # We're done!
        return est_idxs, est_labels

{'fraction_non_alphanumeric': 0.10088781275221953, 'fraction_numerical': 0.004842615012106538, 'mean_word_length': 2.400548696844993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4310781', 'n_tokens_mistral': 723, 'n_tokens_neox': 700, 'n_words': 168}