def test_explicit_end(self):
        text = "ababa"
        gst_obj = GST()
        gst_obj.add_text(text, 0)
        gst_obj.traverse(text)

        self.assertEqual(list(gst_obj.search('c')), [])
        self.assertEqual(list(gst_obj.search('aba')), [0])
Exemplo n.º 2
0
    def test_explicit_end(self):
        text = "ababa"
        gst_obj = GST()
        gst_obj.add_text(text, 0)
        gst_obj.traverse(text)

        self.assertEqual(list(gst_obj.search('c')), [])
        self.assertEqual(list(gst_obj.search('aba')), [0])
    def test_normal(self):
        text = 'abcabcd'
        gst_obj = GST()
        gst_obj.add_text(text, 0)
        gst_obj.traverse(text)

        self.assertEqual(list(gst_obj.search('c')), [0])
        self.assertEqual(list(gst_obj.search('abcd')), [0])
        self.assertEqual(list(gst_obj.search('abcc')), [])
Exemplo n.º 4
0
    def test_normal(self):
        text = 'abcabcd'
        gst_obj = GST()
        gst_obj.add_text(text, 0)
        gst_obj.traverse(text)

        self.assertEqual(list(gst_obj.search('c')), [0])
        self.assertEqual(list(gst_obj.search('abcd')), [0])
        self.assertEqual(list(gst_obj.search('abcc')), [])
    def test_implicit_end(self):
        text = "c_aa"
        gst_obj = GST()
        for index, t in enumerate(text.split('_')):
            gst_obj.add_text(t, index)
        gst_obj.traverse(text)

        self.assertEqual(list(gst_obj.search('c')), [0])
        self.assertEqual(list(gst_obj.search('ca')), [])
        self.assertEqual(list(gst_obj.search('aa')), [1])
        self.assertEqual(list(gst_obj.search('d')), [])
    def test_two_text(self):
        text = "abc_ccc"
        gst_obj = GST()
        for index, t in enumerate(text.split('_')):
            gst_obj.add_text(t, index)
        gst_obj.traverse(text)

        self.assertEqual(list(gst_obj.search('c')), [0, 1])
        self.assertEqual(list(gst_obj.search('cc')), [1])
        self.assertEqual(list(gst_obj.search('bc')), [0])
        self.assertEqual(list(gst_obj.search('d')), [])
Exemplo n.º 7
0
    def test_implicit_end(self):
        text = "c_aa"
        gst_obj = GST()
        for index, t in enumerate(text.split('_')):
            gst_obj.add_text(t, index)
        gst_obj.traverse(text)

        self.assertEqual(list(gst_obj.search('c')), [0])
        self.assertEqual(list(gst_obj.search('ca')), [])
        self.assertEqual(list(gst_obj.search('aa')), [1])
        self.assertEqual(list(gst_obj.search('d')), [])
Exemplo n.º 8
0
    def test_two_text(self):
        text = "abc_ccc"
        gst_obj = GST()
        for index, t in enumerate(text.split('_')):
            gst_obj.add_text(t, index)
        gst_obj.traverse(text)

        self.assertEqual(list(gst_obj.search('c')), [0, 1])
        self.assertEqual(list(gst_obj.search('cc')), [1])
        self.assertEqual(list(gst_obj.search('bc')), [0])
        self.assertEqual(list(gst_obj.search('d')), [])