Beispiel #1
0
    def test_yields_correct_sentences_when_given_simple_paragraph(self):
        test_lines = ["This is a sentence. This is also a sentence. Look at all the sentences."]

        results = list(get_sentences_from_lines(test_lines))
        self.assertEqual(["This is a sentence", "This is also a sentence", "Look at all the sentences"], results)
Beispiel #2
0
    def test_yields_correct_sentences_when_line_is_empty(self):
        test_lines = [""]

        results = list(get_sentences_from_lines(test_lines))

        self.assertEqual([], results)
Beispiel #3
0
    def test_yields_correct_sentences_when_ends_in_non_period(self):
        test_lines = ["What? A sentence! Will it work?!"]

        results = list(get_sentences_from_lines(test_lines))

        self.assertEqual(["What", "A sentence", "Will it work"], results)
Beispiel #4
0
    def test_yields_correct_sentences_when_no_periods_on_several_line(self):
        test_lines = ["i", "am ", "a sentence", "with no punctuation"]

        results = list(get_sentences_from_lines(test_lines))

        self.assertEqual(["i am a sentence with no punctuation"], results)
Beispiel #5
0
    def test_yields_correct_sentences_when_no_trailing_word_spaces(self):
        test_lines = ["one", "two", "three."]

        results = list(get_sentences_from_lines(test_lines))

        self.assertEqual(["one two three"], results)
Beispiel #6
0
    def test_yields_correct_sentences_when_split_over_several_lines(self):
        test_lines = ["This is a sentence.", "This is ", "also a ", "sentence. Look at all the sentences."]

        results = list(get_sentences_from_lines(test_lines))

        self.assertEqual(["This is a sentence", "This is also a sentence", "Look at all the sentences"], results)