def test_basic_prefix_stripper(self):
     obj = RemovePrefix()
     #பேரின்பம் ->   இன்பம், 
     #u"":u"",u"":u"",u"":u"",u"":u"",u"":u"",u"":u"",
     prefix_removal_map = {u"எக்காலம்":u"காலம்",u"இக்காலம்":u"காலம்",u"அக்காலம்":u"காலம்",\
                         u"மாமனிதன்":u"மனிதன்",u"சின்னஜமீன்":u"ஜமீன்",u"அதிவேகம்":u"வேகம்",\
                         u"சிறுகுன்றம்":u"குன்றம்",u"மாமரம்":u"மரம்"}
     
     no_removal_map = {}
     # update no-prefix-to-be-removed / no-change values
     for v in prefix_removal_map.values():
         no_removal_map[v] = v
     
     # prefix removal does not happen for these words
     words_list = list(no_removal_map.keys())
     for idx,w in enumerate(words_list):
         rval = obj.removePrefix(w)
         self.assertFalse(rval[1])
         expected = no_removal_map[w]
         self.assertEqual(rval[0], expected)
     
     # prefix removal to happen as expected
     words_list = list(prefix_removal_map.keys())
     for idx,w in enumerate(words_list):
         rval = obj.removePrefix(w)
         self.assertTrue(rval[1])
         expected = prefix_removal_map[w]
         self.assertEqual(rval[0], expected)
     return
 def test_basic_prefix_stripper(self):
     obj = RemovePrefix()
     #பேரின்பம் ->   இன்பம், 
     #u"":u"",u"":u"",u"":u"",u"":u"",u"":u"",u"":u"",
     prefix_removal_map = {u"எக்காலம்":u"காலம்",u"இக்காலம்":u"காலம்",u"அக்காலம்":u"காலம்",\
                         u"மாமனிதன்":u"மனிதன்",u"சின்னஜமீன்":u"ஜமீன்",u"அதிவேகம்":u"வேகம்",\
                         u"சிறுகுன்றம்":u"குன்றம்",u"மாமரம்":u"மரம்"}
     
     no_removal_map = {}
     # update no-prefix-to-be-removed / no-change values
     for v in prefix_removal_map.values():
         no_removal_map[v] = v
     
     # prefix removal does not happen for these words
     words_list = list(no_removal_map.keys())
     for idx,w in enumerate(words_list):
         rval = obj.removePrefix(w)
         self.assertFalse(rval[1])
         expected = no_removal_map[w]
         self.assertEqual(rval[0], expected)
     
     # prefix removal to happen as expected
     words_list = list(prefix_removal_map.keys())
     for idx,w in enumerate(words_list):
         rval = obj.removePrefix(w)
         self.assertTrue(rval[1])
         expected = prefix_removal_map[w]
         self.assertEqual(rval[0], expected)
     return
Ejemplo n.º 3
0
    def __init__(self, filename=None, lang="ta", mode="non-web"):
        object.__init__(self)
        self.lang = lang.lower()
        self.filename = filename
        self.user_dict = set()
        self.case_filter = CaseFilter(RemovePluralSuffix(),
                                      RemoveVerbSuffixTense(),
                                      RemoveCaseSuffix(), RemovePrefix())
        if self.lang == u"en":
            self.alphabets = [a for a in string.ascii_lowercase]
        else:
            self.alphabets = None

        if mode != "web":
            if not self.filename:
                self.interactive()
            else:
                self.spellcheck(self.filename)
        pass