示例#1
0
 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."))
示例#2
0
 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 .")
示例#3
0
 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)