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

code refactoring

parent a976dc41
No related branches found
No related tags found
1 merge request!1Maca common
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include "util.h" #include "util.h"
#define STANDARD_FPLM_FILENAME "fplm"
void context_set_linguistic_resources_filenames(context *ctx); void context_set_linguistic_resources_filenames(context *ctx);
void context_free(context *ctx) void context_free(context *ctx)
...@@ -142,7 +140,7 @@ void context_set_linguistic_resources_filenames(context *ctx) ...@@ -142,7 +140,7 @@ void context_set_linguistic_resources_filenames(context *ctx)
if(!ctx->fplm_filename){ if(!ctx->fplm_filename){
strcpy(absolute_filename, absolute_path); strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, STANDARD_FPLM_FILENAME); strcat(absolute_filename, DEFAULT_FPLM_FILENAME);
ctx->fplm_filename = strdup(absolute_filename); ctx->fplm_filename = strdup(absolute_filename);
} }
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include "mcd.h" #include "mcd.h"
#include <stdlib.h> #include <stdlib.h>
#define DEFAULT_FPLM_FILENAME "fplm"
typedef struct { typedef struct {
int help; int help;
int verbose; int verbose;
...@@ -17,6 +21,8 @@ typedef struct { ...@@ -17,6 +21,8 @@ typedef struct {
mcd *mcd_struct; mcd *mcd_struct;
} context; } context;
context *context_new(void); context *context_new(void);
void context_free(context *ctx); void context_free(context *ctx);
...@@ -24,6 +30,7 @@ context *context_read_options(int argc, char *argv[]); ...@@ -24,6 +30,7 @@ context *context_read_options(int argc, char *argv[]);
void context_general_help_message(context *ctx); void context_general_help_message(context *ctx);
void context_conll_help_message(context *ctx); void context_conll_help_message(context *ctx);
void context_language_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_maca_data_path_help_message(context *ctx);
void context_mcd_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 ...@@ -176,8 +176,6 @@ config *beam_decoder_sentence(config *initial_config, dico *dico_features, featu
beam *next_beam= beam_new(beam_width); beam *next_beam= beam_new(beam_width);
beam *final_beam= beam_new(beam_width); beam *final_beam= beam_new(beam_width);
beam *tmp_beam= NULL; beam *tmp_beam= NULL;
int i;
float max;
config *argmax; config *argmax;
int step = 0; int step = 0;
......
...@@ -314,25 +314,25 @@ void context_set_linguistic_resources_filenames(context *ctx) ...@@ -314,25 +314,25 @@ void context_set_linguistic_resources_filenames(context *ctx)
if(!ctx->perc_model_filename){ if(!ctx->perc_model_filename){
strcpy(absolute_filename, absolute_path); strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, STANDARD_MODEL_FILENAME); strcat(absolute_filename, DEFAULT_MODEL_FILENAME);
ctx->perc_model_filename = strdup(absolute_filename); ctx->perc_model_filename = strdup(absolute_filename);
} }
if(!ctx->vocabs_filename){ if(!ctx->vocabs_filename){
strcpy(absolute_filename, absolute_path); strcpy(absolute_filename, absolute_path);
strcat(absolute_filename, STANDARD_VOCABS_FILENAME); strcat(absolute_filename, DEFAULT_VOCABS_FILENAME);
ctx->vocabs_filename = strdup(absolute_filename); ctx->vocabs_filename = strdup(absolute_filename);
} }
/* if(!ctx->mcd_filename){ /* if(!ctx->mcd_filename){
strcpy(absolute_filename, absolute_path); 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); ctx->mcd_filename = strdup(absolute_filename);
}*/ }*/
if(!ctx->features_model_filename){ if(!ctx->features_model_filename){
strcpy(absolute_filename, absolute_path); 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); ctx->features_model_filename = strdup(absolute_filename);
} }
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#define TEST_MODE 1 #define TEST_MODE 1
#define TRAIN_MODE 2 #define TRAIN_MODE 2
#define STANDARD_MULTI_COL_DESC_FILENAME "maca_trans_parser.mcd" #define DEFAULT_MULTI_COL_DESC_FILENAME "maca_trans_parser.mcd"
#define STANDARD_FEATURES_MODEL_FILENAME "maca_trans_parser.fm" #define DEFAULT_FEATURES_MODEL_FILENAME "maca_trans_parser.fm"
#define STANDARD_VOCABS_FILENAME "maca_trans_parser.vocab" #define DEFAULT_VOCABS_FILENAME "maca_trans_parser.vocab"
#define STANDARD_MODEL_FILENAME "maca_trans_parser.model" #define DEFAULT_MODEL_FILENAME "maca_trans_parser.model"
#include "dico_vec.h" #include "dico_vec.h"
#include "feat_model.h" #include "feat_model.h"
......
...@@ -90,6 +90,7 @@ char *skip_index(char *buffer) ...@@ -90,6 +90,7 @@ char *skip_index(char *buffer)
if(buffer[i] < '0' || buffer[i] > '9' || buffer[i] == ' ' || buffer[i] == '\t') if(buffer[i] < '0' || buffer[i] > '9' || buffer[i] == ' ' || buffer[i] == '\t')
return &buffer[i]; return &buffer[i];
} }
return NULL;
} }
void depset_print_new_index(FILE *f, depset *d, dico *dico_labels) void depset_print_new_index(FILE *f, depset *d, dico *dico_labels)
......
This diff is collapsed.
...@@ -51,11 +51,6 @@ void queue_print(FILE *f, queue *q) ...@@ -51,11 +51,6 @@ void queue_print(FILE *f, queue *q)
fprintf(f, ")\n"); fprintf(f, ")\n");
} }
int queue_nbelem(queue *q)
{
return q->nbelem;
}
queue *queue_new(int size) queue *queue_new(int size)
{ {
queue *q = (queue *)memalloc(sizeof(queue)); queue *q = (queue *)memalloc(sizeof(queue));
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
#include"word.h" #include"word.h"
#include"mcd.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 { typedef struct {
int size; int size;
word **array; word **array;
......
...@@ -3,6 +3,13 @@ ...@@ -3,6 +3,13 @@
#include"stack.h" #include"stack.h"
#include"util.h" #include"util.h"
/*int stack_height(stack *s)
{
return(s->top);
}*/
int stack_is_empty(stack *s) int stack_is_empty(stack *s)
{ {
return(s->top == 0); return(s->top == 0);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include"word.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 { typedef struct {
int size; int size;
...@@ -20,4 +21,5 @@ word *stack_top(stack *s); ...@@ -20,4 +21,5 @@ word *stack_top(stack *s);
void stack_print(FILE *buffer, stack *s); void stack_print(FILE *buffer, stack *s);
void stack_free(stack *s); void stack_free(stack *s);
int stack_is_empty(stack *s); int stack_is_empty(stack *s);
/* int stack_height(stack *s); */
#endif #endif
...@@ -117,7 +117,7 @@ int generate_training_file_stream(FILE *output_file, context *ctx) ...@@ -117,7 +117,7 @@ int generate_training_file_stream(FILE *output_file, context *ctx)
feat_vec_print(output_file, fv); feat_vec_print(output_file, fv);
} }
else if(ctx->fann_filename){ 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); print_mvt_fann(output_file, ctx->mvt_nb, mvt_code);
fprintf(output_file, "\n\n"); fprintf(output_file, "\n\n");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment