static void learn_option_finish(learn_option_t* opt) { int i; free(opt->model); for (i = 0;i < opt->num_params;++i) { free(opt->params[i]); } free(opt->params); } BEGIN_OPTION_MAP(parse_learn_options, learn_option_t) ON_OPTION_WITH_ARG(SHORTOPT('t') || LONGOPT("type")) if (strcmp(arg, "1d") == 0) { free(opt->type); opt->type = mystrdup("crf1d"); } else { fprintf(stderr, "ERROR: Unknown graphical model: %s\n", arg); return 1; } ON_OPTION_WITH_ARG(SHORTOPT('a') || LONGOPT("algorithm")) if (strcmp(arg, "lbfgs") == 0) { free(opt->algorithm); opt->algorithm = mystrdup("lbfgs"); } else if (strcmp(arg, "l2sgd") == 0) { free(opt->algorithm); opt->algorithm = mystrdup("l2sgd");
static void tagger_option_finish(tagger_option_t* opt) { int i; free(opt->input); free(opt->model); for (i = 0;i < opt->num_params;++i) { free(opt->params[i]); } free(opt->params); } BEGIN_OPTION_MAP(parse_tagger_options, tagger_option_t) ON_OPTION_WITH_ARG(SHORTOPT('m') || LONGOPT("model")) free(opt->model); opt->model = mystrdup(arg); ON_OPTION(SHORTOPT('t') || LONGOPT("test")) opt->evaluate = 1; ON_OPTION(SHORTOPT('r') || LONGOPT("reference")) opt->reference = 1; ON_OPTION(SHORTOPT('p') || LONGOPT("probability")) opt->probability = 1; ON_OPTION(SHORTOPT('i') || LONGOPT("marginal")) opt->marginal = 1;
{ int i; free(opt->model); free(opt->training); free(opt->evaluation); for (i = 0;i < opt->num_params;++i) { free(opt->params[i]); } free(opt->params); } BEGIN_OPTION_MAP(parse_learn_options, learn_option_t) ON_OPTION_WITH_ARG(SHORTOPT('m') || LONGOPT("model")) free(opt->model); opt->model = mystrdup(arg); ON_OPTION_WITH_ARG(SHORTOPT('t') || LONGOPT("test")) free(opt->evaluation); opt->evaluation = mystrdup(arg); ON_OPTION(SHORTOPT('h') || LONGOPT("help")) opt->help = 1; ON_OPTION_WITH_ARG(SHORTOPT('p') || LONGOPT("param")) opt->params = (char **)realloc(opt->params, sizeof(char*) * (opt->num_params + 1)); opt->params[opt->num_params] = mystrdup(arg); ++opt->num_params;
FILE *fpo; FILE *fpe; } option_t; static void option_init(option_t* opt) { memset(opt, 0, sizeof(*opt)); } static void option_finish(option_t* opt) { } BEGIN_OPTION_MAP(parse_options, option_t) ON_OPTION(SHORTOPT('h') || LONGOPT("help")) opt->help = 1; END_OPTION_MAP() static void show_usage(FILE *fp, const char *argv0) { fprintf(fp, "USAGE: %s <COMMAND> [OPTIONS]\n", argv0); fprintf(fp, " COMMAND Command name to specify the processing\n"); fprintf(fp, " OPTIONS Arguments for the command (optional; command-specific)\n"); fprintf(fp, "\n"); fprintf(fp, "COMMAND:\n"); fprintf(fp, " learn Obtain a model from a training set of instances\n"); fprintf(fp, " tag Assign suitable labels to given instances by using a model\n"); fprintf(fp, " dump Output a model in a plain-text format\n"); fprintf(fp, "\n");
static void tagger_option_finish(tagger_option_t* opt) { int i; free(opt->input); free(opt->model); for (i = 0; i < opt->num_params; ++i) { free(opt->params[i]); } free(opt->params); } BEGIN_OPTION_MAP(parse_tagger_options, tagger_option_t) ON_OPTION_WITH_ARG(SHORTOPT('m') || LONGOPT("model")) free(opt->model); opt->model = mystrdup(arg); ON_OPTION(SHORTOPT('t') || LONGOPT("test")) opt->evaluate = 1; ON_OPTION(SHORTOPT('r') || LONGOPT("reference")) opt->reference = 1; ON_OPTION(SHORTOPT('q') || LONGOPT("quiet")) opt->quiet = 1; ON_OPTION(SHORTOPT('h') || LONGOPT("help")) opt->help = 1;
static void tagger_option_finish(tagger_option_t* opt) { int i; free(opt->input); free(opt->model); for (i = 0;i < opt->num_params;++i) { free(opt->params[i]); } free(opt->params); } BEGIN_OPTION_MAP(parse_tagger_options, tagger_option_t) ON_OPTION_WITH_ARG(SHORTOPT('m') || LONGOPT("model")) free(opt->model); opt->model = mystrdup(arg); ON_OPTION_WITH_ARG(LONGOPT("type")) if (strncmp(arg, "tree", 5) == 0) opt->ftype = FTYPE_CRF1TREE; else if (strncmp(arg, "semim", 6) == 0) opt->ftype = FTYPE_SEMIMCRF; else if (strncmp(arg, "1d", 3) != 0) return -1; ON_OPTION(SHORTOPT('t') || LONGOPT("test")) opt->evaluate = 1; ON_OPTION(SHORTOPT('r') || LONGOPT("reference"))