|
|
|
|
File: [home] / javascript / spell.py
(download)
/
(as text)
Revision: 1.3, Sun Apr 24 06:37:31 2005 UTC (5 years, 4 months ago) by ws Branch: MAIN CVS Tags: HEAD Changes since 1.2: +2 -2 lines faster, correct, less compatible -_- |
#!/usr/bin/python
import sys, os, popen2
def log(msg):
f = open('spell.log', 'a')
f.write(msg + "\n")
f.close()
class ispell:
def __init__(self):
self._f = popen2.Popen3("/vhosts/ws/bin/ispell -d/vhosts/ws/lib/ispell/american -a")
self._f.fromchild.readline() #skip the credit line
def __call__(self, word):
self._f.tochild.write(word+'\n')
self._f.tochild.flush()
s = self._f.fromchild.readline()
if 1 == len(s):
s = self._f.fromchild.readline()
ret = (s[0:1] == "*" or s[0:1] == '+')
return ret
try:
spell = ispell()
except:
print "Content-type: text/html\n\n";
print "unable to init ispell"
try:
size = os.environ['CONTENT_LENGTH']
data = sys.stdin.read(int(size)).replace('\0', '')
#log(data)
words = data.split(' ')
print "Content-type: text/html\n\n",
for w in words:
if len(w) > 0 and w[0] != '-' and not spell(w):
print w,
except:
print "Content-type: text/html\n\n";
print "error while trying to spell words"
| tony at ponderer dot org |
Powered by ViewCVS 0.9.2 |