Exemplo n.º 1
0
    def test_calculate_text_plagiarism_score_incorrect_threshold(self):
        """
        Tests that calculate_text_plagiarism_score function
            can handle incorrect threshold input
        """
        patches_texts = (('the', 'cat', 'left'),
                         ('the', 'dog', 'disappeared'))
        bad_inputs = [[], {}, '', -1, -6.34, -6, 1.2, None, True, (None, None)]

        expected = -1
        for bad_input in bad_inputs:
            actual = calculate_text_plagiarism_score(patches_texts,
                                                     patches_texts,
                                                     bad_input)
            self.assertEqual(expected, actual)
Exemplo n.º 2
0
    def test_calculate_text_plagiarism_score_check_threshold(self):
        """
        Tests that calculate_text_plagiarism_score function
            can preprocess given threshold correctly
        """
        original_text_tokens = (('the', 'cat', 'appeared'),
                                ('the', 'dog', 'disappeared'), (), ())
        suspicious_text_tokens = ((), ('the', 'girl', 'arrived'),
                                  ('the', 'boy', 'left'))
        plagiarism_threshold = 0.3

        expected = (0 + 1 / 3 + 0) / 3
        actual = calculate_text_plagiarism_score(original_text_tokens,
                                                 suspicious_text_tokens,
                                                 plagiarism_threshold)
        self.assertEqual(expected, actual)
Exemplo n.º 3
0
    def test_calculate_text_plagiarism_score_bigger_second_text(self):
        """
        Tests that calculate_text_plagiarism_score function
            can handle bigger second texts inputs
        """
        original_text_tokens = ((), ('the', 'girl', 'arrived'), ('the', 'boy',
                                                                 'left'))
        suspicious_text_tokens = (('the', 'cat', 'appeared'),
                                  ('the', 'dog', 'disappeared'), (), ())
        plagiarism_threshold = 0.3
        expected = (0 + 1 / 3 + 0 + 0) / 4

        actual = calculate_text_plagiarism_score(original_text_tokens,
                                                 suspicious_text_tokens,
                                                 plagiarism_threshold)
        self.assertEqual(expected, actual)
Exemplo n.º 4
0
    def test_calculate_text_plagiarism_score_bigger_first_text_complex(self):
        """
        Tests that calculate_text_plagiarism_score function
            can handle different first text lengths complex inputs
        """
        original_text_tokens = (('the', 'cat', 'appeared'),
                                ('the', 'dog', 'disappeared'), (), ())
        suspicious_text_tokens = ((), ('the', 'girl', 'arrived'),
                                  ('the', 'boy', 'left'))
        plagiarism_threshold = 0.3

        expected = (0 + 1 / 3 + 0) / 3
        actual = calculate_text_plagiarism_score(original_text_tokens,
                                                 suspicious_text_tokens,
                                                 plagiarism_threshold)
        self.assertEqual(expected, actual)
Exemplo n.º 5
0
    def test_calculate_text_plagiarism_score_ideal(self):
        """
        Tests that calculate_text_plagiarism_score function
            can handle simple ideal input case
        """
        original_text_tokens = (('the', 'cat', 'appeared'), ('the', 'dog',
                                                             'disappeared'))
        suspicious_text_tokens = (('the', 'man', 'arrived'), ('the', 'boy',
                                                              'left'))
        plagiarism_threshold = 0.3

        expected = (1 / 3 + 1 / 3) / 2
        actual = calculate_text_plagiarism_score(original_text_tokens,
                                                 suspicious_text_tokens,
                                                 plagiarism_threshold)
        self.assertEqual(expected, actual)
Exemplo n.º 6
0
    def test_calculate_text_plagiarism_score_check_output(self):
        """
        Tests that calculate_text_plagiarism_score function
            can generate correct output according to given specs
        """
        original_text_tokens = (('the', 'cat', 'appeared'),
                                ('the', 'dog', 'disappeared'))
        suspicious_text_tokens = (('the', 'man', 'arrived'),
                                  ('the', 'boy', 'left'))
        plagiarism_threshold = 0.3

        expected = float
        actual = type(calculate_text_plagiarism_score(original_text_tokens,
                                                      suspicious_text_tokens,
                                                      plagiarism_threshold))
        self.assertTrue(expected, actual)