From 4627194833a9d50fd218fd3db506685c1d92436d Mon Sep 17 00:00:00 2001 From: Michael Denkowski Date: Tue, 8 Apr 2014 13:54:25 -0700 Subject: setup for hpyplm being optional, different metrics --- realtime/mkconfig.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'realtime/mkconfig.py') diff --git a/realtime/mkconfig.py b/realtime/mkconfig.py index f193c57a..71944080 100755 --- a/realtime/mkconfig.py +++ b/realtime/mkconfig.py @@ -12,11 +12,14 @@ from cdec.configobj import ConfigObj def main(): - if len(sys.argv[1:]) != 12: - sys.stderr.write('usage: {} a.fwd_params a.fwd_err a.rev_params a.rev_err sa sa.ini mono.klm libcdec_ff_hpyplm.so corpus.hpyplm cdec.ini weights.final output.d\n'.format(sys.argv[0])) + if len(sys.argv[1:]) not in (10, 12): + sys.stderr.write('usage: {} a.fwd_params a.fwd_err a.rev_params a.rev_err sa sa.ini mono.klm cdec.ini weights.final output.d [libcdec_ff_hpyplm.so corpus.hpyplm]\n'.format(sys.argv[0])) sys.exit(2) - (a_fwd_params, a_fwd_err, a_rev_params, a_rev_err, sa, sa_ini, mono_klm, libcdec_ff_hpyplm_so, corpus_hpyplm, cdec_ini, weights_final, output_d) = sys.argv[1:] + (a_fwd_params, a_fwd_err, a_rev_params, a_rev_err, sa, sa_ini, mono_klm, cdec_ini, weights_final, output_d) = sys.argv[1:11] + + # Optional + (libcdec_ff_hpyplm_so, corpus_hpyplm) = sys.argv[11:13] if len(sys.argv[1:]) == 12 else (None, None) if os.path.exists(output_d): sys.stderr.write('Directory {} exists, exiting.\n'.format(output_d)) @@ -40,8 +43,10 @@ def main(): # language models shutil.copy(mono_klm, os.path.join(output_d, 'mono.klm')) - shutil.copy(libcdec_ff_hpyplm_so, os.path.join(output_d, 'libcdec_ff_hpyplm.so')) - shutil.copy(corpus_hpyplm, os.path.join(output_d, 'corpus.hpyplm')) + if libcdec_ff_hpyplm_so: + shutil.copy(libcdec_ff_hpyplm_so, os.path.join(output_d, 'libcdec_ff_hpyplm.so')) + if corpus_hpyplm: + shutil.copy(corpus_hpyplm, os.path.join(output_d, 'corpus.hpyplm')) # decoder config config = [[f.strip() for f in line.split('=')] for line in open(cdec_ini)] @@ -52,6 +57,11 @@ def main(): # weights shutil.copy(weights_final, os.path.join(output_d, 'weights.final')) + + # other options + # TODO: automatically set some things here + with open(os.path.join(output_d, 'rt.ini'), 'w') as rt_ini: + pass if __name__ == '__main__': main() -- cgit v1.2.3 From 584e9ccb9cd306626b450962b391c1e521ce206d Mon Sep 17 00:00:00 2001 From: Michael Denkowski Date: Fri, 2 May 2014 12:08:52 -0700 Subject: Automatically generate some rt.ini options --- realtime/mkconfig.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'realtime/mkconfig.py') diff --git a/realtime/mkconfig.py b/realtime/mkconfig.py index 71944080..f9938051 100755 --- a/realtime/mkconfig.py +++ b/realtime/mkconfig.py @@ -59,9 +59,14 @@ def main(): shutil.copy(weights_final, os.path.join(output_d, 'weights.final')) # other options - # TODO: automatically set some things here - with open(os.path.join(output_d, 'rt.ini'), 'w') as rt_ini: - pass + rt_ini = os.path.join(output_d, 'rt.ini') + with open(rt_ini, 'w') as out: + if libcdec_ff_hpyplm_so and corpus_hpyplm: + out.write('hpyplm=true\n') + else: + out.write('hpyplm=false\n') + out.write('metric=ibm_bleu\n') + sys.stderr.write('IMPORTANT: add any additional options such as metric=meteor to {}\n'.format(rt_ini)) if __name__ == '__main__': main() -- cgit v1.2.3