From aba0993c3f6827d1b15c834aa1b3a5c02d1e1ee8 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Sun, 18 Jan 2009 12:39:04 +0530 Subject: Fixed the word2ASCII bugs, and adding a testcase --- payyans/payyans/payyan.py | 13 +++++++------ payyans/tests/test.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 payyans/tests/test.py (limited to 'payyans') diff --git a/payyans/payyans/payyan.py b/payyans/payyans/payyan.py index 185ccde..3a50f0e 100755 --- a/payyans/payyans/payyan.py +++ b/payyans/payyans/payyan.py @@ -69,15 +69,18 @@ class Payyan: index = index+charNo break else: + if(charNo==1): + index=index+1 + ascii_text = ascii_text + letter + break; '''നോക്കിയിട്ടു കിട്ടുന്നില്ല ബായി''' ascii_letter = letter - ascii_text = ascii_text + ascii_letter - index = index + 1 + #ascii_text = ascii_text + ascii_letter + #index = index+1 + return ascii_text def Uni2Ascii(self): - #self.direction="u2a" - #self.rulesDict = self.LoadRules() '''പണിതുടങ്ങട്ടെ''' if self.input_filename : uni_file = codecs.open(self.input_filename, encoding = 'utf-8', errors = 'ignore') @@ -126,8 +129,6 @@ class Payyan: return unicode_text # മതം മാറ്റി തിരിച്ചു കൊടുക്ക്വാ ! def Ascii2Uni(self): - #self.direction="a2u" - #self.rulesDict = self.LoadRules() if self.pdf : command = "pdftotext '" + self.input_filename +"'" process = os.popen(command, 'r') diff --git a/payyans/tests/test.py b/payyans/tests/test.py new file mode 100644 index 0000000..3791df5 --- /dev/null +++ b/payyans/tests/test.py @@ -0,0 +1,11 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +from payyans import Payyan +p=Payyan() +p.mapping_filename="/usr/share/payyans/maps/karthika.map" +print p.word2Unicode(u"hmÀjnI").encode('utf-8') +print p.word2ASCII(u"വാര്‍ഷിക").encode('utf-8') +print p.word2ASCII(u"ആന വായിലമ്പാഴങ്ങ?").encode('utf-8') +print p.word2Unicode(u"B\ hmbne¼mg§?").encode('utf-8') +print p.word2ASCII(u"മോരു തരുമോ!").encode('utf-8') +print p.word2Unicode(u"tamcp Xcptam!").encode('utf-8') -- cgit