diff options
author | Santhosh Thottingal <santhosh.thottingal@gmail.com> | 2009-03-24 21:53:02 +0530 |
---|---|---|
committer | Santhosh Thottingal <santhosh.thottingal@gmail.com> | 2009-03-24 21:53:02 +0530 |
commit | 925ba08ecb3ff12496d343a1a0a99daf9a32ad3d (patch) | |
tree | 91aff87b0818e4e861a0ad2c6843d2286cb3775b /silpa/modules/payyans | |
parent | 886b09e5d997af17d1b0a9c7fad6e952a94bed45 (diff) | |
download | AnjaliOldLipi.git-925ba08ecb3ff12496d343a1a0a99daf9a32ad3d.tar.gz AnjaliOldLipi.git-925ba08ecb3ff12496d343a1a0a99daf9a32ad3d.tar.xz AnjaliOldLipi.git-925ba08ecb3ff12496d343a1a0a99daf9a32ad3d.zip |
Adding Silpa framework
Diffstat (limited to 'silpa/modules/payyans')
-rw-r--r-- | silpa/modules/payyans/maps/ambili.map | 191 | ||||
-rw-r--r-- | silpa/modules/payyans/maps/indulekha.map | 160 | ||||
-rw-r--r-- | silpa/modules/payyans/maps/karthika.map | 157 | ||||
-rw-r--r-- | silpa/modules/payyans/maps/revathi.map | 131 | ||||
-rw-r--r-- | silpa/modules/payyans/maps/template.map | 189 | ||||
-rw-r--r-- | silpa/modules/payyans/payyans.py | 275 |
6 files changed, 1103 insertions, 0 deletions
diff --git a/silpa/modules/payyans/maps/ambili.map b/silpa/modules/payyans/maps/ambili.map new file mode 100644 index 0000000..22fa9f0 --- /dev/null +++ b/silpa/modules/payyans/maps/ambili.map @@ -0,0 +1,191 @@ +#Ambili Font map for Payyans +#http://download.savannah.gnu.org/releases/smc/payyans +#Copyright 2009 Zyxware (www.zyxware.com) +#Copyright 2008 SMC (www.smc.org.in) +#Licensed under GPLv3 +#Contact smc-discuss@googlegroups.com for bug reports +w=ം +x=ഃ +A=അ +B=ആ +C=ഇ +Cu=ഈ +D=ഉ +Du=ഊ +E=ഋ +\p=ഌ +F=എ +G=ഏ +sF=ഐ +H=ഒ +Hm=ഓ +Hu=ഔ +I=ക +J=ഖ +K=ഗ +L=ഘ +M=ങ +N=ച +O=ഛ +P=ജ +Q=ഝ +R=ഞ +S=ട +T=ഠ +U=ഡ +V=ഢ +W=ണ +X=ത +Y=ഥ +Z=ദ +[=ധ +\=ന +]=പ +^=ഫ +_=ബ +`=ഭ +a=മ +b=യ +c=ര +d=റ +e=ല +f=ള +g=ഴ +h=വ +i=ശ +j=ഷ +k=സ +l=ഹ +m=ാ +n=ി +o=ീ +p=ു +q=ൂ +r=ൃ +s=െ +t=േ +ss=ൈ +sm=ൊ +tm=ോ +su=ൌ +v=് +u=ൗ +¡=ത്ഥ +¢=ക്ല +£=ക്ഷ +€=ഗ്ഗ +¥=ഗ്ല +Š=ങ്ക +§=ങ്ങ +š=ണ് +©=ഞ്ച +ª=ഞ്ഞ +«=ട്ട +¬=ല് +=ണ്ട +®=ച്ച +¯=സ്ഥ +°=ക്ക +±=ദ്ദ +²=ദ്ധ +³=ന് +Ž=ന്ത +µ=ന്ദ +¶=ങ്ക +·=ന്മ +ž=പ്പ +¹=പ്ലശ്ശ +º=മ്പ +»=ശ്ശ +Œ=മ്പ +œ=മ്മ +Ÿ=മ്ല +¿=ര് +À=ഹ്ല +Á=റ്റ +Â=ണ്ണ +Ã=സ്റ്റ +Ä=ള് +Å=ള്ള +Æ=ണ്ണ +Ç=ശ്ല +È=ശ്ശ +É=സ്ല +Ê=സ്സ +Ë=ഹ്ല +Ì=സ്റ്റ +Í=ഡ്ഡ +Î=ക്ട +Ï=ബ്ധ +Ð=ബ്ദ +Ñ=ച്ഛ +Ò=ഹ്മ +Ó=ഹ്ന +Ô=ന്ധ +Õ=ത്സ +Ö=ജ്ജ +×=ണ്മ +Ø=ത്ത +Ù=ന്ഥ +Ú=ജ്ഞ +Û=ത്ഭ +Ü=ഗ്മ +Ý=ശ്ച +Þ=ണ്ഡ +ß=ങ്ങ +à=ക്ത +á=ഗ്ന +â=ന്റ +ã=ഷ്ട +ä=റ്റ +å=ന് +ó=ന്ന +y=്യ +z=്വ +{=്ര +ð=ല് +ï=ണ്ട +ñ=ല്ല +ò=ന്മ +´=ട്ട +¸=പ്പ +¨=ണ് +¦=ങ്ക +¼=മ്പ +½=മ്മ +¤=ഗ്ഗ +ô=ഞ്ച +þ=- +∂=ന്ന +-= +≤=ദ്ധ +≥=ന് +ƒ=ള് +˛=- +Ω=മ്മ +‰=റ്റ +ÿ=സ്ഥ +›=ശ്ച +∞=ത്ഥ +≠=ണ്ട +‡=ക്ത +√=ല്ല +∏=പ്പ +≈=ള്ള +π=പ്ല +ø=യ്യ +fl=ത്മ +∑=ന്മ +÷=ജ്ജ +∆=വ്വ +™=ഞ്ഞ +—=ച്ഛ +‚=ന്റ +¥=ന്ത + =സ്സ +⁄=ജ്ഞ +•=ഗ്ല +’=ത്സ +‘=ന്ധ +...=സ്ല +“=ഹ്മ diff --git a/silpa/modules/payyans/maps/indulekha.map b/silpa/modules/payyans/maps/indulekha.map new file mode 100644 index 0000000..126031d --- /dev/null +++ b/silpa/modules/payyans/maps/indulekha.map @@ -0,0 +1,160 @@ +#Givetherulesinfollowingformat +w=ം +x=ഃ +A=അ +B=ആ +C=ഇ +Cu=ഈ +D=ഉ +Du=ഊ +E=ഋ +\p=ഌ +F=എ +G=ഏ +sF=ഐ +H=ഒ +Hm=ഓ +Hu=ഔ +I=ക +J=ഖ +K=ഗ +L=ഘ +M=ങ +N=ച +O=ഛ +P=ജ +Q=ഝ +R=ഞ +S=ട +T=ഠ +U=ഡ +V=ഢ +W=ണ +X=ത +Y=ഥ +Z=ദ +[=ധ +\=ന +]=പ +^=ഫ +_=ബ +`=ഭ +õ=ഭ +a=മ +b=യ +c=ര +d=ല +e=വ +f=ശ +g=ഷ +h=സ +i=ഹ +j=ള +k=ഴ +l=റ +m=് +n=ാ +o=ി +p=ീ +q=ു +r=ൂ +s=ൃ +t=െ +u=േ +ss=ൈ +sm=ൊ +tm=ോ +su=ൌ +v=ൌ +¡=ക്ക +¡=ക്ക +¢=ക്ല +£=ക്ഷ +€=ഗ്ഗ +¥=ദ്ദ +Š=ങ്ക +§=ങ്ങ +š=ച്ച +©=ഞ്ച +ª=ദ്ധ +«=ട്ട +¬=ണ് +=ണ്ട +®=ണ്ണ +¯=ത്ത +°=ന് +±=ര് +²=ല് +³=ള് +Ž=ന്ത +µ=ന്ദ +¶=ന്ന +·=ന്മ +ž=പ്പ +¹=ങ്ക +º=ങ്ങ +»=ച്ച +Œ=മ്പ +œ=മ്മ +Ÿ=മ്ല +¿=ത്ത +À=ന്ദ +Á=ന്ന +Â=ന്റ +Ã=പ്പ +Ä=മ്പ +Å=മ്മ +Æ=വ്വ +Ç=യ്യ +È=ല്ല +É=ള്ള +Ê=റ്റ +Ë=ഹ്ല +Ì=റ്റ +Í=ഡ്ഡ +Î=ക്ട +Ï=ബ്ധ +Ð=ന്ത +Ñ=ച്ഛ +Ò=ഹ്മ +Ó=ഹ്ന +Ô=ന്ധ +Õ=ഞ്ച +Ö=ജ്ജ +×=ണ്മ +Ø=സ്ഥ +Ù=സ്ഥ +Ú=ജ്ഞ +Û=ത്ഭ +Ü=ഗ്മ +Ý=ശ്ച +Þ=ണ്ഡ +ß=ത്മ +à=ക്ത +á=ഗ്ന +â=ന്റ +ã=ഷ്ട +ä=റ്റ +å=ന് +ó=ന്ന +y=്യ +z=്വ +{=്ര +}=്ര +ð=ല് +ï=ണ്ട +ñ=ല്ല +ò=ന്മ +´=ന്ത +¸=ക്ഷ +¨=ഓ +¦=ങ്ക +|=്വ +¼=ഞ്ഞ +½=ട്ട +¤=ഈ +ô=സ്സ +þ=- +¾=ണ്ട +î=ന്മ +$=സ്റ്റ diff --git a/silpa/modules/payyans/maps/karthika.map b/silpa/modules/payyans/maps/karthika.map new file mode 100644 index 0000000..c4e1765 --- /dev/null +++ b/silpa/modules/payyans/maps/karthika.map @@ -0,0 +1,157 @@ +#Givetherulesinfollowingformat +w=ം +x=ഃ +A=അ +B=ആ +C=ഇ +Cu=ഈ +D=ഉ +Du=ഊ +E=ഋ +\p=ഌ +F=എ +G=ഏ +sF=ഐ +H=ഒ +Hm=ഓ +Hu=ഔ +I=ക +J=ഖ +K=ഗ +L=ഘ +M=ങ +N=ച +O=ഛ +P=ജ +Q=ഝ +R=ഞ +S=ട +T=ഠ +U=ഡ +V=ഢ +W=ണ +X=ത +Y=ഥ +Z=ദ +[=ധ +\=ന +]=പ +^=ഫ +_=ബ +`=ഭ +a=മ +b=യ +c=ര +d=റ +e=ല +f=ള +g=ഴ +h=വ +i=ശ +j=ഷ +k=സ +l=ഹ +m=ാ +n=ി +o=ീ +p=ു +q=ൂ +r=ൃ +s=െ +t=േ +ss=ൈ +sm=ൊ +tm=ോ +su=ൌ +v=് +u=ൗ +¡=ക്ക +¡=ക്ക +¢=ക്ല +£=ക്ഷ +€=ഗ്ഗ +¥=ഗ്ല +Š=ങ്ക +§=ങ്ങ +š=ച്ച +©=ഞ്ച +ª=ഞ്ഞ +«=ട്ട +¬=ണ് +=ണ്ട +®=ണ്ണ +¯=ത്ത +°=ത്ഥ +±=ദ്ദ +²=ദ്ധ +³=ന് +Ž=ന്ത +µ=ന്ദ +¶=ന്ന +·=ന്മ +ž=പ്പ +¹=പ്ല +º=ബ്ബ +»=ബ്ല +Œ=മ്പ +œ=മ്മ +Ÿ=മ്ല +¿=യ്യ +À=ര് +Á=റ്റ +Â=ല് +Ã=ല്ല +Ä=ള് +Å=ള്ള +Æ=വ്വ +Ç=ശ്ല +È=ശ്ശ +É=സ്ല +Ê=സ്സ +Ë=ഹ്ല +Ì=സ്റ്റ +Í=ഡ്ഡ +Î=ക്ട +Ï=ബ്ധ +Ð=ബ്ദ +Ñ=ച്ഛ +Ò=ഹ്മ +Ó=ഹ്ന +Ô=ന്ധ +Õ=ത്സ +Ö=ജ്ജ +×=ണ്മ +Ø=സ്ഥ +Ù=ന്ഥ +Ú=ജ്ഞ +Û=ത്ഭ +Ü=ഗ്മ +Ý=ശ്ച +Þ=ണ്ഡ +ß=ത്മ +à=ക്ത +á=ഗ്ന +â=ന്റ +ã=ഷ്ട +ä=റ്റ +å=ന് +ó=ന്ന +y=്യ +z=്വ +{=്ര +##--fromhereaddedbynishan## +ð=ല് +ï=ണ്ട +ñ=ല്ല +ò=ന്മ +´=ന്ത +¸=പ്പ +¨=ച്ച +¦=ങ്ക +¼=മ്പ +½=മ്മ +¤=ഗ്ഗ +ô=ഞ്ച +þ=- +∂=ന്ന + diff --git a/silpa/modules/payyans/maps/revathi.map b/silpa/modules/payyans/maps/revathi.map new file mode 100644 index 0000000..76068de --- /dev/null +++ b/silpa/modules/payyans/maps/revathi.map @@ -0,0 +1,131 @@ +# ML-Revathi mapping to Unicode +# Givetherulesinfollowingformat +A=അ +B=ആ +C=ഇ +D=ഉ +E=ഋ +F=എ +G=ഏ +H=ഒ +I=ക +J=ഖ +K=ഗ +L=ഘ +M=ങ +N=ച +O=ഛ +P=ജ +Q=ഝ +R=ഞ +S=ട +T=ഠ +U=ഡ +V=ഢ +W=ണ +X=ത +Y=ഥ +Z=ദ +[=ധ +\=ന +]=പ +^=ഫ +_=ബ +`=ഭ +a=മ +b=യ +c=ര +d=റ +e=ല +f=ള +g=ഴ +h=വ +i=ശ +j=ഷ +k=സ +l=ഹ +m=ാ +n=ി +o=ീ +p=ു +q=ൂ +r=ൃ +s=െ +t=േ +u=ൗ +v=് +w=ം +x=ഃ +y=്യ +z=്വ +{=്ര +‚=ന്റ +ƒ=ള് +„=ഷ്ട +…=സ്ല +‡=ക്ത +‰=റ്റ +‹=ഗ്മ +Œ=ക്ട +o=ീ +™=ഞ്ഞ +›=ശ്ച +œ=ബ്ധ +Ÿ=ന്ഥ +¡=ററ +¢=ക്ല +£=ക്ഷ +¤=ത്ഭ +¥=ന്ത +§=ഗ്ഗ +¨=ണ് +©=ഞ്ച +ª=ബ്ല +«=ശ്ല +®=ച്ച +°=ക്ക +±=ദ്ദ +´=ട്ട +µ=ന്ദ +·=ഗ്ന +º=മ്പ +»=ശ്ശ +¿=ര് +À=ഹ്ല +Â=നു +Ã=സ്റ്റ +Æ=ണ്ണ +Õ=ഡ്ഡ +Ø=ത്ത +ß=ങ്ങ +æ=മ്ല +÷=ജ്ജ +ø=യ്യ +ÿ=സ്ഥ +ss=ൈ +sm=ൊ +tm=ോ +su=ൌ +’=ത്സ +∂=ന്ന +¬=ല് +¶=ങ്ക +Ω=മ്മ +Δ=വ്വ +π=പ്ല +∏=പ്പ +∑=ന്മ +∕=ജ്ഞ +√=ല്ല +∞=ത്ഥ +∫=ബ്ബ +≈=ള്ള +≠=ണ്ട +≤=ദ്ധ +≥=ന് +–=ബ്ദ +—=ച്ഛ +‘=ന്ധ +“=ഹ്മ +”=ഹ്ന +•=ഗ്ല diff --git a/silpa/modules/payyans/maps/template.map b/silpa/modules/payyans/maps/template.map new file mode 100644 index 0000000..dba911f --- /dev/null +++ b/silpa/modules/payyans/maps/template.map @@ -0,0 +1,189 @@ +! = ? +" = ? +# = ? +$ = ? +% = ? +& = ? +' = ? +( = ? +) = ? +* = ? ++ = ? +, = ? +- = ? +. = ? +/ = ? +0 = ? +1 = ? +2 = ? +3 = ? +4 = ? +5 = ? +6 = ? +7 = ? +8 = ? +9 = ? +: = ? +; = ? +< = ? += = ? +> = ? +? = ? +@ = ? +A = ? +B = ? +C = ? +D = ? +E = ? +F = ? +G = ? +H = ? +I = ? +J = ? +K = ? +L = ? +M = ? +N = ? +O = ? +P = ? +Q = ? +R = ? +S = ? +T = ? +U = ? +V = ? +W = ? +X = ? +Y = ? +Z = ? +[ = ? +\ = ? +] = ? +^ = ? +_ = ? +` = ? +a = ? +b = ? +c = ? +d = ? +e = ? +f = ? +g = ? +h = ? +i = ? +j = ? +k = ? +l = ? +m = ? +n = ? +o = ? +p = ? +q = ? +r = ? +s = ? +t = ? +u = ? +v = ? +w = ? +x = ? +y = ? +z = ? +{ = ? +| = ? +} = ? +~ = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? + = ? diff --git a/silpa/modules/payyans/payyans.py b/silpa/modules/payyans/payyans.py new file mode 100644 index 0000000..d1de143 --- /dev/null +++ b/silpa/modules/payyans/payyans.py @@ -0,0 +1,275 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- +# Payyans Ascii to Unicode Convertor +# Copyright 2008-2009 Santhosh Thottingal <santhosh.thottingal@gmail.com>, +# Nishan Naseer <nishan.naseer@gmail.com>, Manu S Madhav <manusmad@gmail.com>, +# Rajeesh K Nambiar <rajeeshknambiar@gmail.com> +# http://www.smc.org.in +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# If you find any bugs or have any suggestions email: santhosh.thottingal@gmail.com +# URL: http://www.smc.org.in + +''' +പയ്യന് ആളു തരികിടയാകുന്നു. ആസ്കി വേറൊരു തരികിടയും. +തരികിടയെ തരികിടകൊണ്ടു നേരിടുന്നതാണു് ബുദ്ധി. +അമേരിക്കാ-ഇറാഖ് യുദ്ധം താഴെപ്പറയും വിധമാകുന്നു. +''' + +'''ആവശ്യത്തിനുള്ള കോപ്പുകള് കൂട്ടുക ''' +import sys #കുന്തം +import codecs #കൊടച്ചക്രം +import os #ശീലക്കുട +from optparse import OptionParser #മുറുക്കാന്ചെല്ലം + +'''പയ്യന്റെ ക്ലാസ് ഉന്നതകുലമാകുന്നു. ച്ചാല് ആഢ്യന് തന്നെ. ഏ ക്ലാസ് പയ്യന്...!''' +class Payyans: + + def __init__(self): + self.input_filename ="" + self.output_filename="" + self.mapping_filename="" + self.rulesDict=None + self.pdf=0 + + def word2ASCII(self, unicode_text): + index = 0 + prebase_letter = "" + ascii_text="" + self.direction = "u2a" + self.rulesDict = self.LoadRules() + while index < len(unicode_text): + '''കൂട്ടക്ഷരങ്ങള്ക്കൊരു കുറുക്കുവഴി''' + for charNo in [3,2,1]: + letter = unicode_text[index:index+charNo] + if letter in self.rulesDict: + ascii_letter = self.rulesDict[letter] + letter = letter.encode('utf-8') + '''കിട്ടിയ അക്ഷരങ്ങളുടെ അപ്പുറത്തും ഇപ്പുറത്തും സ്വരചിഹ്നങ്ങള് ഫിറ്റ് ചെയ്യാനുള്ള ബദ്ധപ്പാട്''' + if letter == 'ൈ': # പിറകില് രണ്ടു സാധനം പിടിപ്പിക്കുക + ascii_text = ascii_text[:-1] + ascii_letter*2 + ascii_text[-1:] + elif (letter == 'ോ') | (letter == 'ൊ') | (letter == 'ൌ'): #മുമ്പിലൊന്നും പിറകിലൊന്നും + ascii_text = ascii_text[:-1] + ascii_letter[0] + ascii_text[-1:] + ascii_letter[1] + elif (letter == 'െ') | (letter == 'േ') |(letter == '്ര'): #പിറകിലൊന്നുമാത്രം + ascii_text = ascii_text[:-1] + ascii_letter + ascii_text[-1:] + else: + ascii_text = ascii_text + ascii_letter + 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 + + return ascii_text + + def Uni2Ascii(self): + '''പണിതുടങ്ങട്ടെ''' + if self.input_filename : + uni_file = codecs.open(self.input_filename, encoding = 'utf-8', errors = 'ignore') + else : + uni_file = codecs.open(sys.stdin, encoding = 'utf-8', errors = 'ignore') + text = "" + if self.output_filename : + output_file = codecs.open(self.output_filename, encoding = 'utf-8', errors = 'ignore', mode='w+') + while 1: + text =uni_file.readline() + if text == "": + break + ascii_text = "" + # ഹീന ജാതിയിലേയ്ക്ക് തരം താഴ്ത്ത്വാ ! + ascii_text = self.word2ASCII(text) + + if self.output_filename : + output_file.write(ascii_text) + else: + print ascii_text.encode('utf-8') + ''' പയ്യന് നല്ലോരു യൂണിക്കോട് ഫയലില് കേറി നെരങ്ങി ആസ്ക്കിയാക്കി. ദൈവമേ, ഈ പയ്യനു നല്ലബുദ്ധി തോന്നിക്കണേ... ''' + return 0 + + def word2Unicode(self, ascii_text): + index = 0 + post_index = 0 + prebase_letter = "" + postbase_letter = "" # "്യ", "്വ" + unicode_text = "" + next_ucode_letter = "" + self.direction="a2u" + self.rulesDict = self.LoadRules() + while index < len(ascii_text): + for charNo in [2,1]: + letter = ascii_text[index:index+charNo] + if letter in self.rulesDict: + unicode_letter = self.rulesDict[letter] + if(self.isPrebase(unicode_letter)): #സ്വരചിഹ്നമാണോ? + prebase_letter = unicode_letter + else: #സ്വരചിഹ്നമല്ല + #എങ്കില് വ്യഞ്ജനത്തിനു ശേഷം പോസ്റ്റ്-ബേസ് ഉണ്ടോ എന്നു നോക്കൂ + post_index = index+charNo + if post_index < len(ascii_text): + letter = ascii_text[post_index] + if letter in self.rulesDict: + next_ucode_letter = self.rulesDict[letter] + if self.isPostbase(next_ucode_letter): + postbase_letter = next_ucode_letter + index = index + 1 + if ((unicode_letter.encode('utf-8') == "എ") | + ( unicode_letter.encode('utf-8') == "ഒ" )): + unicode_text = unicode_text + postbase_letter + self.getVowelSign(prebase_letter , unicode_letter) + else: + unicode_text = unicode_text + unicode_letter + postbase_letter + prebase_letter + prebase_letter="" + postbase_letter="" + index = index + charNo + break + else: + if charNo == 1: + unicode_text = unicode_text + letter + index = index + 1 + break + unicode_letter = letter + return unicode_text # മതം മാറ്റി തിരിച്ചു കൊടുക്ക്വാ ! + + def Ascii2Uni(self): + if self.pdf : + command = "pdftotext '" + self.input_filename +"'" + process = os.popen(command, 'r') + status = process.close() + if status: + print "The input file is a PDF file. To convert this the pdftotext utility is required. " + print "This feature is available only for GNU/Linux Operating system." + '''ഊഹും. കൊന്നാലും ഇനി മുന്നോട്ടില്ല. മുന്നില് മറ്റവനാകുന്നു. ഏതു്? ''' + return 1 # Error - no pdftotext ! + else: + self.input_filename = os.path.splitext(self.input_filename)[0] + ".txt" + if self.input_filename : + ascii_file = codecs.open(self.input_filename, encoding = 'utf-8', errors = 'ignore') + else : + ascii_file = codecs.open(sys.stdin, encoding = 'utf-8', errors = 'ignore') + + text = "" + if self.output_filename : + output_file = codecs.open(self.output_filename, encoding = 'utf-8', errors = 'ignore', mode='w+') + + '''സത്യമുള്ളടത്തോളം... അതുകൊണ്ടു തന്നെ ടെര്മിനേഷന് ഉറപ്പു്''' + while 1: + text =ascii_file.readline() + if text == "": + break + unicode_text = "" + ''' അങ്ങട്ട് മതം മാറ്റ്വാ... ആസ്കിതനും നാസ്തികനും ഒന്നന്നെ! ''' + unicode_text = self.word2Unicode(text) + + if self.output_filename : + output_file.write(unicode_text) + else: + print unicode_text.encode('utf-8') + + ''' പയ്യന്റെ അവതാരോദ്ദേശ്യം പൂര്ണ്ണമായിരിക്കുന്നു. ഇനി മടക്കം. റിട്ടേണ്...! ''' + return 0 + + def getVowelSign(self, vowel_letter, vowel_sign_letter): + vowel= vowel_letter.encode('utf-8') + vowel_sign= vowel_sign_letter.encode('utf-8') + if vowel == "എ": + if vowel_sign == "െ": + return "ഐ" + if vowel == "ഒ": + if vowel_sign == "ാ": + return "ഓ" + if vowel_sign =="ൗ": + return "ഔ" + return (vowel_letter+ vowel_sign_letter) + + def isPrebase(self, letter): + ''' + ഇതെന്തിനാന്നു ചോദിച്ചാ, ഈ അക്ഷരങ്ങളുടെ ഇടതു വശത്തെഴുതുന്ന സ്വര ചിഹ്നങ്ങളുണ്ടല്ലോ? + അവ ആസ്കി തരികിടയില് എഴുതുന്നതു് ഇടതു വശത്തു തന്നെയാ. യൂണിക്കോഡില് അക്ഷരത്തിനു ശേഷവും + അപ്പൊ ആ വക സംഭവങ്ങളെ തിരിച്ചറിയാനാണു് ഈ സംഭവം. + "തരികിട തരികിടോ ധീംതരികിട" (തരികിട തരികിടയാല്) എന്നു പയ്യന്റെ ഗുരു പയ്യഗുരു പയ്യെ മൊഴിഞ്ഞിട്ടുണ്ടു്. + ''' + unicode_letter = letter.encode('utf-8') + if( ( unicode_letter == "േ" ) | ( unicode_letter == "ൈ" ) | ( unicode_letter == "ൊ" ) | ( unicode_letter == "ോ" ) | ( unicode_letter == "ൌ" ) + | ( unicode_letter == "്ര" ) | ( unicode_letter == "െ" ) + ): + return True #"ഇതു സത്യം... അ...സത്യം.... അസത്യം...!" + else: + return False + + def isPostbase(self, letter): + ''' + "ക്യ" എന്നതിലെ "്യ", "ക്വ" എന്നതിലെ "്വ" എന്നിവ പോസ്റ്റ്-ബേസ് ആണ്. + "ത്യേ" എന്നത് ആസ്കിയില് "ഏ+ത+്യ" എന്നാണ് എഴുതുന്നത്. അപ്പോള് വ്യഞ്ജനം കഴിഞ്ഞ് പോസ്റ്റ്-ബേസ് + ഉണ്ടെങ്കില് വ്യഞ്ജനം+പോസ്റ്റ്-ബേസ് കഴിഞ്ഞേ പ്രീ-ബേസ് ചേര്ക്കാവൂ! ഹൊ, പയ്യന് പാണിനീശിഷ്യനാണ്!! + ''' + unicode_letter = letter.encode('utf-8') + if ( (unicode_letter == "്യ") | (unicode_letter == "്വ") ): + return True + else: + return False + + def LoadRules(self): + ''' + ഈ സംഭവമാണു് മാപ്പിങ്ങ് ഫയല് എടുത്തു് വായിച്ചു പഠിക്കുന്നതു്. + ''' + if(self.rulesDict): + return self.rulesDict + rules_dict = dict() + line = [] + line_number = 0 + rules_file = codecs. open(self.mapping_filename,encoding='utf-8', errors='ignore') + while 1: + ''' ലൈന് നമ്പര് , മാപ്പിങ്ങ് ഫയലില് തെറ്റുണ്ടെങ്കില് പറയാന് ആവശ്യാണു് ''' + line_number = line_number +1 + text = unicode( rules_file.readline()) + if text == "": + break + '''കമന്റടിച്ചേ മത്യാവൂന്നു വെച്ചാ ആവാം. ഒട്ടും മുഷിയില്ല്യ''' + if text[0] == '#': + continue + ''' കമന്റടി പതിവുപോലെ മൈന്റ് ചെയ്യണ്ട ഒന്നും കണ്ടില്യാ കേട്ടില്യാന്നു വെച്ചു നടന്നോളൂ(മനസ്സില് ചിരിച്ചോളൂ) ''' + line = text.strip() + if(line == ""): + continue + '''ലൈനൊന്നും ല്യാ, മോശം.. ങും പോട്ടെ. വേറെ ലൈന് പിടിക്കാം''' + if(len(line.split("=")) != 2): + '''എന്തോ പ്രശ്നണ്ടു്. ന്നാ അതങ്ങടു തുറന്നു പറഞ്ഞേക്കാം''' + print "Error: Syntax Error in the Ascii to Unicode Map in line number ", line_number + print "Line: "+ text + '''പരിപാടി നിര്ത്താം ''' + return 2 # Error - Syntax error in Mapping file + '''ഇടതന്''' + lhs = line.split("=") [ 0 ] + '''വലതന്''' + rhs = line.split("=") [ 1 ] + '''ഇതിനിടക്കിനി മൂന്നാമനു സ്കോപ്പിണ്ടോ? ''' + '''മറക്കാതെ ഇരിക്കട്ടെ. ആവശ്യം വരും ''' + if self.direction == 'a2u': + rules_dict[lhs]=rhs + else: + rules_dict[rhs]=lhs + return rules_dict + + +if __name__ == "__main__": + '''ഒരു പയ്യന് അവതരിക്കുന്നു. ''' + rule= Payyan() + |