Skip to content
Snippets Groups Projects
Commit e9ccdd69 authored by Alexis Nasr's avatar Alexis Nasr
Browse files

added an option to fplm2cff for specifying the file in which the feature dictionary will be written

parent 1b0ec83f
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ context *context_new(void)
ctx->fplm_filename = NULL;
ctx->language = strdup("fr");
ctx->maca_data_path = NULL;
ctx->features_filename = NULL;
return ctx;
}
......@@ -48,6 +49,7 @@ void context_fplm_help_message(context *ctx){
void context_language_help_message(context *ctx){
fprintf(stderr, "\t-L --language : identifier of the language to use\n");
}
void context_maca_data_path_help_message(context *ctx){
fprintf(stderr, "\t-M --maca_data_path : path to maca_data directory\n");
}
......@@ -56,6 +58,10 @@ void context_fm_help_message(context *ctx){
fprintf(stderr, "\t-F --fm <file> : feature model file name\n");
}
void context_features_filename_help_message(context *ctx){
fprintf(stderr, "\t-x --feat <file> : features dictionary file name\n");
}
context *context_read_options(int argc, char *argv[])
{
......@@ -65,7 +71,7 @@ context *context_read_options(int argc, char *argv[])
ctx->program_name = strdup(argv[0]);
static struct option long_options[8] =
static struct option long_options[9] =
{
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, 'v'},
......@@ -74,12 +80,13 @@ context *context_read_options(int argc, char *argv[])
{"language", required_argument, 0, 'L'},
{"fplm", required_argument, 0, 'f'},
{"maca_data_path", required_argument, 0, 'D'},
{"fm", required_argument, 0, 'F'}
{"fm", required_argument, 0, 'F'},
{"feat", required_argument, 0, 'x'}
};
optind = 0;
opterr = 0;
while ((c = getopt_long (argc, argv, "hvdf:L:M:D:F:", long_options, &option_index)) != -1){
while ((c = getopt_long (argc, argv, "hvdf:L:M:D:F:x:", long_options, &option_index)) != -1){
switch (c)
{
case 'd':
......@@ -103,6 +110,9 @@ context *context_read_options(int argc, char *argv[])
case 'F':
ctx->fm_filename = strdup(optarg);
break;
case 'x':
ctx->features_filename = strdup(optarg);
break;
}
}
......
......@@ -17,6 +17,7 @@ typedef struct {
char *language;
char *maca_data_path;
char *fm_filename;
char *features_filename;
} context;
......@@ -26,12 +27,8 @@ void context_free(context *ctx);
context *context_read_options(int argc, char *argv[]);
void context_general_help_message(context *ctx);
void context_conll_help_message(context *ctx);
void context_language_help_message(context *ctx);
void context_fplm_help_message(context *ctx);
void context_maca_data_path_help_message(context *ctx);
void context_mcd_help_message(context *ctx);
void context_form_column_help_message(context *ctx);
void context_pos_column_help_message(context *ctx);
void context_features_filename_help_message(context *ctx);
#endif
......@@ -49,6 +49,14 @@ feat_vec *form2fv(char *form, feat_vec *fv, feat_model *fm, dico *dico_features)
int main(int argc, char *argv[])
{
context *ctx = context_read_options(argc, argv);
if(ctx->help){
context_general_help_message(ctx);
context_language_help_message(ctx);
context_fplm_help_message(ctx);
context_maca_data_path_help_message(ctx);
context_features_filename_help_message(ctx);
exit(1);
}
feat_vec *fv = feat_vec_new(10);
dico *dico_features = dico_new("dico_features", 1000);
feat_model *fm = feat_model_read(ctx->fm_filename, feat_lib_build(), ctx->verbose);
......@@ -61,7 +69,8 @@ int main(int argc, char *argv[])
feat_vec_print(stdout, fv);
}
/* dico_print_fh(stdout, dico_features); */
dico_print("xx", dico_features);
if(ctx->features_filename)
dico_print(ctx->features_filename, dico_features);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment