Demo entry 6870016

open-tamil Mayangoli class


Submitted by anonymous on Aug 21, 2019 at 09:57
Language: Python. Code size: 2.6 kB.

class Mayangoli:
    varisai = [[ u"ல்", u"ழ்",u"ள்"],[u"ர்", u"ற்"],[u"ந்",u"ன்",u"ண்"],[u"ங்",u"ஞ்"]]#வரிசை.

    def __init__(self,word,letters):
        self.word = word
        if word != u"".join(letters):
            letters = tamil.utf8.get_letters(word)
        self.letters = letters
        self.matches_and_positions = []
        self.alternates = []
        self.pos_classes = []

    def run(word,letters):
        obj = Mayangoli(word,letters)
        if len(obj.matches_and_positions) == 0:
            return []
        return obj.alternates

    def find_letter_positions(self):
        for idx,letter in enumerate(self.letters):
            p = tamil.utf8.splitMeiUyir(letter)
            if len(p) == 1:
            for r in range(0,len(Mayangoli.varisai)):
                for c in range(0,len(Mayangoli.varisai[r])):
                    if mei == Mayangoli.varisai[r][c]:
        return len(self.matches_and_positions) > 0

    def find_correspondents(self):
        for pos,r,c in self.matches_and_positions:
            src_letter  = self.letters[pos]
            _,src_uyir = tamil.utf8.splitMeiUyir(src_letter)
            alt_letters = list()
            for alternate_mei in Mayangoli.varisai[r]:
                alt_letters.append( tamil.utf8.joinMeiUyir(alternate_mei,src_uyir) )
        return True

    def _generate_combinations(self):
        return itertools.product(*self.pos_classes)

    def generate_word_alternates(self):
        # find matches in Mayangoli classes
        # if there are no Mayangoli matches then we return []
        # for each match we find the class and find corresponding uyirmei alternates
        # generate the combinations of these alternates in the said word positions
        # caller will filter the new word alternates (returned)
        # based on substituting these correspondents
        for position_sub in self._generate_combinations():
            alt_letters = copy.copy(self.letters)
            if _DEBUG: pprint.pprint(position_sub)
            idx =0
            for pos,r,c in self.matches_and_positions:
                alt_letters[pos] = position_sub[idx]
                idx += 1
            word_alt = u''.join(alt_letters)
        return True

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).