Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

suppress evaluate.py output

  • Loading branch information...
commit 499b18a799dd14b3ce584be0848d648400727776 1 parent 9d6560b
@epico epico authored
Showing with 11 additions and 9 deletions.
  1. +7 −5 evaluate.py
  2. +4 −4 tryprune.py
View
12 evaluate.py
@@ -97,7 +97,7 @@ def modifyCodeforLambda(lambdaparam):
#end processing
-def evaluateModel():
+def evaluateModel(reportfile):
#change to utils/training subdir
cwd = os.getcwd()
os.chdir(os.path.join(libpinyindir, 'utils', 'training'))
@@ -106,9 +106,9 @@ def evaluateModel():
rate = 0.
#begin processing
- cmdline = ['./eval_correction_rate']
+ cmdline = './eval_correction_rate 2>"' + reportfile + '"'
- subprocess = Popen(cmdline, shell=False, stdout=PIPE, \
+ subprocess = Popen(cmdline, shell=True, stdout=PIPE, \
close_fds=True)
for line in subprocess.stdout.readlines():
@@ -166,7 +166,7 @@ def evaluateModel():
print('estimating')
reportfile = os.path.join \
- (trydir, 'estimate_interpolation' + config.getReportPostfix())
+ (trydir, 'estimate' + config.getReportPostfix())
avg_lambda = estimateModel(reportfile)
cwdstatus['EvaluateAverageLambda'] = avg_lambda
@@ -176,7 +176,9 @@ def evaluateModel():
modifyCodeforLambda(avg_lambda)
print('evaluating')
- rate = evaluateModel()
+ reportfile = os.path.join \
+ (trydir, 'evaluate' + config.getReportPostfix())
+ rate = evaluateModel(reportfile)
print(tryname + "'s correction rate:", rate)
cwdstatus['EvaluateCorrectionRate'] = rate
View
8 tryprune.py
@@ -138,8 +138,8 @@ def pruneModel(prunedmodel, k, CDF):
help='model directory', \
default=config.getModelDir())
- parser.add_argument('--mergenumber', action='store', \
- help='number of documents to be merged', \
+ parser.add_argument('--merge', action='store', \
+ help='number of model candidates to be merged', \
default=10, type=int)
parser.add_argument('-k', action='store', \
@@ -166,7 +166,7 @@ def pruneModel(prunedmodel, k, CDF):
os.makedirs(trydir)
cwdstatuspath = os.path.join(trydir, config.getFinalStatusFileName())
cwdstatus = {}
- cwdstatus['PruneMergeNumber'] = args.mergenumber
+ cwdstatus['PruneMergeNumber'] = args.merge
cwdstatus['PruneK'] = args.k
cwdstatus['PruneCDF'] = args.CDF
utils.store_status(cwdstatuspath, cwdstatus)
@@ -176,7 +176,7 @@ def pruneModel(prunedmodel, k, CDF):
mergedmodel = os.path.join(trydir, 'merged.db')
sortedindexname = os.path.join(args.modeldir, \
config.getSortedEstimateIndex())
- mergeSomeModels(mergedmodel, sortedindexname, args.mergenumber)
+ mergeSomeModels(mergedmodel, sortedindexname, args.merge)
#export textual format
print('exporting')
Please sign in to comment.
Something went wrong with that request. Please try again.