Ejemplo n.º 1
0
class TestSentencesStatistics(BaseTest):
    """Tests for the class SentencesStatistics."""
    def setUp(self):
        """Create a list for use in all test methods."""
        file_name = self.get_file_path("sentences_test.txt")
        self.flg = SentencesStatistics(file_name)

    def test_generate_list_of_word_lengths(self):
        """Compare words from a file with a list generated."""
        self.assertListEqual([5, 9, 9, 5, 5, 6, 6, 8, 9, 9, 5, 5, 9],
                             self.flg.list_of_word_lengths())

    def test_number_of_sentences(self):
        """Compare the value of mean."""
        self.assertEqual(13, self.flg.number_of_sentences())

    def test_mean_sentence(self):
        """Compare the value of mean."""
        self.assertEqual(7, self.flg.mean_sentence())

    def test_median_sentence(self):
        """Compare the value of median."""
        self.assertEqual(6.0, self.flg.median_sentence())

    def test_min_sentence(self):
        """Compare the value of min."""
        self.assertEqual(5, self.flg.min_sentence())

    def test_max_sentence(self):
        """Compare the value of max."""
        self.assertEqual(9, self.flg.max_sentence())
Ejemplo n.º 2
0
 def comma(self):
     cp = CountPunctuations(self.file).count_comma()
     mean_cp = (cp / SentencesStatistics(self.file).number_of_sentences()) * 100
     return mean_cp
Ejemplo n.º 3
0
 def question_mark(self):
     cp = CountPunctuations(self.file).count_question_mark()
     mean_cp = (cp / SentencesStatistics(self.file).number_of_sentences()) * 100
     return mean_cp
Ejemplo n.º 4
0
 def median_sentences(self):
     return SentencesStatistics(self.file).median_sentence()
Ejemplo n.º 5
0
 def average_sentences(self):
     return SentencesStatistics(self.file).mean_sentence()
Ejemplo n.º 6
0
 def number_of_sentences(self):
     return SentencesStatistics(self.file).number_of_sentences()
Ejemplo n.º 7
0
 def setUp(self):
     """Create a list for use in all test methods."""
     file_name = self.get_file_path("sentences_test.txt")
     self.flg = SentencesStatistics(file_name)