/usr/share/texmf-texlive/scripts/bengali/ebong.py is in texlive-lang-indic 2009-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | #!/usr/bin/env python
# look in newbong
import sre
A='A'
B='B'
S='S'
s='s'
F='F'
X='X'
NCLINE = 0
global NCWORD,CWORD
AKSAR={
'k' :[B,'k'],
'kh' :[B,'kh'],
'g' :[B,'g'],
'gh' :[B,'gh'],
'ng' :[B,'NG'],
'ch' :[B,'c'],
'^ch' :[B,'ch'],
'j' :[B,'j'],
'jh' :[B,'jh'],
'^y' :[B,'NJ'],
'_n' :[B,'NJ'],
't' :[B,'T'],
'^th' :[B,'Th'],
'd' :[B,'D'],
'dh' :[B,'Dh'],
'^n' :[B,'N'],
'_t' :[B,'t'],
'th' :[B,'th'],
'_d' :[B,'d'],
'_dh' :[B,'dh'],
'n' :[B,'n'],
'p' :[B,'p'],
'ph' :[B,'ph'],
'f' :[B,'ph'],
'b' :[B,'b'],
'bh' :[B,'bh'],
'v' :[B,'bh'],
'm' :[B,'m'],
'M' :[F,'M'],
'^j' :[B,'J'],
'J' :[B,'J'],
'r' :[B,'r'],
'R' :[F,'R'],
'l' :[B,'l'],
'L' :[F,'L'],
'W' :[F,'W'],
'V' :[F,'W'],
'h' :[B,'H'],
'kk' :[B,'kK'],
'kkm' :[B,'kK/N'],
'sh' :[B,'sh'],
'^s' :[B,'Sh'],
'^sh' :[B,'Sh'],
's' :[B,'s'],
'^r' :[B,'rh'],
'^rh' :[B,'rhh'],
'y' :[B,'y'],
'Y' :[F,'Y'],
'JY' :[F,'Y'],
'__t' :[B,'t//'],
'^ng' :[B,'NNG'],
':h' :[B,'h'],
'^' :[F,'NN'],
'_' :[F,':/'],
'A' :[S,'A'],
'AA' :[S,'Aa'],
'I' :[S,'I'],
'II' :[S,'II'],
'U' :[S,'U'],
'UU' :[S,'UU'],
'RI' :[S,'RR'],
'E' :[S,'E'],
'OI' :[S,'OI'],
'O' :[S,'O'],
'OU' :[S,'OU'],
'a' :[X,'o',1],
'aa' :[s,'a',1],
'i' :[s,'i',-1],
'ii' :[s,'ii',1],
'u' :[s,'u',1],
'uu' :[s,'uu',1],
'RII' :[s,'rR',1],
'e' :[s,'e',-1],
'oi' :[s,'oi',-2],
'oo' :[s,'oo',11],
'o' :[X,'o',1],
'ou' :[s,'ou',12],
'.' :[F,'.'],
'..' :[F,'..'],
'...' :[F,'...'],
'|' :[F,'|'],
'~' :[F,'~'],
'`' :[F,'`'],
'!' :[F,'!'],
'1' :[F,'1'],
'2' :[F,'2'],
'at' :[F,'@'],
'#' :[F,'#'],
'3' :[F,'3'],
'$' :[F,'$'],
'4' :[F,'4'],
'%' :[F,'%'],
'5' :[F,'5'],
'6' :[F,'6'],
'&' :[F,'&'],
'7' :[F,'7'],
'*' :[F,'*'],
'8' :[F,'8'],
'(' :[F,'('],
'9' :[F,'9'],
')' :[F,')'],
'0' :[F,'0'],
'dash' :[F,'-'],
'+' :[F,'+'],
'=' :[F,'='],
'|' :[F,'|'],
'{' :[F,'{'],
'[' :[F,'['],
'}' :[F,'}'],
']' :[F,']'],
':' :[F,':'],
';' :[F,';'],
'"' :[F,'"'],
"'" :[F,"'"],
'<' :[F,'<'],
',' :[F,','],
'>' :[F,'>'],
'.' :[F,'.'],
'?' :[F,'?'],
'/' :[F,'/']}
CATCODES = {'SS' :[S,'','','',1],
'SB' :[B,'','','',1],
'BS' :[S,'','','',1],
'BB' :[B,'','/','',1],
'BF' :[F,'','','',1],
'Bs1' :[S,'','','',1],
'Bs-1':[S,'\*','','*',1],
'Bs-2':[S,'\*','','*{oi}',0],
'Bs11':[S,'\*','','*ea',0],
'Bs12':[S,'\*','','*eou',0],
'Fs1' :[S,'','','',1],
'Fs-1':[S,'\*','','*',1],
'Fs-2':[S,'\*','','*{oi}',0],
'Fs11':[S,'\*','','*ea',0],
'Fs12':[S,'\*','','*eou',0],
'FF' :[F,'','','',1],
'AX' :[F,'','','',1]}
def blocked(line):
#print '@ blocked', line , '->',
m = sre.findall('@[^@]+@',line)
outline = line
if not m :
#print outline
return(outline)
else:
for i in range(len(m)):
s=m[i][:-1].replace(' ','%X%')
outline = outline.replace(m[i],s,1)
#print outline
return(outline)
def unblock(line):
#print '@unblock', line, '->',
m = sre.findall('@[^\s]+',line)
outline = line
if not m :
#print outline
return(outline)
else:
for i in range(len(m)):
s=m[i].replace('@','').replace('%X%',' ')
outline = outline.replace(m[i],s)
#print outline
return(outline)
def printamp(line):
#print '@unblock', line, '->',
m = sre.findall('#AT',line)
outline = line
if not m :
#print outline
return(outline)
else:
for i in range(len(m)):
outline = outline.replace('#AT','@')
#print outline
return(outline)
def readsyll(syll):
syllparts=[]
start = 0; end = len(syll)
while syll[start : end]:
slice = syll[start : end]
#print slice
if AKSAR.has_key(slice):
syllparts.append(AKSAR[slice])
start = start + len(slice)
end = len(syll)
else :
end = end -1
return(syllparts)
def fuse(list1,list2):
global CCATCODE
#print list1,list2
Type1 = list1[0]
Type2 = list2[0]
if Type2 == s:
Type3 = str(list2[2])
elif Type2 == X:
Type1=A
Type3=''
else:
Type3 =''
Type = Type1+Type2+Type3
#print 'Type:', Type
try:
CATCODE = CATCODES[Type]
TARGET = CATCODE[0]
PREFIX = CATCODE[1]
MIDFIX = CATCODE[2]
POSTFIX = CATCODE[3]
FLAG = CATCODE[4]
#print 'TGT:', TARGET, PREFIX,MIDFIX,POSTFIX,FLAG
#print 'RAWC', AKSAR[list1[1]][1],AKSAR[list2[1]][1]
c1=list1[1]
c2=list2[1]
if FLAG == 1 :
c = PREFIX + c1 + MIDFIX + POSTFIX + c2
else :
c = PREFIX + c1 + MIDFIX + POSTFIX
fused = [TARGET,c]
#print CATCODE
return(fused)
except KeyError:
print '\n ERROR AT LINE:', NCLINE, 'WORD:',NCWORD, '(',CWORD,')'
return(['ERROR','UNKNOWN CATCODE'])
def fuseatoms(syll):
slist=readsyll(syll);
#print slist
lslist=len(slist);
l0=slist[0];
for i in range(1,lslist):
nextitem = slist[i]
l0=fuse(l0,nextitem)
return(l0[1])
def fuseword(wrd):
if wrd[0] == '@' :
return(wrd)
syllables = wrd.split('-')
w0=''
for eachsyll in syllables:
syll=eachsyll
thesyll = fuseatoms(syll)
w0 = w0 + thesyll
#print 'FUSED WORD',w0
return(w0)
def fuseline(line):
global NCWORD,CWORD
NCWORD = 0
#line = blocked(line)
words = line.split()
l0=''
for eachword in words:
NCWORD=NCWORD+1
word = eachword
CWORD=word
theword=fuseword(word)
#print 'XX',theword
l0=l0+' '+theword
#print 'FUSED LINE', l0
return(l0)
# The main program
import sys
OK=1
finnam = sys.argv[1]
foutnam = finnam.split('.')[0] + '.' + 'tex'
fin = file(finnam,'rt')
fout = file(foutnam,'wt')
textin = fin.readlines()
nlines = len(textin)
textout = []
fin.close()
for eachline in textin:
NCLINE = NCLINE+1
if eachline[0] == '#' :
lineout = eachline[1:]
elif eachline[0] == '\\' :
lineout = eachline
elif eachline == '\n':
lineout = eachline
else :
line1 = eachline.strip()
line2 = blocked(line1)
lineout = fuseline(line2) + '\n'
lineout = lineout[1:]
#print ':::', lineout
if lineout.find('UNKNOWN CATCODE') == -1 :
lineout = unblock(lineout)
#print ':::', lineout
textout.append(printamp(lineout))
else :
OK = 0
fout.close()
if OK == 1:
fout.writelines(textout)
fout.close()
print 'done'
else:
print 'Unknown CATCODE, Fix The errors and try again'
|