# Path: tde/util/functions.py
# def iterator_length(iterable):
# def unique(iterable):
# def unique_by(iterable, key):
# def intersection(iterable1, iterable2):
# def intersection_by(iterable1, iterable2, key):
# def grouper(n, iterable, padvalue=None):
# def fname2speaker(corpus_type):
# def fscore(p, r):


from collections import defaultdict
from tde.util.functions import flatten
import numpy as np
from __future__ import division




class Boundaries(object):
    def __init__(self, container, threshold=0.03):
        self.threshold = threshold
        if hasattr(container, 'iter_fragments'):
            iterator = container.iter_fragments()
        else:
            iterator = (f for f in container)

        bounds = defaultdict(list)
        length = 0
        for fragment in iterator:
            bounds[fragment.name].append(fragment.interval)
            length += 1
        self.length = length
        self.bounds = {}
        for name, intervals in bounds.iteritems():

# Path: tde/util/functions.py
# def iterator_length(iterable):
# def unique(iterable):
# def unique_by(iterable, key):
# def intersection(iterable1, iterable2):
# def intersection_by(iterable1, iterable2, key):
# def grouper(n, iterable, padvalue=None):
# def fname2speaker(corpus_type):
# def fscore(p, r):


# Path: tde/measures/boundaries.py
from collections import defaultdict
from tde.util.functions import flatten
import numpy as np

from __future__ import division




class Boundaries(object):
    def __init__(self, container, threshold=0.03):
        self.threshold = threshold
        if hasattr(container, 'iter_fragments'):
            iterator = container.iter_fragments()
        else:
            iterator = (f for f in container)

        bounds = defaultdict(list)
        length = 0
        for fragment in iterator:
            bounds[fragment.name].append(fragment.interval)
            length += 1
        self.length = length
        self.bounds = {}
        for name, intervals in bounds.iteritems():

            points = set(flatten((interval.start, interval.end)