Пример #1
0
 def test_bishingle(self):
     expected = [
         'A_B', 'A_C', 'A_a', 'A_b', 'A_c', 'B_C', 'B_a', 'B_b', 'B_c',
         'C_a', 'C_b', 'C_c', 'a_b', 'a_c', 'b_c'
     ]
     t = KShingleTransformer(Sentinel(), k=2)
     self.assertListEqual(
         expected, list(t.k_shingle(TestKShingleTransformer.segments)))
Пример #2
0
 def test_bishingle(self):
     expected = ['A_B', 'A_C', 'A_a', 'A_b', 'A_c',
                 'B_C', 'B_a', 'B_b', 'B_c',
                 'C_a', 'C_b', 'C_c',
                 'a_b', 'a_c',
                 'b_c']
     t = KShingleTransformer(Sentinel(), k=2)
     self.assertListEqual(expected, list(t.k_shingle(
         TestKShingleTransformer.segments
     )))
Пример #3
0
    def test_iter(self):
        expected = [
            1,
            TestKShingleTransformer.tokensA + TestKShingleTransformer.tokensB
        ]
        n = -1
        rows = Rows([[1, TestKShingleTransformer.segments]] * 3)

        for n, row in enumerate(KShingleTransformer(rows)):
            self.assertListEqual(expected, row)

        self.assertEqual(2, n)
Пример #4
0
 def test_unishingle(self):
     expected = []
     t = KShingleTransformer(Sentinel(), k=1)
     self.assertListEqual(expected,
                          list(t.k_shingle(TestKShingleTransformer.segments)))
Пример #5
0
 def test_unishingle(self):
     expected = []
     t = KShingleTransformer(Sentinel(), k=1)
     self.assertListEqual(
         expected, list(t.k_shingle(TestKShingleTransformer.segments)))
Пример #6
0
 def test_setup(self):
     s = Sentinel()
     t = KShingleTransformer(s)
     self.assertEqual(s, t.rows)
     self.assertEqual(1, t.K)
     self.assertEqual(None, t.text_columns)