def test_correct(self): blob = tb.Sentence("Meinne Reschtschreibung ist schrrecklich.") assert_true(isinstance(blob.correct(), tb.Sentence)) assert_equal(blob.correct(), tb.Sentence("Meine Rechtschreibung ist schrecklich.")) blob = tb.Sentence("Meinne Reschtschreibung \nist guut.") assert_true(isinstance(blob.correct(), tb.Sentence)) assert_equal(blob.correct(), tb.Sentence("Meine Rechtschreibung \nist gut."))
def test_translate(self): blob = tb.Sentence("Das ist ein Satz.") assert_true(isinstance(blob.tokenizer, NLTKPunktTokenizer)) translated = blob.translate(to="en") assert_true(isinstance(translated, tb.Sentence)) # For some languages punctuation gets separated for others # it does not (not entirely sure if this is Google or TextBlob) # Further tests needed. assert_equal(translated, "This is a sentence .")
def setUp(self): self.empty_sentence = tb.Sentence(" ") self.single_period = tb.Sentence(" .") self.single_comma = tb.Sentence(" ,") self.text_space_period = tb.Sentence("A .") self.single_exclamation_mark = tb.Sentence(" ! ") self.raw_sentence = \ 'Peter mag Restaurants, die belgisches Bier servieren.' self.sentence = tb.Sentence(self.raw_sentence)