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)])
def test_lemma(self): w = tb.Word("cars") assert_equal(w.lemma, "car") w = tb.Word("wolves") assert_equal(w.lemma, "wolf")
def test_correct(self): w = tb.Word('speling') correct = w.correct() assert_equal(correct, tb.Word('spelling')) assert_true(isinstance(correct, tb.Word))
def test_spellcheck(self): blob = tb.Word("speling") suggestions = blob.spellcheck() assert_equal(suggestions[0][0], "spelling")
def test_detect_language(self): assert_equal(tb.Word("bonjour").detect_language(), 'fr')
def test_translate_without_from_lang(self): assert_equal(tb.Word('hola').translate(), tb.Word('hello'))
def test_translate(self): assert_equal(tb.Word("cat").translate(to="es"), "gato")
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')
def setUp(self): self.cat = tb.Word('cat') self.cats = tb.Word('cats')