Пример #1
0
 def checkFormErrors(word, errmsg=None):
     r1 = BadIME()
     r2 = AdjacentConsonants()
     r2.freq_threshold = 4
     r3 = AdjacentVowels()
     item0 = operator.itemgetter(0)
     if errmsg and r1.apply(word)[0]:
         errmsg.append(u"BadIME")
         print("Bad IME")
     return any(list(map(lambda obj: not item0(obj.apply(word)), [r1, r2, r3])))
Пример #2
0
 def checkFormErrors(word,errmsg=None):
     r1=BadIME()
     r2=AdjacentConsonants()
     r2.freq_threshold=4
     r3=AdjacentVowels()
     item0 = operator.itemgetter(0)
     if errmsg and r1.apply(word)[0]:
         errmsg.append(u"BadIME")
         print("Bad IME")
     return any(list(map(lambda obj: not item0(obj.apply(word)),[r1,r2,r3])))
 def test_all_valid(self):
     data,DEBUG = [],False
     with codecs.open("data/project_madurai_utf8.txt","r","utf-8") as f:
         data = filter(lambda x: len(x)>2, f.readlines())
     obj = BadIME()
     for idx,line in enumerate(data):
         for col,word in enumerate( re.split(u'\s+',line) ):
             if DEBUG: 
                 print(idx,col)
                 print(utf8.get_letters(word))
             self.assertEqual(obj.apply(word),(True,None))
         pass
     pass
Пример #4
0
 def test_all_valid(self):
     data, DEBUG = [], False
     with codecs.open("data/project_madurai_utf8.txt", "r", "utf-8") as f:
         data = filter(lambda x: len(x) > 2, f.readlines())
     obj = BadIME()
     for idx, line in enumerate(data):
         for col, word in enumerate(re.split(u'\s+', line)):
             if DEBUG:
                 print(idx, col)
                 print(utf8.get_letters(word))
             self.assertEqual(obj.apply(word), (True, None))
         pass
     pass
Пример #5
0
 def test_invalid_pulli_seq(self):
     not_a_word = u"ஆள்்ஆ"
     #from tamil import utf8
     #print(utf8.get_letters(not_a_word))
     obj = BadIME()
     self.assertEqual(obj.apply(not_a_word), (False, BadIME.reason))
Пример #6
0
 def test_valid_word_det(self):
     for a_word in [u"ஆள்", u"ஏனையோருக்கும்"]:
         obj = BadIME()
         #print(utf8.get_letters(a_word))
         self.assertEqual(obj.apply(a_word), (True, None))
     return
Пример #7
0
 def test_invalid_word3(self):
     obj = BadIME()
     not_a_word = u"தூூக்"
     self.assertEqual(obj.apply(not_a_word), (False, BadIME.reason))
     not_a_word = u"ஏூூளா"
     self.assertEqual(obj.apply(not_a_word), (False, BadIME.reason))
Пример #8
0
 def test_invalid_word_det(self):
     not_a_word = u"ஆாள்"
     #print(utf8.get_letters(not_a_word))
     obj = BadIME()
     self.assertEqual(obj.apply(not_a_word), (False, BadIME.reason))
 def test_invalid_pulli_seq(self):
     not_a_word = u"ஆள்்ஆ"
     #from tamil import utf8
     #print(utf8.get_letters(not_a_word))
     obj = BadIME()
     self.assertEqual( obj.apply(not_a_word), (False,BadIME.reason) )
 def test_valid_word_det(self):
     for a_word in [u"ஆள்",u"ஏனையோருக்கும்"]:
         obj = BadIME()
         #print(utf8.get_letters(a_word))
         self.assertEqual( obj.apply(a_word), (True,None) )
     return
 def test_invalid_word3(self):
     obj = BadIME()
     not_a_word = u"தூூக்"
     self.assertEqual( obj.apply(not_a_word),(False,BadIME.reason) )
     not_a_word = u"ஏூூளா"
     self.assertEqual( obj.apply(not_a_word),(False,BadIME.reason) )
 def test_invalid_word_det(self):
     not_a_word = u"ஆாள்"
     #print(utf8.get_letters(not_a_word))
     obj = BadIME()
     self.assertEqual( obj.apply(not_a_word),(False,BadIME.reason) )