mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 04:43:03 +03:00
Organized command line options thematically.
This is the first step in migration to the use of boost::program_options for GNU/Linux-style handling of command line options.
This commit is contained in:
parent
06e87d851e
commit
612e014e79
1
Jamroot
1
Jamroot
@ -175,6 +175,7 @@ project : requirements
|
||||
<threading>multi:<define>WITH_THREADS
|
||||
<threading>multi:<library>boost_thread
|
||||
<library>boost_system
|
||||
<library>boost_program_options
|
||||
<define>_FILE_OFFSET_BITS=64 <define>_LARGE_FILES
|
||||
$(requirements)
|
||||
<include>.
|
||||
|
@ -31,9 +31,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "InputFileStream.h"
|
||||
#include "StaticData.h"
|
||||
#include "util/exception.hh"
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::algorithm;
|
||||
namespace po = boost::program_options;
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
@ -41,185 +44,285 @@ namespace Moses
|
||||
/** define allowed parameters */
|
||||
Parameter::Parameter()
|
||||
{
|
||||
AddParam("mapping", "description of decoding steps");
|
||||
AddParam("beam-threshold", "b", "threshold for threshold pruning");
|
||||
AddParam("config", "f", "location of the configuration file");
|
||||
//AddParam("continue-partial-translation", "cpt", "start from nonempty hypothesis");
|
||||
AddParam("decoding-graph-backoff", "dpb", "only use subsequent decoding paths for unknown spans of given length");
|
||||
AddParam("drop-unknown", "du", "drop unknown words instead of copying them");
|
||||
AddParam("disable-discarding", "dd", "disable hypothesis discarding");
|
||||
AddParam("factor-delimiter", "fd", "specify a different factor delimiter than the default");
|
||||
AddParam("input-factors", "list of factors in the input");
|
||||
AddParam("input-file", "i", "location of the input file to be translated");
|
||||
AddParam("inputtype", "text (0), confusion network (1), word lattice (2), tree (3) (default = 0)");
|
||||
AddParam("labeled-n-best-list", "print out labels for each weight type in n-best list. default is true");
|
||||
AddParam("mark-unknown", "mu", "mark unknown words in output");
|
||||
AddParam("max-partial-trans-opt", "maximum number of partial translation options per input span (during mapping steps)");
|
||||
AddParam("max-trans-opt-per-coverage", "maximum number of translation options per input span (after applying mapping steps)");
|
||||
AddParam("max-phrase-length", "maximum phrase length (default 20)");
|
||||
AddParam("n-best-list", "file and size of n-best-list to be generated; specify - as the file in order to write to STDOUT");
|
||||
AddParam("n-best-trees", "Write n-best target-side trees to n-best-list");
|
||||
AddParam("lattice-samples", "generate samples from lattice, in same format as nbest list. Uses the file and size arguments, as in n-best-list");
|
||||
AddParam("n-best-factor", "factor to compute the maximum number of contenders (=factor*nbest-size). value 0 means infinity, i.e. no threshold. default is 0");
|
||||
AddParam("print-all-derivations", "to print all derivations in search graph");
|
||||
AddParam("output-factors", "list of factors in the output");
|
||||
AddParam("phrase-drop-allowed", "da", "if present, allow dropping of source words"); //da = drop any (word); see -du for comparison
|
||||
AddParam("report-all-factors", "report all factors in output, not just first");
|
||||
AddParam("report-all-factors-in-n-best", "Report all factors in n-best-lists. Default is false");
|
||||
AddParam("stack", "s", "maximum stack size for histogram pruning. 0 = unlimited stack size");
|
||||
AddParam("stack-diversity", "sd", "minimum number of hypothesis of each coverage in stack (default 0)");
|
||||
AddParam("threads","th", "number of threads to use in decoding (defaults to single-threaded)");
|
||||
AddParam("translation-details", "T", "for each best hypothesis, report translation details to the given file");
|
||||
AddParam("tree-translation-details", "Ttree", "for each hypothesis, report translation details with tree fragment info to given file");
|
||||
//DIMw
|
||||
AddParam("translation-all-details", "Tall", "for all hypotheses, report translation details to the given file");
|
||||
AddParam("translation-option-threshold", "tot", "threshold for translation options relative to best for input phrase");
|
||||
AddParam("early-discarding-threshold", "edt", "threshold for constructing hypotheses based on estimate cost");
|
||||
AddParam("verbose", "v", "verbosity level of the logging");
|
||||
AddParam("references", "Reference file(s) - used for bleu score feature");
|
||||
AddParam("output-factors", "list if factors in the output");
|
||||
AddParam("distortion-limit", "dl", "distortion (reordering) limit in maximum number of words (0 = monotone, -1 = unlimited)");
|
||||
AddParam("monotone-at-punctuation", "mp", "do not reorder over punctuation");
|
||||
AddParam("distortion-file", "source factors (0 if table independent of source), target factors, location of the factorized/lexicalized reordering tables");
|
||||
AddParam("distortion", "configurations for each factorized/lexicalized reordering model.");
|
||||
AddParam("early-distortion-cost", "edc", "include estimate of distortion cost yet to be incurred in the score [Moore & Quirk 2007]. Default is no");
|
||||
AddParam("xml-input", "xi", "allows markup of input with desired translations and probabilities. values can be 'pass-through' (default), 'inclusive', 'exclusive', 'constraint', 'ignore'");
|
||||
AddParam("xml-brackets", "xb", "specify strings to be used as xml tags opening and closing, e.g. \"{{ }}\" (default \"< >\"). Avoid square brackets because of configuration file format. Valid only with text input mode" );
|
||||
AddParam("minimum-bayes-risk", "mbr", "use miminum Bayes risk to determine best translation");
|
||||
AddParam("lminimum-bayes-risk", "lmbr", "use lattice miminum Bayes risk to determine best translation");
|
||||
AddParam("mira", "do mira training");
|
||||
AddParam("consensus-decoding", "con", "use consensus decoding (De Nero et. al. 2009)");
|
||||
AddParam("mbr-size", "number of translation candidates considered in MBR decoding (default 200)");
|
||||
AddParam("mbr-scale", "scaling factor to convert log linear score probability in MBR decoding (default 1.0)");
|
||||
AddParam("lmbr-thetas", "theta(s) for lattice mbr calculation");
|
||||
AddParam("lmbr-pruning-factor", "average number of nodes/word wanted in pruned lattice");
|
||||
AddParam("lmbr-p", "unigram precision value for lattice mbr");
|
||||
AddParam("lmbr-r", "ngram precision decay value for lattice mbr");
|
||||
AddParam("lmbr-map-weight", "weight given to map solution when doing lattice MBR (default 0)");
|
||||
AddParam("lattice-hypo-set", "to use lattice as hypo set during lattice MBR");
|
||||
AddParam("lmodel-oov-feature", "add language model oov feature, one per model");
|
||||
AddParam("clean-lm-cache", "clean language model caches after N translations (default N=1)");
|
||||
AddParam("recover-input-path", "r", "(conf net/word lattice only) - recover input path corresponding to the best translation");
|
||||
AddParam("output-word-graph", "owg", "Output stack info as word graph. Takes filename, 0=only hypos in stack, 1=stack + nbest hypos");
|
||||
AddParam("time-out", "seconds after which is interrupted (-1=no time-out, default is -1)");
|
||||
AddParam("output-search-graph", "osg", "Output connected hypotheses of search into specified filename");
|
||||
AddParam("output-search-graph-extended", "osgx", "Output connected hypotheses of search into specified filename, in extended format");
|
||||
AddParam("unpruned-search-graph", "usg", "When outputting chart search graph, do not exclude dead ends. Note: stack pruning may have eliminated some hypotheses");
|
||||
AddParam("output-search-graph-slf", "slf", "Output connected hypotheses of search into specified directory, one file per sentence, in HTK standard lattice format (SLF) - the flag should be followed by a directory name, which must exist");
|
||||
AddParam("output-search-graph-hypergraph", "Output connected hypotheses of search into specified directory, one file per sentence, in a hypergraph format (see Kenneth Heafield's lazy hypergraph decoder). This flag is followed by 3 values: 'true (gz|txt|bz) directory-name'");
|
||||
AddParam("include-lhs-in-search-graph", "lhssg", "When outputting chart search graph, include the label of the LHS of the rule (useful when using syntax)");
|
||||
#ifdef HAVE_PROTOBUF
|
||||
AddParam("output-search-graph-pb", "pb", "Write phrase lattice to protocol buffer objects in the specified path.");
|
||||
#endif
|
||||
AddParam("cube-pruning-pop-limit", "cbp", "How many hypotheses should be popped for each stack. (default = 1000)");
|
||||
AddParam("cube-pruning-diversity", "cbd", "How many hypotheses should be created for each coverage. (default = 0)");
|
||||
AddParam("description", "Source language, target language, description");
|
||||
AddParam("max-chart-span", "maximum num. of source word chart rules can consume (default 10)");
|
||||
AddParam("non-terminals", "list of non-term symbols, space separated");
|
||||
AddParam("rule-limit", "a little like table limit. But for chart decoding rules. Default is DEFAULT_MAX_TRANS_OPT_SIZE");
|
||||
AddParam("source-label-overlap", "What happens if a span already has a label. 0=add more. 1=replace. 2=discard. Default is 0");
|
||||
AddParam("output-hypo-score", "Output the hypo score to stdout with the output string. For search error analysis. Default is false");
|
||||
AddParam("unknown-lhs", "file containing target lhs of unknown words. 1 per line: LHS prob");
|
||||
AddParam("cube-pruning-lazy-scoring", "cbls", "Don't fully score a hypothesis until it is popped");
|
||||
AddParam("search-algorithm", "Which search algorithm to use. 0=normal stack, 1=cube pruning, 3=chart (with cube pruning), 4=stack with batched lm requests, 5=chart (with incremental search), 6=string-to-tree, 7=tree-to-string, 8=tree-to-string (SCFG-based), 9=forest-to-string (default = 0)");
|
||||
AddParam("link-param-count", "Number of parameters on word links when using confusion networks or lattices (default = 1)");
|
||||
AddParam("description", "Source language, target language, description");
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// general options
|
||||
po::options_description main_opts("Main Options");
|
||||
AddParam(main_opts,"config", "f", "location of the configuration file");
|
||||
AddParam(main_opts,"input-file", "i", "location of the input file to be translated");
|
||||
|
||||
AddParam("max-chart-span", "maximum num. of source word chart rules can consume (default 10)");
|
||||
AddParam("non-terminals", "list of non-term symbols, space separated");
|
||||
AddParam("rule-limit", "a little like table limit. But for chart decoding rules. Default is DEFAULT_MAX_TRANS_OPT_SIZE");
|
||||
AddParam("source-label-overlap", "What happens if a span already has a label. 0=add more. 1=replace. 2=discard. Default is 0");
|
||||
AddParam("output-hypo-score", "Output the hypo score to stdout with the output string. For search error analysis. Default is false");
|
||||
AddParam("show-weights", "print feature weights and exit");
|
||||
AddParam("start-translation-id", "Id of 1st input. Default = 0");
|
||||
AddParam("output-unknowns", "Output the unknown (OOV) words to the given file, one line per sentence");
|
||||
AddParam(main_opts,"verbose", "v", "verbosity level of the logging");
|
||||
AddParam(main_opts,"show-weights", "print feature weights and exit");
|
||||
AddParam(main_opts,"time-out", "seconds after which is interrupted (-1=no time-out, default is -1)");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// factorization options
|
||||
po::options_description factor_opts("General Factorization Options");
|
||||
AddParam(factor_opts,"factor-delimiter", "fd", "specify a different factor delimiter than the default");
|
||||
// one should be able to specify different factor delimiters for intput and output
|
||||
AddParam(factor_opts,"mapping", "description of decoding steps"); // whatever that means ...
|
||||
AddParam(factor_opts,"placeholder-factor", "Which source factor to use to store the original text for placeholders. The factor must not be used by a translation or gen model");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// general search options
|
||||
po::options_description search_opts("Search Options");
|
||||
string desc = "Which search algorithm to use.\n";
|
||||
desc += "0=normal stack (default)\n";
|
||||
desc += "1=cube pruning\n";
|
||||
desc += "3=chart (with cube pruning)\n";
|
||||
desc += "4=stack with batched lm requests\n";
|
||||
desc += "5=chart (with incremental search)\n";
|
||||
desc += "6=string-to-tree\n";
|
||||
desc += "7=tree-to-string\n";
|
||||
desc += "8=tree-to-string (SCFG-based)\n";
|
||||
desc += "9=forest-to-string";
|
||||
AddParam(search_opts,"search-algorithm", desc);
|
||||
AddParam(search_opts,"beam-threshold", "b", "threshold for threshold pruning");
|
||||
AddParam(search_opts,"early-discarding-threshold", "edt", "threshold for constructing hypotheses based on estimate cost");
|
||||
AddParam(search_opts,"stack", "s", "maximum stack size for histogram pruning. 0 = unlimited stack size");
|
||||
AddParam(search_opts,"stack-diversity", "sd", "minimum number of hypothesis of each coverage in stack (default 0)");
|
||||
|
||||
// feature weight-related options
|
||||
AddParam(search_opts,"weight-file", "wf", "feature weights file. Do *not* put weights for 'core' features in here - they go in moses.ini");
|
||||
AddParam(search_opts,"weight", "weights for ALL models, 1 per line 'WeightName value'. Weight names can be repeated");
|
||||
|
||||
AddParam(search_opts,"feature-overwrite", "Override arguments in a particular feature function with a particular key. Format: -feature-overwrite \"FeatureName key=value\"");
|
||||
|
||||
po::options_description tune_opts("Options used in tuning.");
|
||||
AddParam(tune_opts,"weight-overwrite", "special parameter for mert. All on 1 line. Overrides weights specified in 'weights' argument");
|
||||
AddParam(tune_opts,"feature-add", "Add a feature function on the command line. Used by mira to add BLEU feature");
|
||||
AddParam(tune_opts,"weight-add", "Add weight for FF if it doesn't exist, i.e weights here are added 1st, and can be override by the ini file or on the command line. Used to specify initial weights for FF that was also specified on the copmmand line");
|
||||
|
||||
// phrase table limitations:
|
||||
AddParam(search_opts,"max-partial-trans-opt", "maximum number of partial translation options per input span (during mapping steps)");
|
||||
AddParam(search_opts,"max-trans-opt-per-coverage", "maximum number of translation options per input span (after applying mapping steps)");
|
||||
AddParam(search_opts,"max-phrase-length", "maximum phrase length (default 20)");
|
||||
AddParam(search_opts,"translation-option-threshold", "tot", "threshold for translation options relative to best for input phrase");
|
||||
|
||||
// miscellaneous search options
|
||||
AddParam(search_opts,"disable-discarding", "dd", "disable hypothesis discarding"); // ??? memory management? UG
|
||||
AddParam(search_opts,"phrase-drop-allowed", "da", "if present, allow dropping of source words"); //da = drop any (word); see -du for comparison
|
||||
AddParam(search_opts,"threads","th", "number of threads to use in decoding (defaults to single-threaded)");
|
||||
|
||||
// distortion options
|
||||
po::options_description disto_opts("Distortion options");
|
||||
AddParam(disto_opts,"distortion-limit", "dl", "distortion (reordering) limit in maximum number of words (0 = monotone, -1 = unlimited)");
|
||||
AddParam(disto_opts,"monotone-at-punctuation", "mp", "do not reorder over punctuation");
|
||||
AddParam(disto_opts,"early-distortion-cost", "edc", "include estimate of distortion cost yet to be incurred in the score [Moore & Quirk 2007]. Default is no");
|
||||
AddParam(disto_opts,"distortion", "configurations for each factorized/lexicalized reordering model."); // zombie parameter?
|
||||
|
||||
// cube pruning
|
||||
po::options_description cube_opts("Cube pruning options.");
|
||||
AddParam(cube_opts,"cube-pruning-pop-limit", "cbp", "How many hypotheses should be popped for each stack. (default = 1000)");
|
||||
AddParam(cube_opts,"cube-pruning-diversity", "cbd", "How many hypotheses should be created for each coverage. (default = 0)");
|
||||
AddParam(cube_opts,"cube-pruning-lazy-scoring", "cbls", "Don't fully score a hypothesis until it is popped");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// minimum bayes risk decoding
|
||||
po::options_description mbr_opts("Minimum Bayes Risk (MBR), Lattice MBR, and Consensus decoding");
|
||||
|
||||
AddParam(mbr_opts,"minimum-bayes-risk", "mbr", "use miminum Bayes risk to determine best translation");
|
||||
AddParam(mbr_opts,"mbr-size", "number of translation candidates considered in MBR decoding (default 200)");
|
||||
AddParam(mbr_opts,"mbr-scale", "scaling factor to convert log linear score probability in MBR decoding (default 1.0)");
|
||||
|
||||
AddParam(mbr_opts,"lminimum-bayes-risk", "lmbr", "use lattice miminum Bayes risk to determine best translation");
|
||||
AddParam(mbr_opts,"consensus-decoding", "con", "use consensus decoding (De Nero et. al. 2009)");
|
||||
|
||||
po::options_description lmbr_opts("Options specific to Lattic MBR");
|
||||
AddParam(lmbr_opts,"lmbr-p", "unigram precision value for lattice mbr");
|
||||
AddParam(lmbr_opts,"lmbr-r", "ngram precision decay value for lattice mbr");
|
||||
AddParam(lmbr_opts,"lmbr-thetas", "theta(s) for lattice mbr calculation");
|
||||
AddParam(mbr_opts,"lmbr-map-weight", "weight given to map solution when doing lattice MBR (default 0)");
|
||||
AddParam(mbr_opts,"lmbr-pruning-factor", "average number of nodes/word wanted in pruned lattice");
|
||||
AddParam(mbr_opts,"lattice-hypo-set", "to use lattice as hypo set during lattice MBR");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// OOV handling options
|
||||
po::options_description oov_opts("OOV Handling Options");
|
||||
AddParam(oov_opts,"drop-unknown", "du", "drop unknown words instead of copying them");
|
||||
AddParam(oov_opts,"mark-unknown", "mu", "mark unknown words in output");
|
||||
AddParam(oov_opts,"lmodel-oov-feature", "add language model oov feature, one per model");
|
||||
AddParam(oov_opts,"output-unknowns", "Output the unknown (OOV) words to the given file, one line per sentence");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// input options
|
||||
po::options_description input_opts("Input Format Options");
|
||||
AddParam(input_opts,"input-factors", "list of factors in the input");
|
||||
AddParam(input_opts,"inputtype", "text (0), confusion network (1), word lattice (2), tree (3) (default = 0)");
|
||||
AddParam(input_opts,"xml-input", "xi", "allows markup of input with desired translations and probabilities. values can be 'pass-through' (default), 'inclusive', 'exclusive', 'constraint', 'ignore'");
|
||||
AddParam(input_opts,"xml-brackets", "xb", "specify strings to be used as xml tags opening and closing, e.g. \"{{ }}\" (default \"< >\"). Avoid square brackets because of configuration file format. Valid only with text input mode" );
|
||||
AddParam(input_opts,"start-translation-id", "Id of 1st input. Default = 0");
|
||||
AddParam(input_opts,"alternate-weight-setting", "aws", "alternate set of weights to used per xml specification");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// output options
|
||||
po::options_description output_opts("Output Options");
|
||||
AddParam(output_opts,"report-all-factors", "report all factors in output, not just first");
|
||||
AddParam(output_opts,"output-factors", "list if factors in the output");
|
||||
AddParam(output_opts,"print-id", "prefix translations with id. Default if false");
|
||||
AddParam(output_opts,"print-passthrough", "output the sgml tag <passthrough> without any computation on that. Default is false");
|
||||
AddParam(output_opts,"print-passthrough-in-n-best", "output the sgml tag <passthrough> without any computation on that in each entry of the n-best-list. Default is false");
|
||||
AddParam(output_opts,"output-factors", "list of factors in the output");
|
||||
AddParam(output_opts,"print-all-derivations", "to print all derivations in search graph");
|
||||
AddParam(output_opts,"translation-details", "T", "for each best hypothesis, report translation details to the given file");
|
||||
|
||||
AddParam(output_opts,"output-hypo-score", "Output the hypo score to stdout with the output string. For search error analysis. Default is false");
|
||||
AddParam(output_opts,"output-word-graph", "owg", "Output stack info as word graph. Takes filename, 0=only hypos in stack, 1=stack + nbest hypos");
|
||||
AddParam(output_opts,"tree-translation-details", "Ttree", "for each hypothesis, report translation details with tree fragment info to given file");
|
||||
AddParam(output_opts,"print-alignment-info", "Output word-to-word alignment to standard out, separated from translation by |||. Word-to-word alignments are takne from the phrase table if any. Default is false");
|
||||
AddParam(output_opts,"alignment-output-file", "print output word alignments into given file");
|
||||
AddParam(output_opts,"sort-word-alignment", "Sort word alignments for more consistent display. 0=no sort (default), 1=target order");
|
||||
AddParam(output_opts,"report-segmentation", "t", "report phrase segmentation in the output");
|
||||
AddParam(output_opts,"report-segmentation-enriched", "tt", "report phrase segmentation in the output with additional information");
|
||||
|
||||
// translation-all-details was introduced in the context of DIMwid: Decoder Inspection for Moses (using Widgets)
|
||||
// see here: https://ufal.mff.cuni.cz/pbml/100/art-kurtz-seemann-braune-maletti.pdf
|
||||
AddParam(output_opts,"translation-all-details", "Tall", "for all hypotheses, report translation details to the given file");
|
||||
|
||||
po::options_description osg_opts("Options for outputting search graphs");
|
||||
AddParam(osg_opts,"output-search-graph", "osg", "Output connected hypotheses of search into specified filename");
|
||||
AddParam(osg_opts,"output-search-graph-extended", "osgx", "Output connected hypotheses of search into specified filename, in extended format");
|
||||
AddParam(osg_opts,"unpruned-search-graph", "usg", "When outputting chart search graph, do not exclude dead ends. Note: stack pruning may have eliminated some hypotheses");
|
||||
AddParam(osg_opts,"output-search-graph-slf", "slf", "Output connected hypotheses of search into specified directory, one file per sentence, in HTK standard lattice format (SLF) - the flag should be followed by a directory name, which must exist");
|
||||
AddParam(output_opts,"include-lhs-in-search-graph", "lhssg", "When outputting chart search graph, include the label of the LHS of the rule (useful when using syntax)");
|
||||
#ifdef HAVE_PROTOBUF
|
||||
AddParam(osg_opts,"output-search-graph-pb", "pb", "Write phrase lattice to protocol buffer objects in the specified path.");
|
||||
#endif
|
||||
AddParam(osg_opts,"output-search-graph-hypergraph", "DEPRECATED! Output connected hypotheses of search into specified directory, one file per sentence, in a hypergraph format (see Kenneth Heafield's lazy hypergraph decoder). This flag is followed by 3 values: 'true (gz|txt|bz) directory-name'");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// nbest-options
|
||||
po::options_description nbest_opts("N-best Options");
|
||||
AddParam(nbest_opts,"n-best-list", "file and size of n-best-list to be generated; specify - as the file in order to write to STDOUT");
|
||||
// AddParam(nbest_opts,"n-best-list-file", "file of n-best-list to be generated; specify - as the file in order to write to STDOUT");
|
||||
// AddParam(nbest_opts,"n-best-list-size", "size of n-best-list to be generated; specify - as the file in order to write to STDOUT");
|
||||
AddParam(nbest_opts,"labeled-n-best-list", "print out labels for each weight type in n-best list. default is true");
|
||||
AddParam(nbest_opts,"n-best-trees", "Write n-best target-side trees to n-best-list");
|
||||
AddParam(nbest_opts,"n-best-factor", "factor to compute the maximum number of contenders (=factor*nbest-size). value 0 means infinity, i.e. no threshold. default is 0");
|
||||
AddParam(nbest_opts,"report-all-factors-in-n-best", "Report all factors in n-best-lists. Default is false");
|
||||
AddParam(nbest_opts,"lattice-samples", "generate samples from lattice, in same format as nbest list. Uses the file and size arguments, as in n-best-list");
|
||||
AddParam(nbest_opts,"include-segmentation-in-n-best", "include phrasal segmentation in the n-best list. default is false");
|
||||
AddParam(nbest_opts,"print-alignment-info-in-n-best",
|
||||
"Include word-to-word alignment in the n-best list. Word-to-word alignments are taken from the phrase table if any. Default is false");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// server options
|
||||
po::options_description server_opts("Moses Server Options");
|
||||
AddParam(server_opts,"server", "Run moses as a translation server.");
|
||||
AddParam(server_opts,"server-port", "Port for moses server");
|
||||
AddParam(server_opts,"server-log", "Log destination for moses server");
|
||||
AddParam(server_opts,"serial", "Run server in serial mode, processing only one request at a time.");
|
||||
|
||||
po::options_description irstlm_opts("IRSTLM Options");
|
||||
AddParam(irstlm_opts,"clean-lm-cache",
|
||||
"clean language model caches after N translations (default N=1)");
|
||||
|
||||
po::options_description chart_opts("Chart Decoding Options");
|
||||
AddParam(chart_opts,"max-chart-span", "maximum num. of source word chart rules can consume (default 10)");
|
||||
AddParam(chart_opts,"non-terminals", "list of non-term symbols, space separated");
|
||||
AddParam(chart_opts,"rule-limit", "a little like table limit. But for chart decoding rules. Default is DEFAULT_MAX_TRANS_OPT_SIZE");
|
||||
AddParam(chart_opts,"source-label-overlap", "What happens if a span already has a label. 0=add more. 1=replace. 2=discard. Default is 0");
|
||||
AddParam(chart_opts,"unknown-lhs", "file containing target lhs of unknown words. 1 per line: LHS prob");
|
||||
|
||||
po::options_description misc_opts("Miscellaneous Options");
|
||||
AddParam(misc_opts,"mira", "do mira training");
|
||||
AddParam(misc_opts,"description", "Source language, target language, description");
|
||||
AddParam(misc_opts,"no-cache", "Disable all phrase-table caching. Default = false (ie. enable caching)");
|
||||
AddParam(misc_opts,"default-non-term-for-empty-range-only", "Don't add [X] to all ranges, just ranges where there isn't a source non-term. Default = false (ie. add [X] everywhere)");
|
||||
AddParam(misc_opts,"s2t-parsing-algorithm", "Which S2T parsing algorithm to use. 0=recursive CYK+, 1=scope-3 (default = 0)");
|
||||
|
||||
//AddParam(o,"continue-partial-translation", "cpt", "start from nonempty hypothesis");
|
||||
AddParam(misc_opts,"decoding-graph-backoff", "dpb", "only use subsequent decoding paths for unknown spans of given length");
|
||||
AddParam(misc_opts,"references", "Reference file(s) - used for bleu score feature");
|
||||
AddParam(misc_opts,"recover-input-path", "r", "(conf net/word lattice only) - recover input path corresponding to the best translation");
|
||||
AddParam(misc_opts,"link-param-count", "Number of parameters on word links when using confusion networks or lattices (default = 1)");
|
||||
AddParam(misc_opts,"description", "Source language, target language, description");
|
||||
AddParam(misc_opts,"feature-name-overwrite", "Override feature name (NOT arguments). Eg. SRILM-->KENLM, PhraseDictionaryMemory-->PhraseDictionaryScope3");
|
||||
|
||||
AddParam(misc_opts,"feature", "All the feature functions should be here");
|
||||
|
||||
// Compact phrase table and reordering table.
|
||||
AddParam("minlexr-memory", "Load lexical reordering table in minlexr format into memory");
|
||||
AddParam("minphr-memory", "Load phrase table in minphr format into memory");
|
||||
|
||||
AddParam("print-alignment-info", "Output word-to-word alignment to standard out, separated from translation by |||. Word-to-word alignments are takne from the phrase table if any. Default is false");
|
||||
AddParam("include-segmentation-in-n-best", "include phrasal segmentation in the n-best list. default is false");
|
||||
AddParam("print-alignment-info-in-n-best", "Include word-to-word alignment in the n-best list. Word-to-word alignments are takne from the phrase table if any. Default is false");
|
||||
AddParam("alignment-output-file", "print output word alignments into given file");
|
||||
AddParam("sort-word-alignment", "Sort word alignments for more consistent display. 0=no sort (default), 1=target order");
|
||||
AddParam("report-segmentation", "t", "report phrase segmentation in the output");
|
||||
AddParam("report-segmentation-enriched", "tt", "report phrase segmentation in the output with additional information");
|
||||
AddParam("link-param-count", "DEPRECATED. DO NOT USE. Number of parameters on word links when using confusion networks or lattices (default = 1)");
|
||||
|
||||
AddParam("weight-slm", "slm", "DEPRECATED. DO NOT USE. weight(s) for syntactic language model");
|
||||
AddParam("weight-bl", "bl", "DEPRECATED. DO NOT USE. weight for bleu score feature");
|
||||
AddParam("weight-d", "d", "DEPRECATED. DO NOT USE. weight(s) for distortion (reordering components)");
|
||||
AddParam("weight-dlm", "dlm", "DEPRECATED. DO NOT USE. weight for discriminative LM feature function (on top of sparse weights)");
|
||||
AddParam("weight-lr", "lr", "DEPRECATED. DO NOT USE. weight(s) for lexicalized reordering, if not included in weight-d");
|
||||
AddParam("weight-generation", "g", "DEPRECATED. DO NOT USE. weight(s) for generation components");
|
||||
AddParam("weight-i", "I", "DEPRECATED. DO NOT USE. weight(s) for word insertion - used for parameters from confusion network and lattice input links");
|
||||
AddParam("weight-l", "lm", "DEPRECATED. DO NOT USE. weight(s) for language models");
|
||||
AddParam("weight-lex", "lex", "DEPRECATED. DO NOT USE. weight for global lexical model");
|
||||
AddParam("weight-glm", "glm", "DEPRECATED. DO NOT USE. weight for global lexical feature, sparse producer");
|
||||
AddParam("weight-wt", "wt", "DEPRECATED. DO NOT USE. weight for word translation feature");
|
||||
AddParam("weight-pp", "pp", "DEPRECATED. DO NOT USE. weight for phrase pair feature");
|
||||
AddParam("weight-pb", "pb", "DEPRECATED. DO NOT USE. weight for phrase boundary feature");
|
||||
AddParam("weight-t", "tm", "DEPRECATED. DO NOT USE. weights for translation model components");
|
||||
AddParam("weight-p", "w", "DEPRECATED. DO NOT USE. weight for phrase penalty");
|
||||
AddParam("weight-w", "w", "DEPRECATED. DO NOT USE. weight for word penalty");
|
||||
AddParam("weight-u", "u", "DEPRECATED. DO NOT USE. weight for unknown word penalty");
|
||||
AddParam("weight-e", "e", "DEPRECATED. DO NOT USE. weight for word deletion");
|
||||
AddParam("text-type", "DEPRECATED. DO NOT USE. should be one of dev/devtest/test, used for domain adaptation features");
|
||||
AddParam("input-scores", "DEPRECATED. DO NOT USE. 2 numbers on 2 lines - [1] of scores on each edge of a confusion network or lattice input (default=1). [2] Number of 'real' word scores (0 or 1. default=0)");
|
||||
|
||||
AddParam("dlm-model", "DEPRECATED. DO NOT USE. Order, factor and vocabulary file for discriminative LM. Use * for filename to indicate unlimited vocabulary.");
|
||||
AddParam("generation-file", "DEPRECATED. DO NOT USE. location and properties of the generation table");
|
||||
AddParam("global-lexical-file", "gl", "DEPRECATED. DO NOT USE. discriminatively trained global lexical translation model file");
|
||||
AddParam("glm-feature", "DEPRECATED. DO NOT USE. discriminatively trained global lexical translation feature, sparse producer");
|
||||
AddParam("lmodel-file", "DEPRECATED. DO NOT USE. location and properties of the language models");
|
||||
AddParam("lmodel-dub", "DEPRECATED. DO NOT USE. dictionary upper bounds of language models");
|
||||
po::options_description cpt_opts("Options when using compact phrase and reordering tables.");
|
||||
AddParam(cpt_opts,"minphr-memory", "Load phrase table in minphr format into memory");
|
||||
AddParam(cpt_opts,"minlexr-memory", "Load lexical reordering table in minlexr format into memory");
|
||||
|
||||
po::options_description spe_opts("Simulated Post-editing Options");
|
||||
AddParam(spe_opts,"spe-src", "Simulated post-editing. Source filename");
|
||||
AddParam(spe_opts,"spe-trg", "Simulated post-editing. Target filename");
|
||||
AddParam(spe_opts,"spe-aln", "Simulated post-editing. Alignment filename");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// DEPRECATED options
|
||||
po::options_description deprec_opts("Deprecated Options");
|
||||
AddParam(deprec_opts,"link-param-count", "DEPRECATED. DO NOT USE. Number of parameters on word links when using confusion networks or lattices (default = 1)");
|
||||
AddParam(deprec_opts,"weight-slm", "slm", "DEPRECATED. DO NOT USE. weight(s) for syntactic language model");
|
||||
AddParam(deprec_opts,"weight-bl", "bl", "DEPRECATED. DO NOT USE. weight for bleu score feature");
|
||||
AddParam(deprec_opts,"weight-d", "d", "DEPRECATED. DO NOT USE. weight(s) for distortion (reordering components)");
|
||||
AddParam(deprec_opts,"weight-dlm", "dlm", "DEPRECATED. DO NOT USE. weight for discriminative LM feature function (on top of sparse weights)");
|
||||
AddParam(deprec_opts,"weight-lr", "lr", "DEPRECATED. DO NOT USE. weight(s) for lexicalized reordering, if not included in weight-d");
|
||||
AddParam(deprec_opts,"weight-generation", "g", "DEPRECATED. DO NOT USE. weight(s) for generation components");
|
||||
AddParam(deprec_opts,"weight-i", "I", "DEPRECATED. DO NOT USE. weight(s) for word insertion - used for parameters from confusion network and lattice input links");
|
||||
AddParam(deprec_opts,"weight-l", "lm", "DEPRECATED. DO NOT USE. weight(s) for language models");
|
||||
AddParam(deprec_opts,"weight-lex", "lex", "DEPRECATED. DO NOT USE. weight for global lexical model");
|
||||
AddParam(deprec_opts,"weight-glm", "glm", "DEPRECATED. DO NOT USE. weight for global lexical feature, sparse producer");
|
||||
AddParam(deprec_opts,"weight-wt", "wt", "DEPRECATED. DO NOT USE. weight for word translation feature");
|
||||
AddParam(deprec_opts,"weight-pp", "pp", "DEPRECATED. DO NOT USE. weight for phrase pair feature");
|
||||
AddParam(deprec_opts,"weight-pb", "pb", "DEPRECATED. DO NOT USE. weight for phrase boundary feature");
|
||||
AddParam(deprec_opts,"weight-t", "tm", "DEPRECATED. DO NOT USE. weights for translation model components");
|
||||
AddParam(deprec_opts,"weight-p", "w", "DEPRECATED. DO NOT USE. weight for phrase penalty");
|
||||
AddParam(deprec_opts,"weight-w", "w", "DEPRECATED. DO NOT USE. weight for word penalty");
|
||||
AddParam(deprec_opts,"weight-u", "u", "DEPRECATED. DO NOT USE. weight for unknown word penalty");
|
||||
AddParam(deprec_opts,"weight-e", "e", "DEPRECATED. DO NOT USE. weight for word deletion");
|
||||
AddParam(deprec_opts,"text-type", "DEPRECATED. DO NOT USE. should be one of dev/devtest/test, used for domain adaptation features");
|
||||
AddParam(deprec_opts,"input-scores", "DEPRECATED. DO NOT USE. 2 numbers on 2 lines - [1] of scores on each edge of a confusion network or lattice input (default=1). [2] Number of 'real' word scores (0 or 1. default=0)");
|
||||
AddParam(deprec_opts,"dlm-model", "DEPRECATED. DO NOT USE. Order, factor and vocabulary file for discriminative LM. Use * for filename to indicate unlimited vocabulary.");
|
||||
AddParam(deprec_opts,"generation-file", "DEPRECATED. DO NOT USE. location and properties of the generation table");
|
||||
AddParam(deprec_opts,"global-lexical-file", "gl", "DEPRECATED. DO NOT USE. discriminatively trained global lexical translation model file");
|
||||
AddParam(deprec_opts,"glm-feature", "DEPRECATED. DO NOT USE. discriminatively trained global lexical translation feature, sparse producer");
|
||||
AddParam(deprec_opts,"lmodel-file", "DEPRECATED. DO NOT USE. location and properties of the language models");
|
||||
AddParam(deprec_opts,"lmodel-dub", "DEPRECATED. DO NOT USE. dictionary upper bounds of language models");
|
||||
#ifdef HAVE_SYNLM
|
||||
AddParam("slmodel-file", "DEPRECATED. DO NOT USE. location of the syntactic language model file(s)");
|
||||
AddParam("slmodel-factor", "DEPRECATED. DO NOT USE. factor to use with syntactic language model");
|
||||
AddParam("slmodel-beam", "DEPRECATED. DO NOT USE. beam width to use with syntactic language model's parser");
|
||||
AddParam(deprec_opts,"slmodel-file", "DEPRECATED. DO NOT USE. location of the syntactic language model file(s)");
|
||||
AddParam(deprec_opts,"slmodel-factor", "DEPRECATED. DO NOT USE. factor to use with syntactic language model");
|
||||
AddParam(deprec_opts,"slmodel-beam", "DEPRECATED. DO NOT USE. beam width to use with syntactic language model's parser");
|
||||
#endif
|
||||
AddParam("ttable-file", "DEPRECATED. DO NOT USE. location and properties of the translation tables");
|
||||
AddParam("phrase-pair-feature", "DEPRECATED. DO NOT USE. Source and target factors for phrase pair feature");
|
||||
AddParam("phrase-boundary-source-feature", "DEPRECATED. DO NOT USE. Source factors for phrase boundary feature");
|
||||
AddParam("phrase-boundary-target-feature", "DEPRECATED. DO NOT USE. Target factors for phrase boundary feature");
|
||||
AddParam("phrase-length-feature", "DEPRECATED. DO NOT USE. Count features for source length, target length, both of each phrase");
|
||||
AddParam("target-word-insertion-feature", "DEPRECATED. DO NOT USE. Count feature for each unaligned target word");
|
||||
AddParam("source-word-deletion-feature", "DEPRECATED. DO NOT USE. Count feature for each unaligned source word");
|
||||
AddParam("word-translation-feature", "DEPRECATED. DO NOT USE. Count feature for word translation according to word alignment");
|
||||
AddParam(deprec_opts,"ttable-file", "DEPRECATED. DO NOT USE. location and properties of the translation tables");
|
||||
AddParam(deprec_opts,"phrase-pair-feature", "DEPRECATED. DO NOT USE. Source and target factors for phrase pair feature");
|
||||
AddParam(deprec_opts,"phrase-boundary-source-feature", "DEPRECATED. DO NOT USE. Source factors for phrase boundary feature");
|
||||
AddParam(deprec_opts,"phrase-boundary-target-feature", "DEPRECATED. DO NOT USE. Target factors for phrase boundary feature");
|
||||
AddParam(deprec_opts,"phrase-length-feature", "DEPRECATED. DO NOT USE. Count features for source length, target length, both of each phrase");
|
||||
AddParam(deprec_opts,"target-word-insertion-feature", "DEPRECATED. DO NOT USE. Count feature for each unaligned target word");
|
||||
AddParam(deprec_opts,"source-word-deletion-feature", "DEPRECATED. DO NOT USE. Count feature for each unaligned source word");
|
||||
AddParam(deprec_opts,"word-translation-feature", "DEPRECATED. DO NOT USE. Count feature for word translation according to word alignment");
|
||||
|
||||
AddParam("weight-file", "wf", "feature weights file. Do *not* put weights for 'core' features in here - they go in moses.ini");
|
||||
po::options_description zombie_opts("Zombie Options");
|
||||
AddParam(zombie_opts,"distortion-file", "source factors (0 if table independent of source), target factors, location of the factorized/lexicalized reordering tables");
|
||||
|
||||
AddParam("weight", "weights for ALL models, 1 per line 'WeightName value'. Weight names can be repeated");
|
||||
AddParam("weight-overwrite", "special parameter for mert. All on 1 line. Overrides weights specified in 'weights' argument");
|
||||
AddParam("feature-overwrite", "Override arguments in a particular feature function with a particular key. Format: -feature-overwrite \"FeatureName key=value\"");
|
||||
AddParam("weight-add", "Add weight for FF if it doesn't exist, i.e weights here are added 1st, and can be override by the ini file or on the command line. Used to specify initial weights for FF that was also specified on the copmmand line");
|
||||
AddParam("feature-add", "Add a feature function on the command line. Used by mira to add BLEU feature");
|
||||
AddParam("feature-name-overwrite", "Override feature name (NOT arguments). Eg. SRILM-->KENLM, PhraseDictionaryMemory-->PhraseDictionaryScope3");
|
||||
|
||||
AddParam("feature", "All the feature functions should be here");
|
||||
mbr_opts.add(lmbr_opts);
|
||||
search_opts.add(cube_opts);
|
||||
search_opts.add(mbr_opts);
|
||||
search_opts.add(disto_opts);
|
||||
search_opts.add(chart_opts);
|
||||
|
||||
AddParam("print-id", "prefix translations with id. Default if false");
|
||||
input_opts.add(spe_opts);
|
||||
|
||||
AddParam("print-passthrough", "output the sgml tag <passthrough> without any computation on that. Default is false");
|
||||
AddParam("print-passthrough-in-n-best", "output the sgml tag <passthrough> without any computation on that in each entry of the n-best-list. Default is false");
|
||||
output_opts.add(nbest_opts);
|
||||
output_opts.add(osg_opts);
|
||||
|
||||
AddParam("alternate-weight-setting", "aws", "alternate set of weights to used per xml specification");
|
||||
m_options.add(main_opts);
|
||||
m_options.add(server_opts);
|
||||
m_options.add(input_opts);
|
||||
m_options.add(search_opts);
|
||||
m_options.add(output_opts);
|
||||
m_options.add(oov_opts);
|
||||
m_options.add(factor_opts);
|
||||
m_options.add(cpt_opts);
|
||||
m_options.add(irstlm_opts);
|
||||
m_options.add(tune_opts);
|
||||
m_options.add(misc_opts);
|
||||
m_options.add(deprec_opts);
|
||||
m_options.add(zombie_opts);
|
||||
|
||||
AddParam("placeholder-factor", "Which source factor to use to store the original text for placeholders. The factor must not be used by a translation or gen model");
|
||||
AddParam("no-cache", "Disable all phrase-table caching. Default = false (ie. enable caching)");
|
||||
AddParam("default-non-term-for-empty-range-only", "Don't add [X] to all ranges, just ranges where there isn't a source non-term. Default = false (ie. add [X] everywhere)");
|
||||
AddParam("s2t-parsing-algorithm", "Which S2T parsing algorithm to use. 0=recursive CYK+, 1=scope-3 (default = 0)");
|
||||
|
||||
AddParam("spe-src", "Simulated post-editing. Source filename");
|
||||
AddParam("spe-trg", "Simulated post-editing. Target filename");
|
||||
AddParam("spe-aln", "Simulated post-editing. Alignment filename");
|
||||
|
||||
AddParam("server", "Run moses as a translation server.");
|
||||
AddParam("server-port", "Port for moses server");
|
||||
AddParam("server-log", "Log destination for moses server");
|
||||
AddParam("serial", "Run server in serial mode, processing only one request at a time.");
|
||||
}
|
||||
|
||||
Parameter::~Parameter()
|
||||
@ -238,41 +341,65 @@ const PARAM_VEC *Parameter::GetParam(const std::string ¶mName) const
|
||||
}
|
||||
|
||||
/** initialize a parameter, sub of constructor */
|
||||
void Parameter::AddParam(const string ¶mName, const string &description)
|
||||
void
|
||||
Parameter::
|
||||
AddParam(po::options_description& optgroup,
|
||||
string const& paramName,
|
||||
string const& description)
|
||||
{
|
||||
m_valid[paramName] = true;
|
||||
m_description[paramName] = description;
|
||||
optgroup.add_options()(paramName.c_str(), description.c_str());
|
||||
}
|
||||
|
||||
/** initialize a parameter (including abbreviation), sub of constructor */
|
||||
void Parameter::AddParam(const string ¶mName, const string &abbrevName, const string &description)
|
||||
void
|
||||
Parameter::
|
||||
AddParam(po::options_description& optgroup,
|
||||
string const& paramName,
|
||||
string const& abbrevName,
|
||||
string const& description)
|
||||
{
|
||||
m_valid[paramName] = true;
|
||||
m_valid[abbrevName] = true;
|
||||
m_abbreviation[paramName] = abbrevName;
|
||||
m_fullname[abbrevName] = paramName;
|
||||
m_description[paramName] = description;
|
||||
string optname = paramName;
|
||||
if (abbrevName.size() == 1)
|
||||
{
|
||||
optname += string(",")+abbrevName;
|
||||
// m_confusable[abbrevName[0]].insert(paramName);
|
||||
}
|
||||
optgroup.add_options()(optname.c_str(),description.c_str());
|
||||
}
|
||||
|
||||
/** print descriptions of all parameters */
|
||||
void Parameter::Explain()
|
||||
void
|
||||
Parameter::
|
||||
Explain()
|
||||
{
|
||||
cerr << "Usage:" << endl;
|
||||
for(PARAM_STRING::const_iterator iterParam = m_description.begin(); iterParam != m_description.end(); iterParam++) {
|
||||
const string paramName = iterParam->first;
|
||||
const string paramDescription = iterParam->second;
|
||||
cerr << "\t-" << paramName;
|
||||
PARAM_STRING::const_iterator iterAbbr = m_abbreviation.find( paramName );
|
||||
if ( iterAbbr != m_abbreviation.end() )
|
||||
cerr << " (" << iterAbbr->second << ")";
|
||||
cerr << ": " << paramDescription << endl;
|
||||
}
|
||||
cerr << m_options << endl;
|
||||
// for(PARAM_STRING::const_iterator iterParam = m_description.begin();
|
||||
// iterParam != m_description.end(); iterParam++)
|
||||
// {
|
||||
// const string paramName = iterParam->first;
|
||||
// const string paramDescription = iterParam->second;
|
||||
// cerr << "\t-" << paramName;
|
||||
// PARAM_STRING::const_iterator iterAbbr = m_abbreviation.find( paramName );
|
||||
// if ( iterAbbr != m_abbreviation.end() )
|
||||
// cerr << " (" << iterAbbr->second << ")";
|
||||
// cerr << ": " << paramDescription << endl;
|
||||
// }
|
||||
}
|
||||
|
||||
/** check whether an item on the command line is a switch or a value
|
||||
* \param token token on the command line to checked **/
|
||||
|
||||
bool Parameter::isOption(const char* token)
|
||||
bool
|
||||
Parameter::
|
||||
isOption(const char* token)
|
||||
{
|
||||
if (! token) return false;
|
||||
std::string tokenString(token);
|
||||
@ -284,14 +411,18 @@ bool Parameter::isOption(const char* token)
|
||||
}
|
||||
|
||||
/** load all parameters from the configuration file and the command line switches */
|
||||
bool Parameter::LoadParam(const string &filePath)
|
||||
bool
|
||||
Parameter::
|
||||
LoadParam(const string &filePath)
|
||||
{
|
||||
const char *argv[] = {"executable", "-f", filePath.c_str() };
|
||||
return LoadParam(3, (char**) argv);
|
||||
}
|
||||
|
||||
/** load all parameters from the configuration file and the command line switches */
|
||||
bool Parameter::LoadParam(int argc, char* argv[])
|
||||
bool
|
||||
Parameter::
|
||||
LoadParam(int argc, char* argv[])
|
||||
{
|
||||
// config file (-f) arg mandatory
|
||||
string configPath;
|
||||
@ -391,7 +522,9 @@ bool Parameter::LoadParam(int argc, char* argv[])
|
||||
return Validate() && noErrorFlag;
|
||||
}
|
||||
|
||||
void Parameter::AddFeaturesCmd()
|
||||
void
|
||||
Parameter::
|
||||
AddFeaturesCmd()
|
||||
{
|
||||
const PARAM_VEC *params = GetParam("feature-add");
|
||||
if (params) {
|
||||
@ -405,7 +538,9 @@ void Parameter::AddFeaturesCmd()
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<float> Parameter::GetWeights(const std::string &name)
|
||||
std::vector<float>
|
||||
Parameter::
|
||||
GetWeights(const std::string &name)
|
||||
{
|
||||
std::vector<float> ret = m_weights[name];
|
||||
|
||||
@ -417,7 +552,9 @@ std::vector<float> Parameter::GetWeights(const std::string &name)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Parameter::SetWeight(const std::string &name, size_t ind, float weight)
|
||||
void
|
||||
Parameter::
|
||||
SetWeight(const std::string &name, size_t ind, float weight)
|
||||
{
|
||||
PARAM_VEC &newWeights = m_setting["weight"];
|
||||
string line = name + SPrint(ind) + "= " + SPrint(weight);
|
||||
@ -458,7 +595,9 @@ AddWeight(const std::string &name, size_t ind,
|
||||
SetWeight(name, ind, weights);
|
||||
}
|
||||
|
||||
void Parameter::ConvertWeightArgsSingleWeight(const string &oldWeightName, const string &newWeightName)
|
||||
void
|
||||
Parameter::
|
||||
ConvertWeightArgsSingleWeight(const string &oldWeightName, const string &newWeightName)
|
||||
{
|
||||
size_t ind = 0;
|
||||
PARAM_MAP::iterator iterMap;
|
||||
@ -474,7 +613,9 @@ void Parameter::ConvertWeightArgsSingleWeight(const string &oldWeightName, const
|
||||
}
|
||||
}
|
||||
|
||||
void Parameter::ConvertWeightArgsPhraseModel(const string &oldWeightName)
|
||||
void
|
||||
Parameter::
|
||||
ConvertWeightArgsPhraseModel(const string &oldWeightName)
|
||||
{
|
||||
const PARAM_VEC *params;
|
||||
|
||||
@ -645,13 +786,17 @@ void Parameter::ConvertWeightArgsPhraseModel(const string &oldWeightName)
|
||||
|
||||
}
|
||||
|
||||
void Parameter::AddFeature(const std::string &line)
|
||||
void
|
||||
Parameter::
|
||||
AddFeature(const std::string &line)
|
||||
{
|
||||
PARAM_VEC &features = m_setting["feature"];
|
||||
features.push_back(line);
|
||||
}
|
||||
|
||||
void Parameter::ConvertWeightArgsDistortion()
|
||||
void
|
||||
Parameter::
|
||||
ConvertWeightArgsDistortion()
|
||||
{
|
||||
const string oldWeightName = "weight-d";
|
||||
const string oldLexReordingName = "distortion-file";
|
||||
@ -716,7 +861,9 @@ void Parameter::ConvertWeightArgsDistortion()
|
||||
|
||||
}
|
||||
|
||||
void Parameter::ConvertWeightArgsLM()
|
||||
void
|
||||
Parameter::
|
||||
ConvertWeightArgsLM()
|
||||
{
|
||||
const string oldWeightName = "weight-l";
|
||||
const string oldFeatureName = "lmodel-file";
|
||||
@ -808,7 +955,9 @@ void Parameter::ConvertWeightArgsLM()
|
||||
m_setting.erase(oldFeatureName);
|
||||
}
|
||||
|
||||
void Parameter::ConvertWeightArgsGeneration(const std::string &oldWeightName, const std::string &newWeightName)
|
||||
void
|
||||
Parameter::
|
||||
ConvertWeightArgsGeneration(const std::string &oldWeightName, const std::string &newWeightName)
|
||||
{
|
||||
string oldFeatureName = "generation-file";
|
||||
|
||||
@ -850,7 +999,9 @@ void Parameter::ConvertWeightArgsGeneration(const std::string &oldWeightName, co
|
||||
m_setting.erase(oldFeatureName);
|
||||
}
|
||||
|
||||
void Parameter::ConvertWeightArgsWordPenalty()
|
||||
void
|
||||
Parameter::
|
||||
ConvertWeightArgsWordPenalty()
|
||||
{
|
||||
const std::string oldWeightName = "weight-w";
|
||||
const std::string newWeightName = "WordPenalty";
|
||||
@ -883,7 +1034,9 @@ void Parameter::ConvertWeightArgsWordPenalty()
|
||||
|
||||
}
|
||||
|
||||
void Parameter::ConvertPhrasePenalty()
|
||||
void
|
||||
Parameter::
|
||||
ConvertPhrasePenalty()
|
||||
{
|
||||
string oldWeightName = "weight-p";
|
||||
const PARAM_VEC *params = GetParam(oldWeightName);
|
||||
@ -898,7 +1051,9 @@ void Parameter::ConvertPhrasePenalty()
|
||||
}
|
||||
}
|
||||
|
||||
void Parameter::ConvertWeightArgs()
|
||||
void
|
||||
Parameter::
|
||||
ConvertWeightArgs()
|
||||
{
|
||||
// can't handle discr LM. must do it manually 'cos of bigram/n-gram split
|
||||
UTIL_THROW_IF2( m_setting.count("weight-dlm") != 0,
|
||||
@ -940,13 +1095,17 @@ void Parameter::ConvertWeightArgs()
|
||||
|
||||
}
|
||||
|
||||
void Parameter::CreateWeightsMap()
|
||||
void
|
||||
Parameter::
|
||||
CreateWeightsMap()
|
||||
{
|
||||
CreateWeightsMap(m_setting["weight-add"]);
|
||||
CreateWeightsMap(m_setting["weight"]);
|
||||
}
|
||||
|
||||
void Parameter::CreateWeightsMap(const PARAM_VEC &vec)
|
||||
void
|
||||
Parameter::
|
||||
CreateWeightsMap(const PARAM_VEC &vec)
|
||||
{
|
||||
for (size_t i = 0; i < vec.size(); ++i) {
|
||||
const string &line = vec[i];
|
||||
@ -966,7 +1125,9 @@ void Parameter::CreateWeightsMap(const PARAM_VEC &vec)
|
||||
}
|
||||
}
|
||||
|
||||
void Parameter::WeightOverwrite()
|
||||
void
|
||||
Parameter::
|
||||
WeightOverwrite()
|
||||
{
|
||||
PARAM_VEC &vec = m_setting["weight-overwrite"];
|
||||
|
||||
@ -1023,7 +1184,9 @@ void Parameter::WeightOverwrite()
|
||||
}
|
||||
|
||||
/** check that parameter settings make sense */
|
||||
bool Parameter::Validate()
|
||||
bool
|
||||
Parameter::
|
||||
Validate()
|
||||
{
|
||||
bool noErrorFlag = true;
|
||||
|
||||
@ -1082,7 +1245,10 @@ bool Parameter::Validate()
|
||||
}
|
||||
|
||||
/** check whether a file exists */
|
||||
bool Parameter::FilesExist(const string ¶mName, int fieldNo, std::vector<std::string> const& extensions)
|
||||
bool
|
||||
Parameter::
|
||||
FilesExist(const string ¶mName, int fieldNo,
|
||||
std::vector<std::string> const& extensions)
|
||||
{
|
||||
typedef std::vector<std::string> StringVec;
|
||||
StringVec::const_iterator iter;
|
||||
@ -1125,7 +1291,9 @@ bool Parameter::FilesExist(const string ¶mName, int fieldNo, std::vector<std
|
||||
/** look for a switch in arg, update parameter */
|
||||
// TODO arg parsing like this does not belong in the library, it belongs
|
||||
// in moses-cmd
|
||||
string Parameter::FindParam(const string ¶mSwitch, int argc, char* argv[])
|
||||
string
|
||||
Parameter::
|
||||
FindParam(const string ¶mSwitch, int argc, char* argv[])
|
||||
{
|
||||
for (int i = 0 ; i < argc ; i++) {
|
||||
if (string(argv[i]) == paramSwitch) {
|
||||
@ -1145,7 +1313,9 @@ string Parameter::FindParam(const string ¶mSwitch, int argc, char* argv[])
|
||||
* \param paramName full name of parameter
|
||||
* \param argc number of arguments on command line
|
||||
* \param argv values of paramters on command line */
|
||||
void Parameter::OverwriteParam(const string ¶mSwitch, const string ¶mName, int argc, char* argv[])
|
||||
void
|
||||
Parameter::
|
||||
OverwriteParam(const string ¶mSwitch, const string ¶mName, int argc, char* argv[])
|
||||
{
|
||||
int startPos = -1;
|
||||
for (int i = 0 ; i < argc ; i++) {
|
||||
@ -1171,7 +1341,9 @@ void Parameter::OverwriteParam(const string ¶mSwitch, const string ¶mNam
|
||||
|
||||
|
||||
/** read parameters from a configuration file */
|
||||
bool Parameter::ReadConfigFile(const string &filePath )
|
||||
bool
|
||||
Parameter::
|
||||
ReadConfigFile(const string &filePath )
|
||||
{
|
||||
InputFileStream inFile(filePath);
|
||||
string line, paramName;
|
||||
@ -1239,7 +1411,9 @@ std::ostream& operator<<(std::ostream &os, const Credit &credit)
|
||||
return os;
|
||||
}
|
||||
|
||||
void Parameter::PrintCredit()
|
||||
void
|
||||
Parameter::
|
||||
PrintCredit()
|
||||
{
|
||||
vector<Credit> everyone;
|
||||
srand ( time(NULL) );
|
||||
@ -1327,7 +1501,9 @@ void Parameter::PrintCredit()
|
||||
/** update parameter settings with command line switches
|
||||
* \param paramName full name of parameter
|
||||
* \param values inew values for paramName */
|
||||
void Parameter::OverwriteParam(const string ¶mName, PARAM_VEC values)
|
||||
void
|
||||
Parameter::
|
||||
OverwriteParam(const string ¶mName, PARAM_VEC values)
|
||||
{
|
||||
VERBOSE(2,"Overwriting parameter " << paramName);
|
||||
|
||||
@ -1350,12 +1526,16 @@ void Parameter::OverwriteParam(const string ¶mName, PARAM_VEC values)
|
||||
VERBOSE(2, std::endl);
|
||||
}
|
||||
|
||||
void Parameter::PrintFF() const
|
||||
void
|
||||
Parameter::
|
||||
PrintFF() const
|
||||
{
|
||||
StaticData::Instance().GetFeatureRegistry().PrintFF();
|
||||
}
|
||||
|
||||
std::set<std::string> Parameter::GetWeightNames() const
|
||||
std::set<std::string>
|
||||
Parameter::
|
||||
GetWeightNames() const
|
||||
{
|
||||
std::set<std::string> ret;
|
||||
std::map<std::string, std::vector<float> >::const_iterator iter;
|
||||
@ -1366,7 +1546,9 @@ std::set<std::string> Parameter::GetWeightNames() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Parameter::Save(const std::string path)
|
||||
void
|
||||
Parameter::
|
||||
Save(const std::string path)
|
||||
{
|
||||
ofstream file;
|
||||
file.open(path.c_str());
|
||||
@ -1392,7 +1574,10 @@ void Parameter::Save(const std::string path)
|
||||
}
|
||||
|
||||
template<>
|
||||
void Parameter::SetParameter<bool>(bool ¶meter, const std::string ¶meterName, const bool &defaultValue) const
|
||||
void
|
||||
Parameter::
|
||||
SetParameter<bool>(bool ¶meter, std::string const& parameterName,
|
||||
bool const& defaultValue) const
|
||||
{
|
||||
const PARAM_VEC *params = GetParam(parameterName);
|
||||
|
||||
|
@ -28,10 +28,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include <vector>
|
||||
#include "TypeDef.h"
|
||||
#include "Util.h"
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
typedef std::vector<std::string> PARAM_VEC;
|
||||
typedef std::map<std::string, PARAM_VEC > PARAM_MAP;
|
||||
typedef std::map<std::string, bool> PARAM_BOOL;
|
||||
@ -43,12 +43,17 @@ typedef std::map<std::string, std::string > PARAM_STRING;
|
||||
*/
|
||||
class Parameter
|
||||
{
|
||||
typedef boost::program_options::options_description options_description;
|
||||
typedef boost::program_options::value_semantic value_semantic;
|
||||
protected:
|
||||
PARAM_MAP m_setting;
|
||||
PARAM_BOOL m_valid;
|
||||
PARAM_STRING m_abbreviation;
|
||||
PARAM_STRING m_description;
|
||||
PARAM_STRING m_fullname;
|
||||
// std::map<char,std::set<std::string> > m_confusable;
|
||||
// stores long parameter names that start with a letter that is also a short option.
|
||||
options_description m_options;
|
||||
|
||||
std::map<std::string, std::vector<float> > m_weights;
|
||||
|
||||
@ -59,9 +64,30 @@ protected:
|
||||
bool isOption(const char* token);
|
||||
bool Validate();
|
||||
|
||||
void AddParam(const std::string ¶mName, const std::string &description);
|
||||
void AddParam(const std::string ¶mName, const std::string &abbrevName, const std::string &description);
|
||||
void
|
||||
AddParam(options_description& optgroup,
|
||||
value_semantic const* optvalue,
|
||||
std::string const& paramName,
|
||||
std::string const& description);
|
||||
|
||||
void
|
||||
AddParam(options_description& optgroup,
|
||||
std::string const ¶mName,
|
||||
std::string const &description);
|
||||
|
||||
void
|
||||
AddParam(options_description& optgroup,
|
||||
value_semantic const* optvalue,
|
||||
std::string const& paramName,
|
||||
std::string const& abbrevName,
|
||||
std::string const& description);
|
||||
|
||||
void
|
||||
AddParam(options_description& optgroup,
|
||||
std::string const& paramName,
|
||||
std::string const& abbrevName,
|
||||
std::string const& description);
|
||||
|
||||
void PrintCredit();
|
||||
void PrintFF() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user