Ejemplo n.º 1
0
    def test_extend_labels_one_history(self):
        stream = (('1', 1), ('2', 2), ('3', 3))
        one_extended = [('1', tuple(), 1), ('2', tuple(), 2),
                        ('3', tuple(), 3)]

        self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 1)),
                          one_extended)
Ejemplo n.º 2
0
    def test_extend_labels_simple(self):
        stream = (('1', 1), ('2', 2), ('3', 3))
        two_extended = [('1', ('<START>', ), 1), ('2', ('1', ), 2),
                        ('3', ('2', ), 3)]

        self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 2)),
                          two_extended)
Ejemplo n.º 3
0
	def test_extend_labels_three_history(self):
		stream = (('1', 1), ('2', 2), ('3', 3))
		three_extended = [('1', ('<START>', '<START>::<START>'), 1),
						  ('2', ('1', '<START>::1'), 2),
						  ('3', ('2', '1::2'), 3)]

		self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 3)), three_extended)
Ejemplo n.º 4
0
	def test_extend_labels_one_history(self):
		stream = (('1', 1), ('2', 2), ('3', 3))
		one_extended = [('1', tuple(), 1),
						('2', tuple(), 2),
						('3', tuple(), 3)]

		self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 1)), one_extended)
Ejemplo n.º 5
0
	def test_extend_labels_simple(self):
		stream = (('1', 1), ('2', 2), ('3', 3))
		two_extended = [('1', ('<START>',), 1),
						('2', ('1',), 2),
						('3', ('2',), 3)]

		self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 2)), two_extended)
Ejemplo n.º 6
0
    def test_extend_labels_three_history(self):
        stream = (('1', 1), ('2', 2), ('3', 3))
        three_extended = [('1', ('<START>', '<START>::<START>'), 1),
                          ('2', ('1', '<START>::1'), 2),
                          ('3', ('2', '1::2'), 3)]

        self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 3)),
                          three_extended)
Ejemplo n.º 7
0
	def test_extend_labels_multiple_sentences(self):
		stream = (('1', 1), ('2', 2), ('<STOP>', '<STOP>'), ('<START>', '<START>'), ('1', 1))
		two_extended = [('1', ('<START>',), 1),
						('2', ('1',), 2),
						('<STOP>', ('2',), '<STOP>'),
						('<START>', ('<START>',), '<START>'),
						('1', ('<START>',), 1)]

		self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 2)), two_extended)
Ejemplo n.º 8
0
    def test_extend_labels_multiple_sentences(self):
        stream = (('1', 1), ('2', 2), ('<STOP>', '<STOP>'),
                  ('<START>', '<START>'), ('1', 1))
        two_extended = [('1', ('<START>', ), 1), ('2', ('1', ), 2),
                        ('<STOP>', ('2', ), '<STOP>'),
                        ('<START>', ('<START>', ), '<START>'),
                        ('1', ('<START>', ), 1)]

        self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 2)),
                          two_extended)
Ejemplo n.º 9
0
    def test_extend_labels_longer_history_than_sentence(self):
        stream = (('1', 1), ('2', 2))
        five_extended = [
            ('1', ('<START>', '<START>::<START>', '<START>::<START>::<START>',
                   '<START>::<START>::<START>::<START>'), 1),
            ('2', ('1', '<START>::1', '<START>::<START>::1',
                   '<START>::<START>::<START>::1'), 2)
        ]

        self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 5)),
                          five_extended)
Ejemplo n.º 10
0
	def test_extend_labels_longer_history_than_sentence(self):
		stream = (('1', 1), ('2', 2))
		five_extended = [('1', ('<START>',
								'<START>::<START>',
								'<START>::<START>::<START>',
								'<START>::<START>::<START>::<START>'), 1),
						 ('2', ('1', '<START>::1',
								'<START>::<START>::1',
								'<START>::<START>::<START>::1'), 2)]

		self.assertEquals(list(HiddenMarkovModel._extend_labels(stream, 5)), five_extended)