Example #1
0
    def test_anagram_all_or_nothing(self):
        # all words are in dictionary..
        dictPred = wordutils.DictionaryWithPredicate(lambda x: True)
        self.assertTrue(dictPred.isWord('not a word but OK to slack off!'))

        res = [u'தமிழ்', u'தழ்மி', u'மிதழ்', u'மிழ்த', u'ழ்தமி', u'ழ்மித']
        self.assertEqual(list(wordutils.anagrams(u'தமிழ்', dictPred)), res)

        # none of words match
        negDictPred = wordutils.DictionaryWithPredicate(lambda x: False)
        self.assertEqual(list(wordutils.anagrams(res[0], negDictPred)), [])
Example #2
0
def anagram(request, word):
    AllTrueDictionary = wordutils.DictionaryWithPredicate(lambda x: True)
    TVU, TVU_size = DictionaryBuilder.create(TamilVU)
    length = len(utf8.get_letters(word))
    actual = list(wordutils.anagrams(word, TVU))
    json_string = json.dumps(actual, 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
Example #3
0
 def test_anagram_xception(self):
     mtObj = wordutils.DictionaryWithPredicate(False)
     with self.assertRaises(Exception):
         list(wordutils.anagrams(u'உபயொகிக்க!', mtObj))
 def setUp(self):
     self.AllTrueDictionary = wordutils.DictionaryWithPredicate(
         lambda x: True)
     self.TVU, self.TVU_size = DictionaryBuilder.create(TamilVU)
     self.word = u"சவால்"
     self.length = len(utf8.get_letters(self.word))