summaryrefslogtreecommitdiffstats
path: root/segment.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-04-18 14:51:13 +0800
committerPeng Wu <alexepico@gmail.com>2013-04-18 15:28:46 +0800
commit632e0ed5fc56094bf9482a2b4485e27eee390439 (patch)
tree13e9f30d7a6809b4556e41cb7b9e222748d75900 /segment.py
parent3179af0ea400d9c6653fda7d2c1bc8f6cef1f75b (diff)
downloadtrainer-632e0ed5fc56094bf9482a2b4485e27eee390439.tar.gz
trainer-632e0ed5fc56094bf9482a2b4485e27eee390439.tar.xz
trainer-632e0ed5fc56094bf9482a2b4485e27eee390439.zip
write mergeseq.py
Diffstat (limited to 'segment.py')
-rwxr-xr-xsegment.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/segment.py b/segment.py
index fe0ba68..f753ef0 100755
--- a/segment.py
+++ b/segment.py
@@ -10,7 +10,7 @@ from myconfig import MyConfig
config = MyConfig()
-#change cwd to the libpinyin utils/segment directory
+#change cwd to the libpinyin data directory
libpinyin_dir = config.getToolsDir()
libpinyin_sub_dir = os.path.join(libpinyin_dir, 'data')
os.chdir(libpinyin_sub_dir)
@@ -43,7 +43,6 @@ def segmentOneText(infile, outfile, reportfile, fast):
print('found error report')
with open(reportfile, 'wb') as f:
f.writelines(lines)
- f.close()
os.waitpid(subprocess.pid, 0)
#end processing
@@ -64,13 +63,16 @@ def handleOneIndex(indexpath, fast):
#remove tailing '\n'
oneline = oneline.rstrip(os.linesep)
(title, textpath) = oneline.split('#')
+
infile = config.getTextDir() + textpath
outfile = config.getTextDir() + textpath + config.getSegmentPostfix()
reportfile = config.getTextDir() + textpath + \
config.getSegmentReportPostfix()
+
print("Processing " + title + '#' + textpath)
segmentOneText(infile, outfile, reportfile, fast)
print("Processed " + title + '#' + textpath)
+
indexfile.close()
#end processing