From c5368252e3091368ae55475757ed3134d6f84249 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Sun, 29 Mar 2009 17:59:40 +0530 Subject: new modules --- silpa/modules/syllabalizer/syllabalizer.py | 46 ++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'silpa/modules/syllabalizer/syllabalizer.py') diff --git a/silpa/modules/syllabalizer/syllabalizer.py b/silpa/modules/syllabalizer/syllabalizer.py index deed058..5cfde82 100644 --- a/silpa/modules/syllabalizer/syllabalizer.py +++ b/silpa/modules/syllabalizer/syllabalizer.py @@ -25,8 +25,8 @@ along with this program. If not, see . import sys import re import codecs -from langdetect import LangDetect -class Syllabalizer: +from common import * +class Syllabalizer(SilpaModule): def syllabalize_ml(self,text): signs = [ u'\u0d02', u'\u0d03', u'\u0d3e', u'\u0d3f', u'\u0d40', u'\u0d41', @@ -133,10 +133,44 @@ class Syllabalizer: # Return the words splitted return text - + def process(self, form): + response = """ +

Syllabalizer

+

Enter the text for syllabalization in the below text area. + Language of each word will be detected. + You can give the text in any language and even with mixed language +

+
+ + + +
+
+ """ + if(form.has_key('input_text')): + text = form['input_text'].value.decode('utf-8') + response=response % text + words = text.split(" ") + response = response+"

Syllabalization Results

" + for word in words: + syllables = self.syllabalize(word) + syll_result="" + for syllable in syllables: + syll_result=syll_result+syllable + "-" + result = syll_result.replace('\n', '
') + response = response+result + else: + response=response % "" + return response + def get_module_name(self): + return "Syllabalizer" + def get_info(self): + return "Syllabalize each word in the given text" + def syllabalize(self,text): - ld=LangDetect() - lang=ld.detect_lang(text) + mm=ModuleManager() + ld = mm.getModuleInstance("Detect Language") + lang=ld.detect_lang(text)[text] if(lang=="ml_IN"): return self.syllabalize_ml(text) if(lang=="hi_IN"): @@ -147,3 +181,5 @@ class Syllabalizer: for char in text: lst_chars.append(char) return lst_chars +def getInstance(): + return Syllabalizer() -- cgit