Demo entry 6870017

open-tamil conjoined letter split

   

Submitted by anonymous on Aug 21, 2019 at 10:02
Language: Python. Code size: 1.4 kB.

class OttruSplit:
    """ யாரிகழ்ந்து = [ய்  + ஆரிகழ்ந்து], [யார், இகழ்ந்து] ,[யாரிக், அழ்ந்து], [யாரிகழ்ந்த்,உ]"""
    def __init__(self,word,letters):
        self.word = word
        if word != u"".join(letters):
            letters = tamil.utf8.get_letters(word)
        self.letters = letters
        self.results = list()

    def run(self,lexicon):
        self.generate_splits()
        return self.filter(lexicon)

    def generate_splits(self):
        """
            யாரிகழ்ந்து =
                [['ய்', 'ஆரிகழ்ந்து'],
                 ['யார்', 'இகழ்ந்து'],
                 ['யாரிக்', 'அழ்ந்து'],
                 ['யாரிகழ்ந்த்', 'உ']]
        """
        L = len(self.letters)-1
        for idx,letter in enumerate(self.letters):
            if not( letter in tamil.utf8.grantha_uyirmei_letters):
                continue
            muthal = idx == 0 and u"" or u"".join(self.letters[0:idx])
            meethi = idx == L and u"" or u"".join(self.letters[idx+1:])
            mei,uyir = tamil.utf8.splitMeiUyir(letter)
            muthal = muthal + mei
            meethi = uyir + meethi
            self.results.append([muthal,meethi])
        return len(self.results) > 0

    def filter(self,lexicon):
        self.results = list( filter(lambda x: all( map(lexicon.isWord,x) ),self.results) )
        return self.results

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).