def test_time_interval_inner_contains(self):
     params = [
         ("1.000", "1.000", "0.000", False),
         ("1.000", "1.000", "0.999", False),
         ("1.000", "1.000", "1.000", False),
         ("1.000", "1.000", "1.001", False),
         ("1.000", "1.000", "2.000", False),
         ("1.000", "1.001", "0.000", False),
         ("1.000", "1.001", "0.999", False),
         ("1.000", "1.001", "1.000", False),
         ("1.000", "1.001", "1.001", False),
         ("1.000", "1.001", "1.002", False),
         ("1.000", "1.001", "2.000", False),
         ("1.000", "1.002", "0.000", False),
         ("1.000", "1.002", "0.999", False),
         ("1.000", "1.002", "1.000", False),
         ("1.000", "1.002", "1.001", True),
         ("1.000", "1.002", "1.002", False),
         ("1.000", "1.002", "1.003", False),
         ("1.000", "1.002", "2.000", False),
         ("1.234", "1.237", "0.000", False),
         ("1.234", "1.237", "1.233", False),
         ("1.234", "1.237", "1.234", False),
         ("1.234", "1.237", "1.235", True),
         ("1.234", "1.237", "1.236", True),
         ("1.234", "1.237", "1.237", False),
         ("1.234", "1.237", "1.238", False),
         ("1.234", "1.237", "2.000", False),
     ]
     for b, e, p, f in params:
         ti = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
         self.assertEqual(ti.inner_contains(TimeValue(p)), f)
 def test_time_interval_offset(self):
     params = [
         (("0.000", "0.000"), "-1.000", False, ("0.000", "0.000")),
         (("0.000", "0.000"), "-0.000", False, ("0.000", "0.000")),
         (("0.000", "0.000"), "0.000", False, ("0.000", "0.000")),
         (("0.000", "0.000"), "0.500", False, ("0.500", "0.500")),
         (("1.000", "2.000"), "-2.500", False, ("0.000", "0.000")),
         (("1.000", "2.000"), "-2.000", False, ("0.000", "0.000")),
         (("1.000", "2.000"), "-1.500", False, ("0.000", "0.500")),
         (("1.000", "2.000"), "-1.000", False, ("0.000", "1.000")),
         (("1.000", "2.000"), "-0.000", False, ("1.000", "2.000")),
         (("1.000", "2.000"), "0.000", False, ("1.000", "2.000")),
         (("1.000", "2.000"), "0.500", False, ("1.500", "2.500")),
         (("1.000", "2.000"), "1.000", False, ("2.000", "3.000")),
         (("0.000", "0.000"), "-1.000", True, ("-1.000", "-1.000")),
         (("0.000", "0.000"), "-0.000", True, ("0.000", "0.000")),
         (("0.000", "0.000"), "0.000", True, ("0.000", "0.000")),
         (("0.000", "0.000"), "0.500", True, ("0.500", "0.500")),
         (("1.000", "2.000"), "-2.500", True, ("-1.500", "-0.500")),
         (("1.000", "2.000"), "-2.000", True, ("-1.000", "0.000")),
         (("1.000", "2.000"), "-1.500", True, ("-0.500", "0.500")),
         (("1.000", "2.000"), "-1.000", True, ("0.000", "1.000")),
         (("1.000", "2.000"), "-0.000", True, ("1.000", "2.000")),
         (("1.000", "2.000"), "0.000", True, ("1.000", "2.000")),
         (("1.000", "2.000"), "0.500", True, ("1.500", "2.500")),
         (("1.000", "2.000"), "1.000", True, ("2.000", "3.000")),
     ]
     for ti1, d, a, exp in params:
         ti1 = TimeInterval(begin=TimeValue(ti1[0]), end=TimeValue(ti1[1]))
         d = TimeValue(d)
         ti1.offset(offset=d, allow_negative=a)
         self.assertEqual(ti1.begin, TimeValue(exp[0]))
         self.assertEqual(ti1.end, TimeValue(exp[1]))
示例#3
0
    def test_time_interval_offset(self):
        params = [
            (("0.000", "0.000"), "-1.000", False, ("0.000", "0.000")),
            (("0.000", "0.000"), "-0.000", False, ("0.000", "0.000")),
            (("0.000", "0.000"), "0.000", False, ("0.000", "0.000")),
            (("0.000", "0.000"), "0.500", False, ("0.500", "0.500")),
            (("1.000", "2.000"), "-2.500", False, ("0.000", "0.000")),
            (("1.000", "2.000"), "-2.000", False, ("0.000", "0.000")),
            (("1.000", "2.000"), "-1.500", False, ("0.000", "0.500")),
            (("1.000", "2.000"), "-1.000", False, ("0.000", "1.000")),
            (("1.000", "2.000"), "-0.000", False, ("1.000", "2.000")),
            (("1.000", "2.000"), "0.000", False, ("1.000", "2.000")),
            (("1.000", "2.000"), "0.500", False, ("1.500", "2.500")),
            (("1.000", "2.000"), "1.000", False, ("2.000", "3.000")),

            (("0.000", "0.000"), "-1.000", True, ("-1.000", "-1.000")),
            (("0.000", "0.000"), "-0.000", True, ("0.000", "0.000")),
            (("0.000", "0.000"), "0.000", True, ("0.000", "0.000")),
            (("0.000", "0.000"), "0.500", True, ("0.500", "0.500")),
            (("1.000", "2.000"), "-2.500", True, ("-1.500", "-0.500")),
            (("1.000", "2.000"), "-2.000", True, ("-1.000", "0.000")),
            (("1.000", "2.000"), "-1.500", True, ("-0.500", "0.500")),
            (("1.000", "2.000"), "-1.000", True, ("0.000", "1.000")),
            (("1.000", "2.000"), "-0.000", True, ("1.000", "2.000")),
            (("1.000", "2.000"), "0.000", True, ("1.000", "2.000")),
            (("1.000", "2.000"), "0.500", True, ("1.500", "2.500")),
            (("1.000", "2.000"), "1.000", True, ("2.000", "3.000")),
        ]
        for ti1, d, a, exp in params:
            ti1 = TimeInterval(begin=TimeValue(ti1[0]), end=TimeValue(ti1[1]))
            d = TimeValue(d)
            ti1.offset(offset=d, allow_negative=a)
            self.assertEqual(ti1.begin, TimeValue(exp[0]))
            self.assertEqual(ti1.end, TimeValue(exp[1]))
示例#4
0
    def test_time_interval_inner_contains(self):
        params = [
            ("1.000", "1.000", "0.000", False),
            ("1.000", "1.000", "0.999", False),
            ("1.000", "1.000", "1.000", False),
            ("1.000", "1.000", "1.001", False),
            ("1.000", "1.000", "2.000", False),

            ("1.000", "1.001", "0.000", False),
            ("1.000", "1.001", "0.999", False),
            ("1.000", "1.001", "1.000", False),
            ("1.000", "1.001", "1.001", False),
            ("1.000", "1.001", "1.002", False),
            ("1.000", "1.001", "2.000", False),

            ("1.000", "1.002", "0.000", False),
            ("1.000", "1.002", "0.999", False),
            ("1.000", "1.002", "1.000", False),
            ("1.000", "1.002", "1.001", True),
            ("1.000", "1.002", "1.002", False),
            ("1.000", "1.002", "1.003", False),
            ("1.000", "1.002", "2.000", False),

            ("1.234", "1.237", "0.000", False),
            ("1.234", "1.237", "1.233", False),
            ("1.234", "1.237", "1.234", False),
            ("1.234", "1.237", "1.235", True),
            ("1.234", "1.237", "1.236", True),
            ("1.234", "1.237", "1.237", False),
            ("1.234", "1.237", "1.238", False),
            ("1.234", "1.237", "2.000", False),
        ]
        for b, e, p, f in params:
            ti = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
            self.assertEqual(ti.inner_contains(TimeValue(p)), f)
 def test_time_interval_list_add_not_sorted(self):
     params = [
         ([
             ("1.000", "1.000"),
             ("0.500", "0.500"),
             ("1.000", "1.000"),
         ], [
             ("0.500", "0.500"),
             ("1.000", "1.000"),
             ("1.000", "1.000"),
         ]),
         ([
             ("1.000", "1.000"),
             ("0.500", "0.500"),
         ], [
             ("0.500", "0.500"),
             ("1.000", "1.000"),
         ]),
         ([
             ("2.000", "2.000"),
             ("1.000", "2.000"),
             ("0.500", "0.500"),
         ], [
             ("0.500", "0.500"),
             ("1.000", "2.000"),
             ("2.000", "2.000"),
         ]),
         ([
             ("2.000", "2.000"),
             ("0.500", "0.500"),
             ("2.000", "3.000"),
             ("1.000", "2.000"),
             ("0.500", "0.500"),
         ], [
             ("0.500", "0.500"),
             ("0.500", "0.500"),
             ("1.000", "2.000"),
             ("2.000", "2.000"),
             ("2.000", "3.000"),
         ]),
     ]
     for ins, exp in params:
         l = SyncMapFragmentList(begin=TimeValue("0.000"),
                                 end=TimeValue("10.000"))
         for b, e in ins:
             i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             s = SyncMapFragment(interval=i)
             l.add(s, sort=False)
         l.sort()
         for j, fragment in enumerate(l.fragments):
             b, e = exp[j]
             exp_i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             exp_s = SyncMapFragment(interval=exp_i)
             self.assertTrue(fragment == exp_s)
 def test_time_interval_offset_bad(self):
     params = [
         None,
         1,
         1.234,
         "1.234",
         Decimal("1.234"),
     ]
     ti1 = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("1.000"))
     for p in params:
         with self.assertRaises(TypeError):
             ti1.offset(p)
示例#7
0
 def test_time_interval_offset_bad(self):
     params = [
         None,
         1,
         1.234,
         "1.234",
         Decimal("1.234"),
     ]
     ti1 = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("1.000"))
     for p in params:
         with self.assertRaises(TypeError):
             ti1.offset(p)
 def test_time_interval_list_add_sorted_bad(self):
     l = SyncMapFragmentList(begin=TimeValue("0.000"),
                             end=TimeValue("10.000"))
     i = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("0.000"))
     s = SyncMapFragment(interval=i)
     l.add(s, sort=False)
     i = TimeInterval(begin=TimeValue("1.000"), end=TimeValue("1.000"))
     s = SyncMapFragment(interval=i)
     l.add(s, sort=False)
     i = TimeInterval(begin=TimeValue("2.000"), end=TimeValue("2.000"))
     s = SyncMapFragment(interval=i)
     with self.assertRaises(ValueError):
         l.add(s, sort=True)
示例#9
0
 def test_time_interval_ends_at(self):
     params = [
         ("1.234", "1.237", "0.000", False),
         ("1.234", "1.237", "1.233", False),
         ("1.234", "1.237", "1.234", False),
         ("1.234", "1.237", "1.235", False),
         ("1.234", "1.237", "1.236", False),
         ("1.234", "1.237", "1.237", True),
         ("1.234", "1.237", "1.238", False),
         ("1.234", "1.237", "2.000", False),
     ]
     for b, e, p, f in params:
         ti = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
         self.assertEqual(ti.ends_at(TimeValue(p)), f)
 def test_time_interval_ends_at(self):
     params = [
         ("1.234", "1.237", "0.000", False),
         ("1.234", "1.237", "1.233", False),
         ("1.234", "1.237", "1.234", False),
         ("1.234", "1.237", "1.235", False),
         ("1.234", "1.237", "1.236", False),
         ("1.234", "1.237", "1.237", True),
         ("1.234", "1.237", "1.238", False),
         ("1.234", "1.237", "2.000", False),
     ]
     for b, e, p, f in params:
         ti = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
         self.assertEqual(ti.ends_at(TimeValue(p)), f)
示例#11
0
    def intervals(self, speech=True, time=True):
        """
        Return a list of intervals::

        [(b_1, e_1), (b_2, e_2), ..., (b_k, e_k)]

        where ``b_i`` is the time when the ``i``-th interval begins,
        and ``e_i`` is the time when it ends.

        :param bool speech: if ``True``, return speech intervals,
                            otherwise return nonspeech intervals
        :param bool time: if ``True``, return :class:`~aeneas.exacttiming.TimeInterval` objects,
                          otherwise return indices (int)
        :rtype: list of pairs (see above)
        """
        self._ensure_mfcc_mask()
        if speech:
            self.log(u"Converting speech runs to intervals...")
            intervals = self.__speech_intervals
        else:
            self.log(u"Converting nonspeech runs to intervals...")
            intervals = self.__nonspeech_intervals
        if time:
            mws = self.rconf.mws
            intervals = [
                TimeInterval(begin=(b * mws), end=((e + 1) * mws))
                for b, e in intervals
            ]
        self.log(u"Converting... done")
        return intervals
示例#12
0
 def test_fragment_constructor_interval_nonzero(self):
     interval = TimeInterval(begin=TimeValue("1.000"),
                             end=TimeValue("3.000"))
     frag = SyncMapFragment(interval=interval)
     self.assertEqual(frag.length, TimeValue("2.000"))
     self.assertEqual(frag.chars, 0)
     self.assertEqual(frag.rate, 0)
 def test_time_interval_list_add_bad_sequence(self):
     params = [
         [
             ("1.000", "1.000"),
             ("0.500", "1.500"),
         ],
         [
             ("1.000", "2.000"),
             ("1.500", "1.750"),
         ],
         [
             ("1.000", "2.000"),
             ("1.500", "1.500"),
         ],
         [
             ("1.000", "2.000"),
             ("0.500", "1.500"),
         ],
         [
             ("1.000", "2.000"),
             ("1.500", "2.500"),
         ],
         [
             ("1.000", "2.000"),
             ("0.500", "2.500"),
         ],
     ]
     for seq in params:
         l = SyncMapFragmentList(begin=TimeValue("0.000"),
                                 end=TimeValue("10.000"))
         with self.assertRaises(ValueError):
             for b, e in seq:
                 i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
                 s = SyncMapFragment(interval=i)
                 l.add(s)
 def test_time_interval_list_has_adjacent_fragments_only(self):
     params = [
         ([
             ("0.000", "0.000"),
             ("0.000", "0.000"),
             ("0.000", "0.000"),
         ], True, True),
         ([
             ("0.000", "1.000"),
             ("1.000", "1.000"),
             ("1.000", "1.000"),
         ], True, True),
         ([
             ("0.000", "0.000"),
             ("0.000", "0.000"),
             ("0.000", "1.000"),
         ], True, True),
         ([
             ("0.000", "0.000"),
             ("0.000", "1.000"),
             ("1.000", "1.000"),
         ], True, True),
         ([
             ("0.000", "1.000"),
             ("1.000", "2.000"),
             ("2.000", "3.000"),
         ], True, True),
         ([
             ("0.000", "0.000"),
             ("0.000", "1.000"),
             ("1.000", "1.000"),
             ("1.000", "2.000"),
             ("2.000", "2.000"),
         ], True, True),
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.500"),
                 ("1.500", "2.000"),
                 ("2.000", "2.000"),
             ],
             True,
             True,
         ),
     ]
     for frags, exp, exp_inside in params:
         l = SyncMapFragmentList(begin=TimeValue("0.000"),
                                 end=TimeValue("10.000"))
         for b, e in frags:
             i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             s = SyncMapFragment(interval=i)
             l.add(s)
         self.assertEqual(l.has_adjacent_fragments_only(), exp)
         self.assertEqual(
             l.has_adjacent_fragments_only(min_index=1,
                                           max_index=len(l) - 1),
             exp_inside)
 def test_time_interval_constructor(self):
     params = [
         ("0.000", "0.000"),
         ("0.000", "1.000"),
         ("1.000", "1.000"),
         ("1.234", "1.235"),
     ]
     for b, e in params:
         TimeInterval(begin=TimeValue(b), end=TimeValue(e))
 def test_time_interval_list_add_bad_type(self):
     params = [
         None, (0.000, 5.000), (TimeValue("0.000"), TimeValue("5.000")),
         TimeInterval(begin=TimeValue("0.000"), end=TimeValue("5.000"))
     ]
     l = SyncMapFragmentList(begin=TimeValue("0.000"),
                             end=TimeValue("10.000"))
     for p in params:
         with self.assertRaises(TypeError):
             l.add(p)
示例#17
0
 def test_time_interval_percent(self):
     params = [
         (-100, "0.000"),
         (-50, "0.000"),
         (0, "0.000"),
         (10, "0.100"),
         (25, "0.250"),
         (50, "0.500"),
         (75, "0.750"),
         (90, "0.900"),
         (100, "1.000"),
         (150, "1.000"),
         (200, "1.000"),
     ]
     t = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("1.000"))
     for p, e in params:
         p = Decimal(p)
         e = TimeValue(e)
         self.assertEqual(t.percent_value(p), e)
 def test_time_interval_percent(self):
     params = [
         (-100, "0.000"),
         (-50, "0.000"),
         (0, "0.000"),
         (10, "0.100"),
         (25, "0.250"),
         (50, "0.500"),
         (75, "0.750"),
         (90, "0.900"),
         (100, "1.000"),
         (150, "1.000"),
         (200, "1.000"),
     ]
     t = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("1.000"))
     for p, e in params:
         p = Decimal(p)
         e = TimeValue(e)
         self.assertEqual(t.percent_value(p), e)
 def test_time_interval_bad_value(self):
     params = [
         ("1.000", "0.000"),
         ("-1.000", "0.000"),
         ("0.000", "-1.000"),
         ("-2.000", "-1.000"),
     ]
     for b, e in params:
         with self.assertRaises(ValueError):
             TimeInterval(begin=TimeValue(b), end=TimeValue(e))
 def test_time_interval_bad_type(self):
     params = [
         (None, None),
         (0, 1),
         (TimeValue("0.000"), 1),
         (0, TimeValue("1.000")),
     ]
     for b, e in params:
         with self.assertRaises(TypeError):
             TimeInterval(begin=b, end=e)
 def test_time_interval_length(self):
     params = [
         ("0.000", "0.000", "0.000"),
         ("0.000", "1.000", "1.000"),
         ("1.000", "1.000", "0.000"),
         ("1.234", "1.235", "0.001"),
     ]
     for b, e, l in params:
         ti = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
         self.assertEqual(ti.length, TimeValue(l))
 def test_time_interval_has_zero_length(self):
     params = [
         ("0.000", "0.000", True),
         ("0.000", "1.000", False),
         ("1.000", "1.000", True),
         ("1.234", "1.235", False),
     ]
     for b, e, f in params:
         ti = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
         self.assertEqual(ti.has_zero_length, f)
 def test_time_interval_intersection(self):
     params = [
         # TABLE 1
         (("1.000", "1.000"), ("0.000", "0.000"), None),
         (("1.000", "1.000"), ("1.000", "1.000"), ("1.000", "1.000")),
         (("1.000", "1.000"), ("2.000", "2.000"), None),
         # TABLE 2
         (("1.000", "1.000"), ("0.000", "0.500"), None),
         (("1.000", "1.000"), ("0.500", "1.000"), ("1.000", "1.000")),
         (("1.000", "1.000"), ("0.500", "1.500"), ("1.000", "1.000")),
         (("1.000", "1.000"), ("1.000", "1.500"), ("1.000", "1.000")),
         (("1.000", "1.000"), ("1.500", "2.000"), None),
         # TABLE 3
         (("1.000", "2.000"), ("0.000", "0.000"), None),
         (("1.000", "2.000"), ("1.000", "1.000"), ("1.000", "1.000")),
         (("1.000", "2.000"), ("1.500", "1.500"), ("1.500", "1.500")),
         (("1.000", "2.000"), ("2.000", "2.000"), ("2.000", "2.000")),
         (("1.000", "2.000"), ("2.500", "2.500"), None),
         # TABLE 4
         (("1.000", "2.000"), ("0.000", "0.500"), None),
         (("1.000", "2.000"), ("0.000", "1.000"), ("1.000", "1.000")),
         (("1.000", "2.000"), ("0.000", "1.500"), ("1.000", "1.500")),
         (("1.000", "2.000"), ("0.000", "2.000"), ("1.000", "2.000")),
         (("1.000", "2.000"), ("0.000", "2.500"), ("1.000", "2.000")),
         # TABLE 5
         (("1.000", "2.000"), ("1.000", "1.500"), ("1.000", "1.500")),
         (("1.000", "2.000"), ("1.000", "2.000"), ("1.000", "2.000")),
         (("1.000", "2.000"), ("1.000", "2.500"), ("1.000", "2.000")),
         # TABLE 6
         (("1.000", "2.000"), ("1.100", "1.500"), ("1.100", "1.500")),
         (("1.000", "2.000"), ("1.100", "2.000"), ("1.100", "2.000")),
         (("1.000", "2.000"), ("1.100", "2.500"), ("1.100", "2.000")),
         # TABLE 7
         (("1.000", "2.000"), ("2.000", "2.500"), ("2.000", "2.000")),
         # TABLE 8
         (("1.000", "2.000"), ("2.500", "3.000"), None),
     ]
     for ti1, ti2, exp in params:
         ti1 = TimeInterval(begin=TimeValue(ti1[0]), end=TimeValue(ti1[1]))
         ti2 = TimeInterval(begin=TimeValue(ti2[0]), end=TimeValue(ti2[1]))
         if exp is not None:
             exp = TimeInterval(begin=TimeValue(exp[0]),
                                end=TimeValue(exp[1]))
         self.assertEqual(ti1.intersection(ti2), exp)
         self.assertEqual(ti2.intersection(ti1), exp)
         self.assertEqual(ti1.overlaps(ti2), exp is not None)
         self.assertEqual(ti2.overlaps(ti1), exp is not None)
示例#24
0
 def test_time_interval_relative_position_of(self):
     params = [
         # TABLE 1
         (("1.000", "1.000"), ("0.000", "0.000"), TimeInterval.RELATIVE_POSITION_PP_L),
         (("1.000", "1.000"), ("1.000", "1.000"), TimeInterval.RELATIVE_POSITION_PP_C),
         (("1.000", "1.000"), ("2.000", "2.000"), TimeInterval.RELATIVE_POSITION_PP_G),
         # TABLE 2
         (("1.000", "1.000"), ("0.000", "0.500"), TimeInterval.RELATIVE_POSITION_PI_LL),
         (("1.000", "1.000"), ("0.500", "1.000"), TimeInterval.RELATIVE_POSITION_PI_LC),
         (("1.000", "1.000"), ("0.500", "1.500"), TimeInterval.RELATIVE_POSITION_PI_LG),
         (("1.000", "1.000"), ("1.000", "1.500"), TimeInterval.RELATIVE_POSITION_PI_CG),
         (("1.000", "1.000"), ("1.500", "2.000"), TimeInterval.RELATIVE_POSITION_PI_GG),
         # TABLE 3
         (("1.000", "2.000"), ("0.000", "0.000"), TimeInterval.RELATIVE_POSITION_IP_L),
         (("1.000", "2.000"), ("1.000", "1.000"), TimeInterval.RELATIVE_POSITION_IP_B),
         (("1.000", "2.000"), ("1.500", "1.500"), TimeInterval.RELATIVE_POSITION_IP_I),
         (("1.000", "2.000"), ("2.000", "2.000"), TimeInterval.RELATIVE_POSITION_IP_E),
         (("1.000", "2.000"), ("2.500", "2.500"), TimeInterval.RELATIVE_POSITION_IP_G),
         # TABLE 4
         (("1.000", "2.000"), ("0.000", "0.500"), TimeInterval.RELATIVE_POSITION_II_LL),
         (("1.000", "2.000"), ("0.000", "1.000"), TimeInterval.RELATIVE_POSITION_II_LB),
         (("1.000", "2.000"), ("0.000", "1.500"), TimeInterval.RELATIVE_POSITION_II_LI),
         (("1.000", "2.000"), ("0.000", "2.000"), TimeInterval.RELATIVE_POSITION_II_LE),
         (("1.000", "2.000"), ("0.000", "2.500"), TimeInterval.RELATIVE_POSITION_II_LG),
         # TABLE 5
         (("1.000", "2.000"), ("1.000", "1.500"), TimeInterval.RELATIVE_POSITION_II_BI),
         (("1.000", "2.000"), ("1.000", "2.000"), TimeInterval.RELATIVE_POSITION_II_BE),
         (("1.000", "2.000"), ("1.000", "2.500"), TimeInterval.RELATIVE_POSITION_II_BG),
         # TABLE 6
         (("1.000", "2.000"), ("1.100", "1.500"), TimeInterval.RELATIVE_POSITION_II_II),
         (("1.000", "2.000"), ("1.100", "2.000"), TimeInterval.RELATIVE_POSITION_II_IE),
         (("1.000", "2.000"), ("1.100", "2.500"), TimeInterval.RELATIVE_POSITION_II_IG),
         # TABLE 7
         (("1.000", "2.000"), ("2.000", "2.500"), TimeInterval.RELATIVE_POSITION_II_EG),
         # TABLE 8
         (("1.000", "2.000"), ("2.500", "3.000"), TimeInterval.RELATIVE_POSITION_II_GG),
     ]
     for ti1, ti2, exp in params:
         ti1 = TimeInterval(begin=TimeValue(ti1[0]), end=TimeValue(ti1[1]))
         ti2 = TimeInterval(begin=TimeValue(ti2[0]), end=TimeValue(ti2[1]))
         self.assertEqual(ti1.relative_position_of(ti2), exp)
         self.assertEqual(ti2.relative_position_wrt(ti1), exp)
示例#25
0
 def test_time_interval_non_zero_before_non_zero(self):
     params = [
         (("1.000", "1.000"), ("0.000", "2.000"), False),
         (("1.000", "1.000"), ("0.999", "2.000"), False),
         (("1.000", "1.000"), ("1.000", "1.000"), False),
         (("1.000", "1.000"), ("1.000", "2.000"), False),
         (("1.000", "1.000"), ("1.001", "2.000"), False),
         (("1.000", "1.000"), ("2.000", "2.000"), False),
         (("0.000", "1.000"), ("0.000", "2.000"), False),
         (("0.000", "1.000"), ("0.999", "2.000"), False),
         (("0.000", "1.000"), ("1.000", "1.000"), False),
         (("0.000", "1.000"), ("1.000", "2.000"), True),
         (("0.000", "1.000"), ("1.001", "2.000"), False),
         (("0.000", "1.000"), ("2.000", "2.000"), False),
     ]
     for ti1, ti2, exp in params:
         ti1 = TimeInterval(begin=TimeValue(ti1[0]), end=TimeValue(ti1[1]))
         ti2 = TimeInterval(begin=TimeValue(ti2[0]), end=TimeValue(ti2[1]))
         self.assertEqual(ti1.is_non_zero_before_non_zero(ti2), exp)
         self.assertEqual(ti2.is_non_zero_after_non_zero(ti1), exp)
 def test_time_interval_ordering(self):
     t_0_0 = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("0.000"))
     t_0_1 = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("1.000"))
     t_0_3 = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("3.000"))
     q_0_3 = TimeInterval(begin=TimeValue("0.000"), end=TimeValue("3.000"))
     t_2_2 = TimeInterval(begin=TimeValue("2.000"), end=TimeValue("2.000"))
     q_2_2 = TimeInterval(begin=TimeValue("2.000"), end=TimeValue("2.000"))
     self.assertTrue(t_0_0 <= t_0_0)
     self.assertTrue(t_0_0 == t_0_0)
     self.assertTrue(t_0_0 >= t_0_0)
     self.assertFalse(t_0_0 != t_0_0)
     self.assertTrue(t_0_1 <= t_0_1)
     self.assertTrue(t_0_1 == t_0_1)
     self.assertTrue(t_0_1 >= t_0_1)
     self.assertTrue(t_0_0 < t_0_1)
     self.assertTrue(t_0_0 < t_0_3)
     self.assertTrue(t_0_0 < t_2_2)
     self.assertTrue(t_0_0 <= t_0_1)
     self.assertTrue(t_0_0 <= t_0_3)
     self.assertTrue(t_0_0 <= t_2_2)
     self.assertFalse(t_0_3 < q_0_3)
     self.assertTrue(t_0_3 <= q_0_3)
     self.assertTrue(t_0_3 == q_0_3)
     self.assertTrue(t_0_3 >= q_0_3)
     self.assertFalse(t_0_3 > q_0_3)
     self.assertFalse(t_0_3 != q_0_3)
     self.assertFalse(t_2_2 < q_2_2)
     self.assertTrue(t_2_2 <= q_2_2)
     self.assertTrue(t_2_2 == q_2_2)
     self.assertTrue(t_2_2 >= q_2_2)
     self.assertFalse(t_2_2 > q_2_2)
     self.assertFalse(t_2_2 != q_2_2)
 def test_time_interval_list_add_good(self):
     params = [
         ("5.000", "6.000", "5.000", "5.000"),
         ("5.000", "6.000", "5.000", "5.500"),
         ("5.000", "6.000", "5.000", "6.000"),
         ("5.000", "6.000", "5.500", "5.600"),
         ("5.000", "6.000", "6.000", "6.000"),
     ]
     for lb, le, b, e in params:
         i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
         s = SyncMapFragment(interval=i)
         l = SyncMapFragmentList(begin=TimeValue(lb), end=TimeValue(le))
         l.add(s)
 def test_time_interval_list_add_bad_value(self):
     params = [
         ("5.000", "6.000", "1.000", "2.000"),
         ("5.000", "6.000", "1.000", "5.000"),
         ("5.000", "6.000", "5.000", "7.000"),
         ("5.000", "6.000", "5.500", "7.000"),
         ("5.000", "6.000", "6.000", "7.000"),
         ("5.000", "6.000", "7.000", "8.000"),
     ]
     for lb, le, b, e in params:
         i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
         s = SyncMapFragment(interval=i)
         l = SyncMapFragmentList(begin=TimeValue(lb), end=TimeValue(le))
         with self.assertRaises(ValueError):
             l.add(s)
示例#29
0
 def __init__(self,
              text_fragment=None,
              interval=None,
              begin=None,
              end=None,
              fragment_type=REGULAR,
              confidence=1.0):
     self.text_fragment = text_fragment
     if interval is not None:
         self.interval = interval
     elif (begin is not None) and (end is not None):
         self.interval = TimeInterval(begin, end)
     else:
         self.interval = None
     self.fragment_type = fragment_type
     self.confidence = confidence
 def test_has_zero_length_leaves(self):
     params = [
         ([("0.000", "0.000"), ("0.000", "0.000")], True),
         ([("0.000", "0.000"), ("0.000", "1.000")], True),
         ([("0.000", "1.000"), ("1.000", "1.000")], True),
         ([("0.000", "1.000"), ("1.000", "2.000")], False),
         ([("0.000", "0.000"), ("1.000", "1.000")], True),
         ([("0.000", "0.000"), ("1.000", "2.000")], True),
         ([("0.000", "1.000"), ("2.000", "2.000")], True),
         ([("0.000", "1.000"), ("2.000", "3.000")], False),
     ]
     for l, exp in params:
         tree = Tree()
         for b, e in l:
             interval = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             smf = SyncMapFragment(interval=interval)
             child = Tree(value=smf)
             tree.add_child(child, as_last=True)
         syn = SyncMap(tree=tree)
         self.assertEqual(syn.has_zero_length_leaves, exp)
 def test_leaves_are_consistent(self):
     params = [
         ([("0.000", "0.000"), ("0.000", "0.000")], True),
         ([("0.000", "0.000"), ("0.000", "1.000")], True),
         ([("0.000", "1.000"), ("1.000", "1.000")], True),
         ([("0.000", "1.000"), ("1.000", "2.000")], True),
         ([("0.000", "0.000"), ("1.000", "1.000")], True),
         ([("0.000", "0.000"), ("1.000", "2.000")], True),
         ([("0.000", "1.000"), ("2.000", "2.000")], True),
         ([("0.000", "1.000"), ("2.000", "3.000")], True),
         ([("0.000", "1.000"), ("1.000", "1.000"),
           ("1.000", "2.000")], True),
         ([("0.000", "1.000"), ("1.000", "1.000"),
           ("2.000", "2.000")], True),
         ([("0.000", "1.000"), ("2.000", "3.000"),
           ("1.500", "1.500")], True),
         ([("0.000", "1.000"), ("2.000", "3.000"),
           ("1.500", "1.750")], True),
         ([("0.000", "1.000"), ("1.040", "2.000")], True),
         ([("0.000", "1.000"), ("0.000", "0.500")], False),
         ([("0.000", "1.000"), ("0.000", "1.000")], False),
         ([("0.000", "1.000"), ("0.000", "1.500")], False),
         ([("0.000", "1.000"), ("0.500", "0.500")], False),
         ([("0.000", "1.000"), ("0.500", "0.750")], False),
         ([("0.000", "1.000"), ("0.500", "1.000")], False),
         ([("0.000", "1.000"), ("0.500", "1.500")], False),
         ([("0.000", "1.000"), ("2.000", "2.000"),
           ("1.500", "2.500")], False),
         ([("0.000", "1.000"), ("2.000", "3.000"),
           ("1.500", "2.500")], False),
         ([("0.000", "1.000"), ("0.960", "2.000")], False),
     ]
     for l, exp in params:
         tree = Tree()
         for b, e in l:
             interval = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             smf = SyncMapFragment(interval=interval)
             child = Tree(value=smf)
             tree.add_child(child, as_last=True)
         syn = SyncMap(tree=tree)
         self.assertEqual(syn.leaves_are_consistent, exp)
 def test_time_interval_list_clone(self):
     params = [
         [
             ("1.000", "1.000"),
             ("0.500", "0.500"),
             ("1.000", "1.000"),
         ],
         [
             ("1.000", "1.000"),
             ("0.500", "0.500"),
         ],
         [
             ("2.000", "2.000"),
             ("1.000", "2.000"),
             ("0.500", "0.500"),
         ],
         [
             ("2.000", "2.000"),
             ("0.500", "0.500"),
             ("2.000", "3.000"),
             ("1.000", "2.000"),
             ("0.500", "0.500"),
         ],
     ]
     for ins in params:
         l = SyncMapFragmentList(begin=TimeValue("0.000"),
                                 end=TimeValue("10.000"))
         for b, e in ins:
             i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             s = SyncMapFragment(interval=i)
             l.add(s)
         c = l.clone()
         self.assertNotEqual(id(l), id(c))
         self.assertEqual(len(l), len(c))
         for j, fragment in enumerate(l.fragments):
             self.assertNotEqual(id(l[j]), id(c[j]))
             self.assertEqual(l[j], c[j])
             fragment.fragment_type = SyncMapFragment.NONSPEECH
             self.assertNotEqual(l[j].fragment_type, c[j].fragment_type)
             self.assertEqual(l[j].fragment_type, SyncMapFragment.NONSPEECH)
             self.assertEqual(c[j].fragment_type, SyncMapFragment.REGULAR)
示例#33
0
 def test_time_interval_intersection(self):
     params = [
         # TABLE 1
         (("1.000", "1.000"), ("0.000", "0.000"), None),
         (("1.000", "1.000"), ("1.000", "1.000"), ("1.000", "1.000")),
         (("1.000", "1.000"), ("2.000", "2.000"), None),
         # TABLE 2
         (("1.000", "1.000"), ("0.000", "0.500"), None),
         (("1.000", "1.000"), ("0.500", "1.000"), ("1.000", "1.000")),
         (("1.000", "1.000"), ("0.500", "1.500"), ("1.000", "1.000")),
         (("1.000", "1.000"), ("1.000", "1.500"), ("1.000", "1.000")),
         (("1.000", "1.000"), ("1.500", "2.000"), None),
         # TABLE 3
         (("1.000", "2.000"), ("0.000", "0.000"), None),
         (("1.000", "2.000"), ("1.000", "1.000"), ("1.000", "1.000")),
         (("1.000", "2.000"), ("1.500", "1.500"), ("1.500", "1.500")),
         (("1.000", "2.000"), ("2.000", "2.000"), ("2.000", "2.000")),
         (("1.000", "2.000"), ("2.500", "2.500"), None),
         # TABLE 4
         (("1.000", "2.000"), ("0.000", "0.500"), None),
         (("1.000", "2.000"), ("0.000", "1.000"), ("1.000", "1.000")),
         (("1.000", "2.000"), ("0.000", "1.500"), ("1.000", "1.500")),
         (("1.000", "2.000"), ("0.000", "2.000"), ("1.000", "2.000")),
         (("1.000", "2.000"), ("0.000", "2.500"), ("1.000", "2.000")),
         # TABLE 5
         (("1.000", "2.000"), ("1.000", "1.500"), ("1.000", "1.500")),
         (("1.000", "2.000"), ("1.000", "2.000"), ("1.000", "2.000")),
         (("1.000", "2.000"), ("1.000", "2.500"), ("1.000", "2.000")),
         # TABLE 6
         (("1.000", "2.000"), ("1.100", "1.500"), ("1.100", "1.500")),
         (("1.000", "2.000"), ("1.100", "2.000"), ("1.100", "2.000")),
         (("1.000", "2.000"), ("1.100", "2.500"), ("1.100", "2.000")),
         # TABLE 7
         (("1.000", "2.000"), ("2.000", "2.500"), ("2.000", "2.000")),
         # TABLE 8
         (("1.000", "2.000"), ("2.500", "3.000"), None),
     ]
     for ti1, ti2, exp in params:
         ti1 = TimeInterval(begin=TimeValue(ti1[0]), end=TimeValue(ti1[1]))
         ti2 = TimeInterval(begin=TimeValue(ti2[0]), end=TimeValue(ti2[1]))
         if exp is not None:
             exp = TimeInterval(begin=TimeValue(exp[0]), end=TimeValue(exp[1]))
         self.assertEqual(ti1.intersection(ti2), exp)
         self.assertEqual(ti2.intersection(ti1), exp)
         self.assertEqual(ti1.overlaps(ti2), exp is not None)
         self.assertEqual(ti2.overlaps(ti1), exp is not None)
 def test_time_interval_non_zero_before_non_zero(self):
     params = [
         (("1.000", "1.000"), ("0.000", "2.000"), False),
         (("1.000", "1.000"), ("0.999", "2.000"), False),
         (("1.000", "1.000"), ("1.000", "1.000"), False),
         (("1.000", "1.000"), ("1.000", "2.000"), False),
         (("1.000", "1.000"), ("1.001", "2.000"), False),
         (("1.000", "1.000"), ("2.000", "2.000"), False),
         (("0.000", "1.000"), ("0.000", "2.000"), False),
         (("0.000", "1.000"), ("0.999", "2.000"), False),
         (("0.000", "1.000"), ("1.000", "1.000"), False),
         (("0.000", "1.000"), ("1.000", "2.000"), True),
         (("0.000", "1.000"), ("1.001", "2.000"), False),
         (("0.000", "1.000"), ("2.000", "2.000"), False),
     ]
     for ti1, ti2, exp in params:
         ti1 = TimeInterval(begin=TimeValue(ti1[0]), end=TimeValue(ti1[1]))
         ti2 = TimeInterval(begin=TimeValue(ti2[0]), end=TimeValue(ti2[1]))
         self.assertEqual(ti1.is_non_zero_before_non_zero(ti2), exp)
         self.assertEqual(ti2.is_non_zero_after_non_zero(ti1), exp)
示例#35
0
 def test_fragment_pretty_print(self):
     interval = TimeInterval(begin=TimeValue("1.000"),
                             end=TimeValue("3.000"))
     text = TextFragment(identifier=u"f001", lines=[u"Hello", u"World"])
     frag = SyncMapFragment(text_fragment=text, interval=interval)
     self.assertEqual(frag.pretty_print, u"f001\t1.000\t3.000\tHello World")
示例#36
0
 def test_fragment_pretty_print_empty_text(self):
     interval = TimeInterval(begin=TimeValue("1.000"),
                             end=TimeValue("3.000"))
     frag = SyncMapFragment(interval=interval)
     self.assertEqual(frag.pretty_print, u"\t1.000\t3.000\t")
 def test_time_interval_list_offset(self):
     params = [
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "0.500",
             [
                 ("1.000", "1.000"),
                 ("1.500", "1.500"),
                 ("1.500", "2.500"),
             ],
         ),
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "8.000",
             [
                 ("8.500", "8.500"),
                 ("9.000", "9.000"),
                 ("9.000", "10.000"),
             ],
         ),
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "8.500",
             [
                 ("9.000", "9.000"),
                 ("9.500", "9.500"),
                 ("9.500", "10.000"),
             ],
         ),
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "9.000",
             [
                 ("9.500", "9.500"),
                 ("10.000", "10.000"),
                 ("10.000", "10.000"),
             ],
         ),
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "10.000",
             [
                 ("10.000", "10.000"),
                 ("10.000", "10.000"),
                 ("10.000", "10.000"),
             ],
         ),
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "-0.500",
             [
                 ("0.000", "0.000"),
                 ("0.500", "0.500"),
                 ("0.500", "1.500"),
             ],
         ),
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "-1.000",
             [
                 ("0.000", "0.000"),
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
             ],
         ),
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "-1.500",
             [
                 ("0.000", "0.000"),
                 ("0.000", "0.000"),
                 ("0.000", "0.500"),
             ],
         ),
         (
             [
                 ("0.500", "0.500"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
             ],
             "-3.000",
             [
                 ("0.000", "0.000"),
                 ("0.000", "0.000"),
                 ("0.000", "0.000"),
             ],
         ),
     ]
     for ins, off, exp in params:
         l = SyncMapFragmentList(begin=TimeValue("0.000"),
                                 end=TimeValue("10.000"))
         for b, e in ins:
             i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             s = SyncMapFragment(interval=i)
             l.add(s)
         l.offset(TimeValue(off))
         for j, fragment in enumerate(l.fragments):
             b, e = exp[j]
             exp_i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             exp_s = SyncMapFragment(interval=exp_i)
             self.assertTrue(fragment == exp_s)
 def test_time_interval_list_fix_zero_length_fragments_middle(self):
     params = [
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
                 ("2.000", "9.999"),
             ],
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.001"),
                 ("1.001", "2.000"),
                 ("2.000", "9.999"),
             ],
         ),
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
                 ("2.000", "9.999"),
             ],
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.001"),
                 ("1.001", "1.002"),
                 ("1.002", "2.000"),
                 ("2.000", "9.999"),
             ],
         ),
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
                 ("2.000", "9.999"),
             ],
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.001"),
                 ("1.001", "1.002"),
                 ("1.002", "1.003"),
                 ("1.003", "2.000"),
                 ("2.000", "9.999"),
             ],
         ),
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
                 ("2.000", "3.000"),
                 ("3.000", "4.000"),
                 ("4.000", "4.000"),
                 ("4.000", "5.000"),
                 ("5.000", "9.999"),
             ],
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.001"),
                 ("1.001", "1.002"),
                 ("1.002", "1.003"),
                 ("1.003", "2.000"),
                 ("2.000", "3.000"),
                 ("3.000", "4.000"),
                 ("4.000", "4.001"),
                 ("4.001", "5.000"),
                 ("5.000", "9.999"),
             ],
         ),
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "2.000"),
                 ("2.000", "3.000"),
                 ("3.000", "4.000"),
                 ("4.000", "4.000"),
                 ("4.000", "5.000"),
                 ("5.000", "9.999"),
             ],
             [
                 ("0.000", "0.000"),
                 ("0.000", "0.001"),
                 ("0.001", "1.000"),
                 ("1.000", "1.001"),
                 ("1.001", "1.002"),
                 ("1.002", "1.003"),
                 ("1.003", "2.000"),
                 ("2.000", "3.000"),
                 ("3.000", "4.000"),
                 ("4.000", "4.001"),
                 ("4.001", "5.000"),
                 ("5.000", "9.999"),
             ],
         ),
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.002"),
                 ("1.002", "9.999"),
             ],
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.001"),
                 ("1.001", "1.002"),
                 ("1.002", "1.003"),
                 ("1.003", "1.005"),
                 ("1.005", "9.999"),
             ],
         ),
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.002"),
                 ("1.002", "2.000"),
                 ("2.000", "9.999"),
             ],
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.001"),
                 ("1.001", "1.002"),
                 ("1.002", "1.003"),
                 ("1.003", "1.005"),
                 ("1.005", "2.000"),
                 ("2.000", "9.999"),
             ],
         ),
         (
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.000"),
                 ("1.000", "1.002"),
                 ("1.002", "1.002"),
                 ("1.002", "2.000"),
                 ("2.000", "9.999"),
             ],
             [
                 ("0.000", "0.000"),
                 ("0.000", "1.000"),
                 ("1.000", "1.001"),
                 ("1.001", "1.002"),
                 ("1.002", "1.003"),
                 ("1.003", "1.005"),
                 ("1.005", "1.006"),
                 ("1.006", "2.000"),
                 ("2.000", "9.999"),
             ],
         ),
     ]
     for ins, exp in params:
         l = SyncMapFragmentList(begin=TimeValue("0.000"),
                                 end=TimeValue("10.000"))
         for b, e in ins:
             i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             s = SyncMapFragment(interval=i)
             l.add(s)
         l.fix_zero_length_fragments(duration=TimeValue("0.001"),
                                     min_index=1,
                                     max_index=(len(l) - 1))
         for j, fragment in enumerate(l.fragments):
             b, e = exp[j]
             exp_i = TimeInterval(begin=TimeValue(b), end=TimeValue(e))
             exp_s = SyncMapFragment(interval=exp_i)
             self.assertTrue(fragment == exp_s)