diff options
author | Peng Wu <alexepico@gmail.com> | 2013-04-18 14:51:13 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2013-04-18 15:28:46 +0800 |
commit | 632e0ed5fc56094bf9482a2b4485e27eee390439 (patch) | |
tree | 13e9f30d7a6809b4556e41cb7b9e222748d75900 /segment.py | |
parent | 3179af0ea400d9c6653fda7d2c1bc8f6cef1f75b (diff) | |
download | trainer-632e0ed5fc56094bf9482a2b4485e27eee390439.tar.gz trainer-632e0ed5fc56094bf9482a2b4485e27eee390439.tar.xz trainer-632e0ed5fc56094bf9482a2b4485e27eee390439.zip |
write mergeseq.py
Diffstat (limited to 'segment.py')
-rwxr-xr-x | segment.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 |