class SpellTestTamil(unittest.TestCase): def setUp(self): self.speller = Speller(lang=u"TA", mode="web") def test_words_in_dictionary(self): # test if all the words are in the dictionary for w in [ u"சவால்", u"மகதம்", u"ஆரதம்", u"பல்லவன்", u"பாதம்", u"கவணம்", u"செயல்" ]: ok, _ = self.speller.check_word_and_suggest(w) self.assertTrue(ok, w) return def test_words_in_error(self): # test if the words in error are flagged # further test if suggestion contains the right word debug = False words_and_fixes = {u"எந்திர": u"எந்திரம்", u"செயல்பட": u"செயல்"} for w, right_word in words_and_fixes.items(): notok, suggs = self.speller.check_word_and_suggest(w) if (debug): pprint(notok) pprint(suggs) self.assertFalse(notok, w) self.assertTrue(right_word in suggs, u"%s -> (%s)" % (right_word, u", ".join(suggs))) return
class SpellTestTamil(unittest.TestCase): def setUp(self): self.speller = Speller(lang=u"TA",mode="web") def test_words_in_dictionary(self): # test if all the words are in the dictionary for w in [u"சவால்",u"மகதம்",u"ஆரதம்", u"பல்லவன்",u"பாதம்",u"கவணம்", u"செயல்"]: ok,_ = self.speller.check_word_and_suggest(w) self.assertTrue( ok, w ) return def test_words_in_error(self): # test if the words in error are flagged # further test if suggestion contains the right word debug = False words_and_fixes = { u"எந்திர" : u"எந்திரம்", u"செயல்பட":u"செயல்"} for w,right_word in words_and_fixes.items(): notok,suggs = self.speller.check_word_and_suggest( w ) if ( debug ): pprint(notok) pprint(suggs) self.assertFalse( notok, w ) self.assertTrue( right_word in suggs, u"%s -> (%s)"%(right_word,u", ".join(suggs) )) return
def spell_check(request, k1): speller = Speller(lang="TA", mode="web") notok, suggs = speller.check_word_and_suggest(k1) json_string = json.dumps(suggs, ensure_ascii=False) # creating a Response object to set the content type and the encoding response = HttpResponse(json_string, content_type="application/json; charset=utf-8") return response
def spell_check(request,k1): speller = Speller(lang=u"TA",mode="web") notok,suggs = speller.check_word_and_suggest( k1 ) json_string = json.dumps(suggs,ensure_ascii = False) #creating a Response object to set the content type and the encoding response = HttpResponse(json_string,content_type="application/json; charset=utf-8" ) return response