Beispiel #1
0
 def test_spellcheck_special_cases(self):
     # Punctuation
     assert_equal(tb.Word("!").spellcheck(), [("!", 1.0)])
     # Numbers
     assert_equal(tb.Word("42").spellcheck(), [("42", 1.0)])
     assert_equal(tb.Word("12.34").spellcheck(), [("12.34", 1.0)])
     # One-letter words
     assert_equal(tb.Word("I").spellcheck(), [("I", 1.0)])
     assert_equal(tb.Word("A").spellcheck(), [("A", 1.0)])
     assert_equal(tb.Word("a").spellcheck(), [("a", 1.0)])
Beispiel #2
0
 def test_lemma(self):
     w = tb.Word("cars")
     assert_equal(w.lemma, "car")
     w = tb.Word("wolves")
     assert_equal(w.lemma, "wolf")
Beispiel #3
0
 def test_correct(self):
     w = tb.Word('speling')
     correct = w.correct()
     assert_equal(correct, tb.Word('spelling'))
     assert_true(isinstance(correct, tb.Word))
Beispiel #4
0
 def test_spellcheck(self):
     blob = tb.Word("speling")
     suggestions = blob.spellcheck()
     assert_equal(suggestions[0][0], "spelling")
Beispiel #5
0
 def test_detect_language(self):
     assert_equal(tb.Word("bonjour").detect_language(), 'fr')
Beispiel #6
0
 def test_translate_without_from_lang(self):
     assert_equal(tb.Word('hola').translate(), tb.Word('hello'))
Beispiel #7
0
 def test_translate(self):
     assert_equal(tb.Word("cat").translate(to="es"), "gato")
Beispiel #8
0
 def test_init(self):
     tb.Word("cat")
     assert_true(isinstance(self.cat, tb.Word))
     word = tb.Word('cat', 'NN')
     assert_equal(word.pos_tag, 'NN')
Beispiel #9
0
 def setUp(self):
     self.cat = tb.Word('cat')
     self.cats = tb.Word('cats')