Exemplo n.º 1
0
    def test_extract_sentences_regular(self):
        """
            Verify that extract_sentences can be correctly applied to strings with sentences whose only punctuation is at the end.
        """

        # Strings with one grammatically CORRECT sentence
        self.assertEqual(
            ParseTools.extract_sentences("Here is a declaritive sentence."),
            ["Here is a declaritive sentence."])
        self.assertEqual(
            ParseTools.extract_sentences("Is this an interrogative sentence?"),
            ["Is this an interrogative sentence?"])
        self.assertEqual(
            ParseTools.extract_sentences("This is an excalamtory sentence!"),
            ["This is an excalamtory sentence!"])

        # Strings with multiple grammatically CORRECT sentences
        self.assertEqual(
            ParseTools.extract_sentences(
                "This string has two sentences. Both of the sentences are grammatically correct."
            ), [
                "This string has two sentences.",
                "Both of the sentences are grammatically correct."
            ])

        # Strings with multiple grammatically INCORRECT sentences
        self.assertEqual(
            ParseTools.extract_sentences(
                "Sentences have this does two. Grammar not is."),
            ["Sentences have this does two.", "Grammar not is."])
Exemplo n.º 2
0
 def test_extract_sentences_twitter_words(self):
     """
         Verify behavior of extract_sentences when it enconters twitter words.
     """
     self.assertEqual(
         ParseTools.extract_sentences(
             "@TrumpPeeLannin I am there and and you can see the proof?"),
         ["@TrumpPeeLannin I am there and and you can see the proof?"])
     self.assertEqual(
         ParseTools.extract_sentences("@TheBearthen   Thanks!"),
         ["@TheBearthen   Thanks!"])
Exemplo n.º 3
0
 def test_extract_sentences_alternative_puncuation(self):
     """
         Verify that extract_sentences can be correctly applied to strings with sentences with embedded punctuation.
     """
     self.assertEqual(
         ParseTools.extract_sentences("Dr. Seuss was a good author."),
         ["Dr. Seuss was a good author."])
Exemplo n.º 4
0
    def test_extract_sentences_alt_punctuation(self):
        """
            Verify behavior of extract_sentences on strings with alternative punctuation.
        """
        self.assertEqual(ParseTools.extract_sentences("."), ["."])
        self.assertEqual(ParseTools.extract_sentences(".."), [".."])
        self.assertEqual(ParseTools.extract_sentences("..."), ["..."])
        self.assertEqual(ParseTools.extract_sentences("...."), ["...."])

        self.assertEqual(
            ParseTools.extract_sentences("This string has no punctuation"),
            ["This string has no punctuation"])
        self.assertEqual(
            ParseTools.extract_sentences(
                "This sentence has punctuation. This does not"),
            ["This sentence has punctuation.", "This does not"])
        self.assertEqual(
            ParseTools.extract_sentences(
                "This sentence ends in three dots... This does not."),
            ["This sentence ends in three dots...", "This does not."])
Exemplo n.º 5
0
 def test_extract_sentences_null_string(self):
     """
         Verify that extract_sentences can correctly indicate that a null string has no sentences.
     """
     self.assertEqual(ParseTools.extract_sentences(""), [])