Example #1
0
 def test_three_context(self):
     test_string = "godspeed"
     test_features = set(
         tuple(x) for x in features.contexts(test_string, context_size=3))
     expected_features = set([(('g', 'o', 'd'), 's', ('p', 'e', 'e')),
                              (('o', 'd', 's'), 'p', ('e', 'e', 'd'))])
     self.assertEqual(test_features, expected_features)
Example #2
0
 def test_one_context(self):
     test_string = "hello"
     test_features = set(
         tuple(x) for x in features.contexts(test_string, context_size=1))
     expected_features = set([(('h', ), 'e', ('l', )),
                              (('l', ), 'l', ('o', )),
                              (('e', ), 'l', ('l', ))])
     self.assertEqual(test_features, expected_features)
Example #3
0
	def test_one_context(self):
		test_string = "hello"
		test_features = set(tuple(x) for x in features.contexts(test_string, context_size=1))
		expected_features = set([(('h',), 'e', ('l',)), (('l',), 'l', ('o',)), (('e',), 'l', ('l',))])
		self.assertEqual(test_features, expected_features)
Example #4
0
	def test_three_context(self):
		test_string = "godspeed"
		test_features = set(tuple(x) for x in features.contexts(test_string, context_size=3))
		expected_features = set([(('g', 'o', 'd'), 's', ('p', 'e', 'e')),
								 (('o', 'd', 's'), 'p', ('e', 'e', 'd'))])
		self.assertEqual(test_features, expected_features)
Example #5
0
 def _file_triples(self, lines):
     for line in lines:
         for triple in features.contexts(line.rstrip().split(),
                                         context_size=1):
             yield triple
Example #6
0
	def _file_triples(self, lines):
		for line in lines:
			for triple in features.contexts(line.rstrip().split(), context_size=1):
				yield triple