Example #1
0
    def test_replace_single_char_with_single_char(self):
        text = "1.12.1"
        scores = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4]

        ss = ScoreString(text, scores)
        replaced_ss = ss.replace(".", "a")
        self.assertEqual(len(replaced_ss.scores), len(replaced_ss.data))
        self.assertEqual(replaced_ss.scores, [0.9, 0.8, 0.7, 0.6, 0.5, 0.4])
        self.assertEqual(replaced_ss.data, "1a12a1")
Example #2
0
    def test_replace_multi_char_with_multi_char_thresh_filter(self):
        text = "1.12..1"
        scores = [0.9, 0.8, 0.7, 0.6, 0.5, 0.1, 0.4]

        ss = ScoreString(text, scores)
        replaced_ss = ss.replace("..", "aaa", thresh=0.6)
        self.assertEqual(len(replaced_ss.scores), len(replaced_ss.data))
        self.assertEqual(replaced_ss.data, "1.12aaa1")
        self.assertEqual(replaced_ss.scores,
                         [0.9, 0.8, 0.7, 0.6, 0.5, 0.1, 0.3, 0.4])