summaryrefslogtreecommitdiffstats
path: root/generate.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-27 16:05:52 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-27 16:05:52 +0800
commit0128ad50d1615c4fa8ff969d9d214029217a9759 (patch)
tree83cf653c2cfbcd97bc7d5d435e1c9b574763ed30 /generate.py
parent2575950b486c9716174a14a8b5ad8c04fa086a14 (diff)
downloadtrainer-0128ad50d1615c4fa8ff969d9d214029217a9759.tar.gz
trainer-0128ad50d1615c4fa8ff969d9d214029217a9759.tar.xz
trainer-0128ad50d1615c4fa8ff969d9d214029217a9759.zip
fixes generate.py
Diffstat (limited to 'generate.py')
-rwxr-xr-xgenerate.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/generate.py b/generate.py
index b28c8d5..13a63d3 100755
--- a/generate.py
+++ b/generate.py
@@ -32,9 +32,9 @@ def generateOneText(infile, modelfile, reportfile):
#begin processing
cmdline = ['./gen_k_mixture_model', '--maximum-occurs-allowed', \
- config.getMaximumOccursAllowed(), \
+ str(config.getMaximumOccursAllowed()), \
'--maximum-increase-rates-allowed', \
- config.getMaximumIncreaseRatesAllowed(), \
+ str(config.getMaximumIncreaseRatesAllowed()), \
'--k-mixture-model-file', \
modelfile, infile + \
config.getSegmentPostfix()]
@@ -73,6 +73,16 @@ def handleOneIndex(indexpath, subdir, indexname):
if 'GenerateModelEnd' in indexstatus:
modelnum = indexstatus['GenerateModelEnd']
+ #clean up previous file
+ modeldir = os.path.join(config.getModelDir(), subdir, indexname)
+ modelfile = os.path.join( \
+ modeldir, config.getCandidateModelName(modelnum))
+ reportfile = modelfile + config.getReportPostfix()
+ if os.access(modelfile, os.F_OK):
+ os.unlink(modelfile)
+ if os.access(reportfile, os.F_OK):
+ os.unlink(reportfile)
+
#begin processing
indexfile = open(indexpath, 'r')
for i, oneline in enumerate(indexfile.readlines()):
@@ -112,14 +122,7 @@ def handleOneIndex(indexpath, subdir, indexname):
aggmodelsize = 0
textnum = nexttextnum
modelnum += 1
- modeldir = os.path.join(config.getModelDir(), subdir, indexname)
- modelfile = os.path.join( \
- modeldir, config.getCandidateModelName(modelnum))
- reportfile = modelfile + config.getReportPostfix()
- if os.access(modelfile, os.F_OK):
- os.unlink(modelfile)
- if os.access(reportfile, os.F_OK):
- os.unlink(reportfile)
+
#save current progress in status file
indexstatus['GenerateTextEnd'] = nexttextnum
indexstatus['GenerateModelEnd'] = modelnum