Example #1
0
 def test_lemmatize(self):
     w = tb.Word("Autos")
     assert_equal(w.lemmatize(), "Auto")
     w = tb.Word("Wölfe")
     assert_equal(w.lemmatize(), "Wolf")
     w = tb.Word("ging")
     assert_equal(w.lemmatize("v"), "gehen")
Example #2
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)])
Example #3
0
 def test_correct(self):
     w = tb.Word('Reschtschreibung')
     correct = w.correct()
     assert_equal(correct, tb.Word('Rechtschreibung'))
     assert_true(isinstance(correct, tb.Word))
Example #4
0
 def test_spellcheck(self):
     blob = tb.Word("Reschtschreibung")
     suggestions = blob.spellcheck()
     assert_equal(suggestions[0][0], "Rechtschreibung")
Example #5
0
 def test_detect_language(self):
     assert_equal(tb.Word("Guten Tag").detect_language(), 'de')
Example #6
0
 def test_translate_without_from_lang(self):
     valid_translations = (tb.Word('Hallo'), tb.Word('hallo'),
                           tb.Word('Hallo zusammen'))
     assert_true(tb.Word('Hello').translate() in valid_translations)
Example #7
0
 def test_translate(self):
     assert_true(
         tb.Word("Katze").translate(from_lang="de", to="en") in
         ["cat", "Cat"])
Example #8
0
 def test_init(self):
     tb.Word("Katze")
     assert_true(isinstance(self.cat, tb.Word))
     word = tb.Word('Katze', 'NN')
     assert_equal(word.pos_tag, 'NN')
Example #9
0
 def setUp(self):
     self.cat = tb.Word('Katze')
     self.cats = tb.Word('Katzen')
Example #10
0
 def test_define(self):
     w = tb.Word("Gewinn")
     synsets = w.get_synsets(wn.NOUN)
     definitions = w.define(wn.NOUN)
     assert_true(len(definitions) > 0)
     assert_equal(len(synsets), len(definitions))
Example #11
0
 def test_definitions(self):
     w = tb.Word("Krake")
     assert_true(len(w.definitions) > 0)
     for definition in w.definitions:
         assert_true(isinstance(definition, basestring))
Example #12
0
 def test_synsets_with_pos_argument(self):
     w = tb.Word("Arbeit")
     noun_syns = w.get_synsets(pos=wn.NOUN)
     assert_true(len(noun_syns) > 0)
     for synset in noun_syns:
         assert_equal(synset.pos, wn.NOUN)
Example #13
0
 def test_synsets(self):
     w = tb.Word("Fahrrad")
     assert_true(isinstance(w.synsets, (list, tuple)))
     assert_true(isinstance(w.synsets[0], Synset))
Example #14
0
 def test_lemma(self):
     w = tb.Word("Häuser")
     assert_equal(w.lemma, "Haus")
     w = tb.Word("ging", "VBD")
     assert_equal(w.lemma, "gehen")
Example #15
0
 def test_translate(self):
     assert_equal(
         tb.Word("Katze").translate(from_lang="de", to="en"), "cat")