Commit f9233876 authored by Alexis Nasr's avatar Alexis Nasr
Browse files

bug fixing in maca_trans_parser_conll2fann

parent bbb0919c
...@@ -333,105 +333,4 @@ context *context_read_options(int argc, char *argv[]) ...@@ -333,105 +333,4 @@ context *context_read_options(int argc, char *argv[])
return ctx; return ctx;
} }
void context_set_linguistic_resources_filenames_parser(context *ctx)
{
char absolute_path[500];
char absolute_filename[500];
absolute_path[0] = '\0';
if(ctx->maca_data_path)
strcat(absolute_path, ctx->maca_data_path);
else
strcat(absolute_path, getenv("MACAON_DIR"));
strcat(absolute_path, "/");
strcat(absolute_path, ctx->language);
strcat(absolute_path, "/bin/");
if(!ctx->perc_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_MODEL_FILENAME);
ctx->perc_model_filename = strdup(absolute_filename);
}
if(!ctx->vocabs_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_VOCABS_FILENAME);
ctx->vocabs_filename = strdup(absolute_filename);
}
/* if(!ctx->mcd_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_MULTI_COL_DESC_FILENAME);
ctx->mcd_filename = strdup(absolute_filename);
}*/
if(!ctx->features_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_FEATURES_MODEL_FILENAME);
ctx->features_model_filename = strdup(absolute_filename);
}
fprintf(stderr, "perc_model_filename = %s\n", ctx->perc_model_filename);
fprintf(stderr, "vocabs_filename = %s\n", ctx->vocabs_filename);
fprintf(stderr, "mcd_filename = %s\n", ctx->mcd_filename);
fprintf(stderr, "perc_features_model_filename = %s\n", ctx->features_model_filename);
}
void context_set_linguistic_resources_filenames_tagger(context *ctx)
{
char absolute_path[500];
char absolute_filename[500];
absolute_path[0] = '\0';
if(ctx->maca_data_path)
strcat(absolute_path, ctx->maca_data_path);
else
strcat(absolute_path, getenv("MACAON_DIR"));
strcat(absolute_path, "/");
strcat(absolute_path, ctx->language);
strcat(absolute_path, "/bin/");
if(!ctx->perc_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_MODEL_TAGGER_FILENAME);
ctx->perc_model_filename = strdup(absolute_filename);
}
if(!ctx->vocabs_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_VOCABS_TAGGER_FILENAME);
ctx->vocabs_filename = strdup(absolute_filename);
}
/* if(!ctx->mcd_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_MULTI_COL_DESC_TAGGER_FILENAME);
ctx->mcd_filename = strdup(absolute_filename);
}*/
if(!ctx->features_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_FEATURES_MODEL_TAGGER_FILENAME);
ctx->features_model_filename = strdup(absolute_filename);
}
if(!ctx->f2p_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_F2P_FILENAME);
ctx->f2p_filename = strdup(absolute_filename);
ctx->f2p = form2pos_read(ctx->f2p_filename);
}
fprintf(stderr, "perc_model_filename = %s\n", ctx->perc_model_filename);
fprintf(stderr, "vocabs_filename = %s\n", ctx->vocabs_filename);
fprintf(stderr, "mcd_filename = %s\n", ctx->mcd_filename);
fprintf(stderr, "perc_features_model_filename = %s\n", ctx->features_model_filename);
fprintf(stderr, "f2p_filename = %s\n", ctx->f2p_filename);
}
...@@ -93,10 +93,4 @@ void context_maca_data_path_help_message(context *ctx); ...@@ -93,10 +93,4 @@ void context_maca_data_path_help_message(context *ctx);
void context_f2p_filename_help_message(context *ctx); void context_f2p_filename_help_message(context *ctx);
void context_set_linguistic_resources_filenames_tagger(context *ctx);
void context_set_linguistic_resources_filenames_parser(context *ctx);
#endif #endif
...@@ -42,6 +42,54 @@ void decode_check_options(context *ctx){ ...@@ -42,6 +42,54 @@ void decode_check_options(context *ctx){
} }
} }
void set_linguistic_resources_filenames_parser(context *ctx)
{
char absolute_path[500];
char absolute_filename[500];
absolute_path[0] = '\0';
if(ctx->maca_data_path)
strcat(absolute_path, ctx->maca_data_path);
else
strcat(absolute_path, getenv("MACAON_DIR"));
strcat(absolute_path, "/");
strcat(absolute_path, ctx->language);
strcat(absolute_path, "/bin/");
if(!ctx->perc_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_MODEL_FILENAME);
ctx->perc_model_filename = strdup(absolute_filename);
}
if(!ctx->vocabs_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_VOCABS_FILENAME);
ctx->vocabs_filename = strdup(absolute_filename);
}
/* if(!ctx->mcd_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_MULTI_COL_DESC_FILENAME);
ctx->mcd_filename = strdup(absolute_filename);
}*/
if(!ctx->features_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_FEATURES_MODEL_FILENAME);
ctx->features_model_filename = strdup(absolute_filename);
}
fprintf(stderr, "perc_model_filename = %s\n", ctx->perc_model_filename);
fprintf(stderr, "vocabs_filename = %s\n", ctx->vocabs_filename);
fprintf(stderr, "mcd_filename = %s\n", ctx->mcd_filename);
fprintf(stderr, "perc_features_model_filename = %s\n", ctx->features_model_filename);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FILE *conll_file = NULL; FILE *conll_file = NULL;
...@@ -53,7 +101,7 @@ int main(int argc, char *argv[]) ...@@ -53,7 +101,7 @@ int main(int argc, char *argv[])
ctx = context_read_options(argc, argv); ctx = context_read_options(argc, argv);
decode_check_options(ctx); decode_check_options(ctx);
context_set_linguistic_resources_filenames_parser(ctx); set_linguistic_resources_filenames_parser(ctx);
ctx->features_model = feat_model_read(ctx->features_model_filename); ctx->features_model = feat_model_read(ctx->features_model_filename);
ctx->vocabs = dico_vec_read(ctx->vocabs_filename, ctx->hash_ratio); ctx->vocabs = dico_vec_read(ctx->vocabs_filename, ctx->hash_ratio);
......
...@@ -42,6 +42,64 @@ void decode_check_options(context *ctx){ ...@@ -42,6 +42,64 @@ void decode_check_options(context *ctx){
} }
} }
void set_linguistic_resources_filenames_tagger(context *ctx)
{
char absolute_path[500];
char absolute_filename[500];
absolute_path[0] = '\0';
if(ctx->maca_data_path)
strcat(absolute_path, ctx->maca_data_path);
else
strcat(absolute_path, getenv("MACAON_DIR"));
strcat(absolute_path, "/");
strcat(absolute_path, ctx->language);
strcat(absolute_path, "/bin/");
if(!ctx->perc_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_MODEL_TAGGER_FILENAME);
ctx->perc_model_filename = strdup(absolute_filename);
}
if(!ctx->vocabs_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_VOCABS_TAGGER_FILENAME);
ctx->vocabs_filename = strdup(absolute_filename);
}
/* if(!ctx->mcd_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_MULTI_COL_DESC_TAGGER_FILENAME);
ctx->mcd_filename = strdup(absolute_filename);
}*/
if(!ctx->features_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_FEATURES_MODEL_TAGGER_FILENAME);
ctx->features_model_filename = strdup(absolute_filename);
}
if(!ctx->f2p_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, DEFAULT_F2P_FILENAME);
ctx->f2p_filename = strdup(absolute_filename);
ctx->f2p = form2pos_read(ctx->f2p_filename);
}
fprintf(stderr, "perc_model_filename = %s\n", ctx->perc_model_filename);
fprintf(stderr, "vocabs_filename = %s\n", ctx->vocabs_filename);
fprintf(stderr, "mcd_filename = %s\n", ctx->mcd_filename);
fprintf(stderr, "perc_features_model_filename = %s\n", ctx->features_model_filename);
fprintf(stderr, "f2p_filename = %s\n", ctx->f2p_filename);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FILE *conll_file = NULL; FILE *conll_file = NULL;
...@@ -50,7 +108,7 @@ int main(int argc, char *argv[]) ...@@ -50,7 +108,7 @@ int main(int argc, char *argv[])
ctx = context_read_options(argc, argv); ctx = context_read_options(argc, argv);
decode_check_options(ctx); decode_check_options(ctx);
context_set_linguistic_resources_filenames_tagger(ctx); set_linguistic_resources_filenames_tagger(ctx);
ctx->features_model = feat_model_read(ctx->features_model_filename); ctx->features_model = feat_model_read(ctx->features_model_filename);
ctx->vocabs = dico_vec_read(ctx->vocabs_filename, ctx->hash_ratio); ctx->vocabs = dico_vec_read(ctx->vocabs_filename, ctx->hash_ratio);
mcd_link_to_dico(ctx->mcd_struct, ctx->vocabs); mcd_link_to_dico(ctx->mcd_struct, ctx->vocabs);
......
...@@ -27,13 +27,13 @@ void transform_treebank_help_message(context *ctx) ...@@ -27,13 +27,13 @@ void transform_treebank_help_message(context *ctx)
context_mcd_help_message(ctx); context_mcd_help_message(ctx);
context_features_model_help_message(ctx); context_features_model_help_message(ctx);
fprintf(stderr, "IN TEST MODE\n"); fprintf(stderr, "IN TEST MODE\n");
context_alphabet_help_message(ctx); context_vocabs_help_message(ctx);
fprintf(stderr, "OUTPUT\n"); fprintf(stderr, "OUTPUT\n");
context_cff_help_message(ctx); context_cff_help_message(ctx);
context_fann_help_message(ctx); context_fann_help_message(ctx);
fprintf(stderr, "IN TRAIN MODE\n"); fprintf(stderr, "IN TRAIN MODE\n");
context_alphabet_help_message(ctx); context_vocabs_help_message(ctx);
} }
...@@ -140,6 +140,8 @@ int main(int argc, char *argv[]) ...@@ -140,6 +140,8 @@ int main(int argc, char *argv[])
ctx = context_read_options(argc, argv); ctx = context_read_options(argc, argv);
transform_treebank_check_options(ctx); transform_treebank_check_options(ctx);
ctx->features_model = feat_model_read(ctx->features_model_filename);
if(ctx->mode == TRAIN_MODE){ if(ctx->mode == TRAIN_MODE){
mcd_extract_dico_from_corpus(ctx->mcd_struct, ctx->conll_filename); mcd_extract_dico_from_corpus(ctx->mcd_struct, ctx->conll_filename);
...@@ -176,6 +178,15 @@ int main(int argc, char *argv[]) ...@@ -176,6 +178,15 @@ int main(int argc, char *argv[])
fprintf(output_file, "%d", nb_trans); fprintf(output_file, "%d", nb_trans);
fclose(output_file); fclose(output_file);
if(ctx->mode == TRAIN_MODE){
/* dico_print(ctx->perceptron_features_filename, ctx->d_perceptron_features); */
dico_vec_print(ctx->vocabs_filename, ctx->vocabs);
}
context_free(ctx); context_free(ctx);
return 0; return 0;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment