Commit 362239fe authored by Alexis Nasr's avatar Alexis Nasr
Browse files

code refactoring

parent a976dc41
......@@ -7,8 +7,6 @@
#include "util.h"
#define STANDARD_FPLM_FILENAME "fplm"
void context_set_linguistic_resources_filenames(context *ctx);
void context_free(context *ctx)
......@@ -142,7 +140,7 @@ void context_set_linguistic_resources_filenames(context *ctx)
if(!ctx->fplm_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, STANDARD_FPLM_FILENAME);
strcat(absolute_filename, DEFAULT_FPLM_FILENAME);
ctx->fplm_filename = strdup(absolute_filename);
}
......
......@@ -4,6 +4,10 @@
#include "mcd.h"
#include <stdlib.h>
#define DEFAULT_FPLM_FILENAME "fplm"
typedef struct {
int help;
int verbose;
......@@ -17,6 +21,8 @@ typedef struct {
mcd *mcd_struct;
} context;
context *context_new(void);
void context_free(context *ctx);
......@@ -24,6 +30,7 @@ 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);
......
......@@ -176,8 +176,6 @@ config *beam_decoder_sentence(config *initial_config, dico *dico_features, featu
beam *next_beam= beam_new(beam_width);
beam *final_beam= beam_new(beam_width);
beam *tmp_beam= NULL;
int i;
float max;
config *argmax;
int step = 0;
......
......@@ -314,25 +314,25 @@ void context_set_linguistic_resources_filenames(context *ctx)
if(!ctx->perc_model_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, STANDARD_MODEL_FILENAME);
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, STANDARD_VOCABS_FILENAME);
strcat(absolute_filename, DEFAULT_VOCABS_FILENAME);
ctx->vocabs_filename = strdup(absolute_filename);
}
/* if(!ctx->mcd_filename){
strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, STANDARD_MULTI_COL_DESC_FILENAME);
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, STANDARD_FEATURES_MODEL_FILENAME);
strcat(absolute_filename, DEFAULT_FEATURES_MODEL_FILENAME);
ctx->features_model_filename = strdup(absolute_filename);
}
......
......@@ -4,10 +4,10 @@
#define TEST_MODE 1
#define TRAIN_MODE 2
#define STANDARD_MULTI_COL_DESC_FILENAME "maca_trans_parser.mcd"
#define STANDARD_FEATURES_MODEL_FILENAME "maca_trans_parser.fm"
#define STANDARD_VOCABS_FILENAME "maca_trans_parser.vocab"
#define STANDARD_MODEL_FILENAME "maca_trans_parser.model"
#define DEFAULT_MULTI_COL_DESC_FILENAME "maca_trans_parser.mcd"
#define DEFAULT_FEATURES_MODEL_FILENAME "maca_trans_parser.fm"
#define DEFAULT_VOCABS_FILENAME "maca_trans_parser.vocab"
#define DEFAULT_MODEL_FILENAME "maca_trans_parser.model"
#include "dico_vec.h"
#include "feat_model.h"
......
......@@ -90,6 +90,7 @@ char *skip_index(char *buffer)
if(buffer[i] < '0' || buffer[i] > '9' || buffer[i] == ' ' || buffer[i] == '\t')
return &buffer[i];
}
return NULL;
}
void depset_print_new_index(FILE *f, depset *d, dico *dico_labels)
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ int feat_vec_add(feat_vec *fv, int feat);
void feat_vec_empty(feat_vec *fv);
void feat_vec_print_string(feat_vec *fv, dico *dico_features);
void feat_vec_print(FILE *f, feat_vec *fv);
/* void feat_vec_print_dnn(FILE *f, feat_vec *fv, feat_model *fm, mcd *m); */
/* void feat_vec_print_dnn(FILE *f, feat_vec *fv, feat_model *fm, mcd *m); */
/* void feat_vec_fill_input_array_dnn(fann_type *input_array, feat_vec *fv, feat_model *fm, mcd *m); */
/* void feat_vec_fill_input_array_dnn(float *input_array, feat_vec *fv, feat_model *fm, mcd *m); */
#endif
......@@ -51,11 +51,6 @@ void queue_print(FILE *f, queue *q)
fprintf(f, ")\n");
}
int queue_nbelem(queue *q)
{
return q->nbelem;
}
queue *queue_new(int size)
{
queue *q = (queue *)memalloc(sizeof(queue));
......
......@@ -5,6 +5,11 @@
#include"word.h"
#include"mcd.h"
#define queue_nbelem(q) (q)->nbelem
#define queue_size(q) (q)->size
#define queue_head(q) (q)->head
#define queue_tail(q) (q)->tail
typedef struct {
int size;
word **array;
......
......@@ -3,6 +3,13 @@
#include"stack.h"
#include"util.h"
/*int stack_height(stack *s)
{
return(s->top);
}*/
int stack_is_empty(stack *s)
{
return(s->top == 0);
......
......@@ -4,7 +4,8 @@
#include<stdio.h>
#include"word.h"
#define stack_height(s) (s)->top
#define stack_height(s) (s)->top
#define stack_elt_n(s, n) (s)->array[(s)->top - (n) - 1]
typedef struct {
int size;
......@@ -20,4 +21,5 @@ word *stack_top(stack *s);
void stack_print(FILE *buffer, stack *s);
void stack_free(stack *s);
int stack_is_empty(stack *s);
/* int stack_height(stack *s); */
#endif
......@@ -117,7 +117,7 @@ int generate_training_file_stream(FILE *output_file, context *ctx)
feat_vec_print(output_file, fv);
}
else if(ctx->fann_filename){
feat_vec_print_dnn(output_file, fv, ctx->features_model, ctx->mcd_struct);
/* feat_vec_print_dnn(output_file, fv, ctx->features_model, ctx->mcd_struct); */
print_mvt_fann(output_file, ctx->mvt_nb, mvt_code);
fprintf(output_file, "\n\n");
}
......@@ -218,7 +218,7 @@ int generate_training_file_buffer(FILE *output_file, context *ctx)
c = config_initial(conll_file, ctx->mcd_struct, 1000, 0);
while((ref = sentence_read(conll_file_ref, ctx->mcd_struct)) && (sentence_nb < ctx->sent_nb)){
/* sentence_print(stdout, ref, NULL); */
/* sentence_print(stdout, ref, NULL); */
queue_read_sentence(c->bf, conll_file, ctx->mcd_struct);
while(!config_is_terminal(c)){
/* config_print(stdout,c); */
......
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