diff options
author | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2014-07-09 05:41:28 +0400 |
---|---|---|
committer | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2014-07-09 05:41:28 +0400 |
commit | 4d41211c2cd6eb75c5a229c10e98fdfa1acff3b4 (patch) | |
tree | 142dca24625b301147a931f728825dd40cf74e53 /moses/TranslationModel/UG/generic/program_options/ug_splice_arglist.cc | |
parent | 28d64e23396cba53a83b75e01e9977db636e2285 (diff) |
Major overhaul of Mmsapt. Reorganization of old and addition of new features in phrase tables. Many critical bug fixes.
Diffstat (limited to 'moses/TranslationModel/UG/generic/program_options/ug_splice_arglist.cc')
-rw-r--r-- | moses/TranslationModel/UG/generic/program_options/ug_splice_arglist.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/moses/TranslationModel/UG/generic/program_options/ug_splice_arglist.cc b/moses/TranslationModel/UG/generic/program_options/ug_splice_arglist.cc new file mode 100644 index 000000000..7dc2cd18f --- /dev/null +++ b/moses/TranslationModel/UG/generic/program_options/ug_splice_arglist.cc @@ -0,0 +1,50 @@ +//-*- c++ -*- +#include "ug_splice_arglist.h" +#include "moses/Util.h" +#include "util/exception.hh" +#include <boost/foreach.hpp> + +namespace Moses { + + void + filter_arguments(int const argc_in, char const* const* const argv_in, + int & argc_moses, char*** argv_moses, + int & argc_other, char*** argv_other, + vector<pair<string,int> > const& filter) + { + *argv_moses = new char*[argc_in]; + *argv_other = new char*[argc_in]; + (*argv_moses)[0] = new char[strlen(argv_in[0])+1]; + strcpy((*argv_moses)[0], argv_in[0]); + argc_moses = 1; + argc_other = 0; + typedef pair<string,int> option; + int i = 1; + while (i < argc_in) + { + BOOST_FOREACH(option const& o, filter) + { + if (o.first == argv_in[i]) + { + (*argv_other)[argc_other] = new char[strlen(argv_in[i])+1]; + strcpy((*argv_other)[argc_other++],argv_in[i]); + for (int k = 0; k < o.second; ++k) + { + UTIL_THROW_IF2(++i >= argc_in || argv_in[i][0] == '-', + "[" << HERE << "] Missing argument for " + << "parameter " << o.first << "!"); + (*argv_other)[argc_other] = new char[strlen(argv_in[i])+1]; + strcpy((*argv_other)[argc_other++],argv_in[i]); + } + if (++i >= argc_in) break; + } + } + if (i >= argc_in) break; + (*argv_moses)[argc_moses] = new char[strlen(argv_in[i])+1]; + strcpy((*argv_moses)[argc_moses++], argv_in[i++]); + } + } + +} // namespace Moses + + |