Commit dd9cf8bb authored by Arne Koehn's avatar Arne Koehn

helpers for forcing taggers into an incremental mode

parent a5064077
#! /usr/bin/env python
import sys
#from subprocess import Popen, PIPE
#from StringIO import StringIO
#from time import sleep
#from tempfile import NamedTemporaryFile
#stdinfile = NamedTemporaryFile(mode='w+')
#tnt = Popen("cat | ../tnt/tnt -v0 -z100 ../tnt/"+sys.argv[1]+" -", stdin=PIPE, stdout=PIPE, bufsize=10000, shell=True)
#tntin = stdinfile.file
#tntin = tnt.stdin
sentence = []
while True:
try:
l = "ERROR"
l = sys.stdin.readline()
except:
exit # eof or something
sentence.append(l)
if l == "":
exit() # eof
if l == "\n":
sentence = []
for s in sentence:
print s,
print
# tntin.writelines(sentence)
# force output
# tntin.write("\n")
# tntin.flush()
# sleep(1)
# x = "ERROR"
# y = "ERROR"
# while x.strip() != "":
# y = x
# x = tnt.stdout.readline()
# print "-----", x,
# print y,
#! /usr/bin/env python
import sys
sentence = []
while True:
x = "NEWLINE"
y = ""
while x.strip() != "":
y = x
x = sys.stdin.readline()
if x == "":
exit() # eof reached
if y == "NEWLINE": # end of sentence -> two newlines, print one
print
else:
print y, # y has \n already, don't print a second one
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment