def test_corrections(self): TVU,_ = DictionaryBuilder.create(TamilVU) words = [u'இன்பம்', u'ஆப்பம்', u'இன்னம்', u'இன்பன்', u'அற்பம்', u'அப்பம்', u'அற்றம்', u'அற்கம்', u'அக்கம்', u'அட்டம்', u'அம்மம்', u'அற்பர்', u'அப்பன்', u'அப்பர்', u'அப்பல்', u'அம்பர்', u'அம்பல்', u'அன்னம்', u'அன்னன்', u'அன்னல்', u'அன்பன்'] actual = corrections(u'அன்பம்',TVU,ta_kbd_cm,ed=2) self.assertSequenceEqual( actual, words )
def test_corrections(self): TVU, _ = DictionaryBuilder.create(TamilVU) words = [ u"இன்பம்", u"ஆப்பம்", u"இன்னம்", u"இன்பன்", u"அற்பம்", u"அப்பம்", u"அற்றம்", u"அற்கம்", u"அக்கம்", u"அட்டம்", u"அம்மம்", u"அற்பர்", u"அப்பன்", u"அப்பர்", u"அப்பல்", u"அம்பர்", u"அம்பல்", u"அன்னம்", u"அன்னன்", u"அன்னல்", u"அன்பன்", ] actual = corrections(u"அன்பம்", TVU, ta_kbd_cm, ed=2) self.assertSequenceEqual(actual, words)
def test_corrections(self): TVU, _ = DictionaryBuilder.create(TamilVU) words = [ u'இன்பம்', u'ஆப்பம்', u'இன்னம்', u'இன்பன்', u'அற்பம்', u'அப்பம்', u'அற்றம்', u'அற்கம்', u'அக்கம்', u'அட்டம்', u'அம்மம்', u'அற்பர்', u'அப்பன்', u'அப்பர்', u'அப்பல்', u'அம்பர்', u'அம்பல்', u'அன்னம்', u'அன்னன்', u'அன்னல்', u'அன்பன்' ] actual = corrections(u'அன்பம்', TVU, ta_kbd_cm, ed=2) self.assertSequenceEqual(actual, words)
def get_english_dictionary(): LoadDictionary.lock.acquire() if not Speller.ENL_dict: Speller.ENL_dict, _ = DictionaryBuilder.create(EnglishLinux) LoadDictionary.lock.release() return Speller.ENL_dict
def get_dictionary(): LoadDictionary.lock.acquire() if not Speller.TVU_dict: Speller.TVU_dict, _ = DictionaryBuilder.create(TamilVU) LoadDictionary.lock.release() return Speller.TVU_dict
# -*- coding: utf-8 -*- ## (C) 2019 Muthiah Annamalai, ## This module is part of solthiruthi project under open-tamil umbrella. ## This code maybe used/distributed under MIT LICENSE. from solthiruthi.dictionary import DictionaryBuilder, TamilVU from solthiruthi.qwertykbd import confusion_matrix as en_kbd_cm from solthiruthi.tamil99kbd import inv_confusion_matrix as kbd_cm from solthiruthi.typographical import oridam_generate_patterns, corrections TVU, _ = DictionaryBuilder.create(TamilVU) def checkpat(word_in, check_words, kbd=en_kbd_cm): pat = oridam_generate_patterns(word_in, kbd, ed=len(word_in)) pat = ["".join(p) for p in pat] print("Total = %d" % (len(pat))) print("Total set = %d" % len(set(pat))) for word in check_words: print('%s ->' % word, word in pat) for p in pat: print(p) #checkpat(list('arg'),['art','arg']) #checkpat(get_letters(u'பவளம்'),[u'பவகல்',u'கவளம்'],kbd_cm) #checkpat(get_letters(u'அன்பம்'),[u'இன்பம்'],kbd_cm) wl = corrections('அன்பம்', TVU, kbd_cm, ed=2) for c in wl: print(("u'%s'," % c)) print(("L = %d" % len(wl)))