From eea694d78b09818af1d3bba432bfa97262db8c2a Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 21 Jul 2011 11:23:26 +0800 Subject: refine segment.py --- segment.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'segment.py') diff --git a/segment.py b/segment.py index fbd7f65..b65bfd7 100755 --- a/segment.py +++ b/segment.py @@ -26,10 +26,15 @@ def segmentOneText(infile, outfile, reportfile): return #begin processing - cmdline = './ngseg <"' + infile + '" >"' + outfile + '"' - subprocess = Popen(cmdline, shell=True, stderr=PIPE, \ + cmdline = './ngseg >"' + outfile + '"' + subprocess = Popen(cmdline, shell=True, stdin=PIPE, stderr=PIPE, \ close_fds=True) + with open(infile, 'rb') as f: + subprocess.stdin.writelines(f.readlines()) + subprocess.stdin.close() + f.close() + lines = subprocess.stderr.readlines() if lines: print('found error report') -- cgit