Permalink
Browse files

fixes tryprune.py

  • Loading branch information...
1 parent cd94f84 commit c8c090a77e0ab448c8b65abf40d035f51f9b414d @epico epico committed Jul 27, 2011
Showing with 8 additions and 10 deletions.
  1. +3 −2 evaluate.py
  2. +5 −8 tryprune.py
View
@@ -139,14 +139,15 @@ def evaluateModel():
if utils.check_epoch(cwdstatus, 'Evaluate'):
sys.exit('already evaluated.')
+ print('checking')
+ checkData()
+
modelfile = os.path.join(trydir, config.getFinalModelFileName())
destfile = os.path.join(libpinyindir, 'data', \
config.getFinalModelFileName())
print('copying from ' + modelfile + ' to ' + destfile)
shutil.copyfile(modelfile, destfile)
- print('checking')
- checkData()
print('cleaning')
cleanUpData()
print('building')
View
@@ -52,13 +52,10 @@ def exportModel(modelfile, textmodel):
def convertModel(kmm_model, inter_model):
#begin processing
- cmdline = ['./k_mixture_model_to_interpolation']
+ cmdline = './k_mixture_model_to_interpolation <"' + kmm_model + '"'
- subprocess = Popen(cmdline, shell=False, stdin=PIPE, \
+ subprocess = Popen(cmdline, shell=True, \
stdout=PIPE, close_fds=True)
- with open(kmm_model, 'rb') as f:
- subprocess.stdin.writelines(f.readlines())
- f.close()
with open(inter_model, 'wb') as f:
f.writelines(subprocess.stdout.readlines())
@@ -122,7 +119,7 @@ def mergeSomeModels(mergedmodel, sortedindexname, mergenum):
def pruneModel(prunedmodel, k, CDF):
#begin processing
cmdline = ['./prune_k_mixture_model', \
- '-k', k, '--CDF', CDF,
+ '-k', str(k), '--CDF', str(CDF),
prunedmodel]
subprocess = Popen(cmdline, shell=False, close_fds=True)
@@ -160,7 +157,7 @@ def pruneModel(prunedmodel, k, CDF):
print(args)
tryname = 'try' + args.tryname
- trydir = os.path.join(config.getFinalDir(), tryname)
+ trydir = os.path.join(config.getFinalModelDir(), tryname)
#check try<name> directory
if os.access(trydir, os.F_OK):
@@ -208,7 +205,7 @@ def pruneModel(prunedmodel, k, CDF):
cwdstatus['PruneModelSize'] = modelsize
utils.store_status(cwdstatuspath, cwdstatus)
- print('final model size:' + modelsize)
+ print('final model size:', modelsize)
#sign status epoch
utils.sign_epoch(cwdstatus, 'Prune')

0 comments on commit c8c090a

Please sign in to comment.