diff --git a/maca_common/include/mcd.h b/maca_common/include/mcd.h index c9134fa4883c3edf798648658c52eef3c7754582..1fd242cb23c8dee976a0e1fcbe29022e0e9f6b28 100644 --- a/maca_common/include/mcd.h +++ b/maca_common/include/mcd.h @@ -127,5 +127,6 @@ void mcd_free(mcd *m); int mcd_get_code(mcd *m, char *str, int col); dico_vec *mcd_build_dico_vec(mcd *mcd_struct); int mcd_wf_code(char *wf); - +void mcd_remove_wf_column(mcd *m, int wf_code); +mcd *mcd_copy(mcd *m); #endif diff --git a/maca_common/include/word.h b/maca_common/include/word.h index 2e5ae2c72df48d5f8c1772dbd26653a091d104ee..7606d4cf31bd94d38a7d087a8def69db4650fb0d 100644 --- a/maca_common/include/word.h +++ b/maca_common/include/word.h @@ -3,43 +3,45 @@ #include "mcd.h" -#define word_get_index(w) (w)->wf_array[MCD_WF_INDEX] -#define word_get_form(w) (w)->wf_array[MCD_WF_FORM] -#define word_get_lemma(w) (w)->wf_array[MCD_WF_LEMMA] -#define word_get_cpos(w) (w)->wf_array[MCD_WF_CPOS] -#define word_get_pos(w) (w)->wf_array[MCD_WF_POS] -#define word_get_feats(w) (w)->wf_array[MCD_WF_FEATS] -#define word_get_gov(w) (w)->wf_array[MCD_WF_GOV] -#define word_get_label(w) (w)->wf_array[MCD_WF_LABEL] -#define word_get_stag(w) (w)->wf_array[MCD_WF_STAG] -#define word_get_sent_seg(w) (w)->wf_array[MCD_WF_SENT_SEG] -#define word_get_A(w) (w)->wf_array[MCD_WF_A] -#define word_get_B(w) (w)->wf_array[MCD_WF_B] -#define word_get_C(w) (w)->wf_array[MCD_WF_C] -#define word_get_D(w) (w)->wf_array[MCD_WF_D] -#define word_get_E(w) (w)->wf_array[MCD_WF_E] -#define word_get_F(w) (w)->wf_array[MCD_WF_F] -#define word_get_G(w) (w)->wf_array[MCD_WF_G] -#define word_get_H(w) (w)->wf_array[MCD_WF_H] -#define word_get_I(w) (w)->wf_array[MCD_WF_I] -#define word_get_J(w) (w)->wf_array[MCD_WF_J] -#define word_get_K(w) (w)->wf_array[MCD_WF_K] -#define word_get_L(w) (w)->wf_array[MCD_WF_L] -#define word_get_M(w) (w)->wf_array[MCD_WF_M] -#define word_get_N(w) (w)->wf_array[MCD_WF_N] -#define word_get_O(w) (w)->wf_array[MCD_WF_O] -#define word_get_P(w) (w)->wf_array[MCD_WF_P] -#define word_get_Q(w) (w)->wf_array[MCD_WF_Q] -#define word_get_R(w) (w)->wf_array[MCD_WF_R] -#define word_get_S(w) (w)->wf_array[MCD_WF_S] -#define word_get_T(w) (w)->wf_array[MCD_WF_T] -#define word_get_U(w) (w)->wf_array[MCD_WF_U] -#define word_get_V(w) (w)->wf_array[MCD_WF_V] -#define word_get_W(w) (w)->wf_array[MCD_WF_W] -#define word_get_X(w) (w)->wf_array[MCD_WF_X] -#define word_get_Y(w) (w)->wf_array[MCD_WF_Y] -#define word_get_Z(w) (w)->wf_array[MCD_WF_Z] -#define word_get_signature(w) (w)->signature +#define word_get_index(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_INDEX] +#define word_get_form(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_FORM] +#define word_get_lemma(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_LEMMA] +#define word_get_cpos(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_CPOS] +#define word_get_pos(w) ((w) == NULL) ? -1 : ((w)->wf_array[MCD_WF_POS]) +#define word_get_feats(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_FEATS] +#define word_get_gov(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_GOV] +#define word_get_label(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_LABEL] +#define word_get_stag(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_STAG] +#define word_get_sent_seg(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_SENT_SEG] +#define word_get_A(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_A] +#define word_get_B(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_B] +#define word_get_C(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_C] +#define word_get_D(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_D] +#define word_get_E(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_E] +#define word_get_F(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_F] +#define word_get_G(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_G] +#define word_get_H(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_H] +#define word_get_I(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_I] +#define word_get_J(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_J] +#define word_get_K(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_K] +#define word_get_L(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_L] +#define word_get_M(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_M] +#define word_get_N(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_N] +#define word_get_O(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_O] +#define word_get_P(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_P] +#define word_get_Q(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_Q] +#define word_get_R(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_R] +#define word_get_S(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_S] +#define word_get_T(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_T] +#define word_get_U(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_U] +#define word_get_V(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_V] +#define word_get_W(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_W] +#define word_get_X(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_X] +#define word_get_Y(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_Y] +#define word_get_Z(w) ((w) == NULL) ? -1 : (w)->wf_array[MCD_WF_Z] +#define word_get_signature(w) ((w) == NULL) ? -1 : (w)->signature +#define word_get_U1(w) ((w) == NULL) ? -1 : (w)->U1 +#define word_get_relative_index(w) ((w) == NULL) ? -1 : (w)->relative_index #define word_set_index(w, val) (w)->wf_array[MCD_WF_INDEX] = (val) #define word_set_form(w, val) (w)->wf_array[MCD_WF_FORM] = (val) @@ -75,16 +77,11 @@ #define word_set_V(w, val) (w)->wf_array[MCD_WF_V] = (val) #define word_set_W(w, val) (w)->wf_array[MCD_WF_W] = (val) #define word_set_X(w, val) (w)->wf_array[MCD_WF_X] = (val) - #define word_set_Y(w, val) (w)->wf_array[MCD_WF_Y] = (val) #define word_set_Z(w, val) (w)->wf_array[MCD_WF_Z] = (val) #define word_set_signature(w, val) (w)->signature = (val) - #define word_set_relative_index(w, val) (w)->relative_index = (val) -#define word_get_relative_index(w) (w)->relative_index - - typedef struct _word { int wf_array[MCD_WF_NB]; /* array containing the codes corresponding to the different word features */ char *input; /* the string corresponding to the actual line in the corpus file */ diff --git a/maca_common/include/word_buffer.h b/maca_common/include/word_buffer.h index 47f2928a5662757e9cf0af2f9caf7d29768320f8..a2e358b2cae411be0b609b734f4f28959967d690 100644 --- a/maca_common/include/word_buffer.h +++ b/maca_common/include/word_buffer.h @@ -11,7 +11,7 @@ #define word_buffer_get_lookahead(wb) (wb)->lookahead #define word_buffer_get_current_index(wb) (wb)->current_index #define word_buffer_get_input_file(wb) (wb)->input_file -#define word_buffer_get_mcd(wb) (wb)->input_mcd_struct +#define word_buffer_get_mcd(wb) (wb)->mcd_struct #define word_buffer_b0(wb) ((wb)->nbelem == 0)? NULL : (wb)->array[(wb)->current_index] #define word_buffer_b1(wb) ((wb)->current_index + 1 >= (wb)->nbelem)? NULL : (wb)->array[(wb)->current_index + 1] @@ -20,6 +20,9 @@ #define word_buffer_bm1(wb) ((wb)->current_index - 1 < 0)? NULL : (wb)->array[(wb)->current_index - 1] #define word_buffer_bm2(wb) ((wb)->current_index - 2 < 0)? NULL : (wb)->array[(wb)->current_index - 2] #define word_buffer_bm3(wb) ((wb)->current_index - 3 < 0)? NULL : (wb)->array[(wb)->current_index - 3] +#define word_buffer_nb_elts_right(wb) (wb)->nbelem - (wb)->current_index - 1 +#define word_buffer_nb_elts_left(wb) (wb)->current_index + typedef struct { int size; /* size of the array used to store words */ @@ -36,19 +39,15 @@ word_buffer *word_buffer_new(FILE *input_file, mcd *mcd_struct, int lookahead); void word_buffer_free(word_buffer *wb); int word_buffer_add(word_buffer *wb, word *w); word *word_buffer_get_word_relative(word_buffer *wb, int dist); +word* word_buffer_get_word_n(word_buffer *wb, int n); int word_buffer_read_next_word(word_buffer *wb); int word_buffer_move_right(word_buffer *wb); int word_buffer_move_left(word_buffer *wb); void word_buffer_print(FILE *f, word_buffer *wb); -/* -word *word_buffer_b0(word_buffer *wb); -word *word_buffer_b1(word_buffer *wb); -word *word_buffer_b2(word_buffer *wb); -word *word_buffer_b3(word_buffer *wb); -word *word_buffer_bm1(word_buffer *wb); -word *word_buffer_bm2(word_buffer *wb); -word *word_buffer_bm3(word_buffer *wb); -*/ - +int word_buffer_is_empty(word_buffer *wb); +int word_buffer_is_last(word_buffer *wb); +int word_buffer_end(word_buffer *wb); +int word_buffer_read_sentence(word_buffer *bw); +word_buffer *word_buffer_load_mcf(char *mcf_filename, mcd *mcd_struct); #endif diff --git a/maca_common/src/mcd.c b/maca_common/src/mcd.c index 1bb939cf75a01482d61960b2635c354508df24d5..5f068e21995509830abfc1c1fb5a2bf25279012f 100644 --- a/maca_common/src/mcd.c +++ b/maca_common/src/mcd.c @@ -8,6 +8,21 @@ #include "dico.h" #include "word_emb.h" + +void mcd_remove_wf_column(mcd *m, int wf_code) +{ + int col = m->wf2col[wf_code]; + m->wf2col[wf_code] = -1; + + m->representation[col] = MCD_REPRESENTATION_NULL; + m->wf[col] = -1; + m->wf_str[col] = NULL; + m->filename[col] = NULL; + m->dico_array[col] = NULL; + m->word_emb_array[col] = NULL; + +} + mcd *mcd_new(int nb_col) { mcd *m = (mcd *)memalloc(sizeof(mcd)); @@ -30,11 +45,30 @@ mcd *mcd_new(int nb_col) m->wf_str[i] = NULL; m->filename[i] = NULL; m->dico_array[i] = NULL; - m->word_emb_array[i] = NULL;; + m->word_emb_array[i] = NULL; } return m; } +mcd *mcd_copy(mcd *m) +{ + int i; + mcd *copy = mcd_new(m->nb_col); + + for(i=0; i < MCD_WF_NB; i++) + copy->wf2col[i] = m->wf2col[i] = -1; + + for(i=0; i < m->nb_col; i++){ + copy->representation[i] = m->representation[i]; + copy->wf[i] = m->wf[i]; + copy->wf_str[i] = (m->wf_str[i]) ? strdup(m->wf_str[i]) : NULL; + copy->filename[i] = (m->filename[i]) ? strdup(m->filename[i]) : NULL; + copy->dico_array[i] = (m->dico_array[i]) ? m->dico_array[i] : NULL; + copy->word_emb_array[i] = (m->word_emb_array[i])? m->word_emb_array[i] : NULL; + } + return copy; +} + void mcd_free(mcd *m) { int i; diff --git a/maca_common/src/sentence.c b/maca_common/src/sentence.c index 30a23b947c529a3c3455d36f81e016d6554f832f..aaa5e1b587d77cbc97e9f65b23e6c75fe25e85af 100644 --- a/maca_common/src/sentence.c +++ b/maca_common/src/sentence.c @@ -17,7 +17,7 @@ sentence *sentence_new(mcd *m, FILE *f) sentence *sentence_init(mcd *m, FILE *f) { sentence *s = sentence_new(m, f); - sentence_add_word(s, word_create_dummy(m)); + /* sentence_add_word(s, word_create_dummy(m)); */ return s; } @@ -35,7 +35,7 @@ void sentence_print(FILE *f, sentence *s, dico *dico_labels) int i; - for(i=1; i < s->length; i++){ + for(i=0; i < s->length; i++){ fprintf(f, "%d\t", i); word_print(f, s->words[i]); fprintf(f, "\n"); @@ -78,7 +78,7 @@ sentence *sentence_read(FILE *f, mcd *mcd_struct) if(w) sentence_add_word(s, w); if(word_is_eos(w, mcd_struct)) break; } - + if(s->length == 1){ sentence_free(s); diff --git a/maca_common/src/word.c b/maca_common/src/word.c index ee703d075017a98e4af07693deaa5227c9f1bfdc..d4b25c03d074649e499d1c6aa6cf19eb632c4f3e 100644 --- a/maca_common/src/word.c +++ b/maca_common/src/word.c @@ -16,9 +16,12 @@ word *word_new(char *input) w->input = strdup(input); for(i=0; i < MCD_WF_NB; i++) w->wf_array[i] = -1; + + w->wf_array[MCD_WF_GOV] = 0; w->form = NULL; w->relative_index = -1; + w->signature = -1; return w; } @@ -124,7 +127,9 @@ void word_print2(FILE *f, word *w) void word_print(FILE *f, word *w) { if(w == NULL) return; - + if(w->input == NULL) + fprintf(f, "NULL"); + else fprintf(f, "%s", w->input); } @@ -137,6 +142,14 @@ int word_is_eos(word *w, mcd *mcd_struct) } int word_get_gov_relative_index(word *w) { - if(word_get_gov(w) == 0) return 0; - return word_get_relative_index(w) + word_get_gov(w); + int index; + if(word_get_gov(w) == 0) return -1; + + printf("in word_get_gov_rel_index(%d)\n", word_get_relative_index(w)); + printf("gov = %d\n", word_get_gov(w)); + + index = (word_get_relative_index(w)) + (word_get_gov(w)); + /* printf("index = %d\n", index); */ + return index; + /* return word_get_relative_index(w) + word_get_gov(w); */ } diff --git a/maca_common/src/word_buffer.c b/maca_common/src/word_buffer.c index 74e1a0b0086aa68466aeea3ec338c97671f3abc7..06d6b8d1e5fec585ed4a7639cdedc6551fea0f53 100644 --- a/maca_common/src/word_buffer.c +++ b/maca_common/src/word_buffer.c @@ -12,9 +12,17 @@ word_buffer *word_buffer_new(FILE *input_file, mcd *mcd_struct, int lookahead) wb->nbelem = 0; wb->array = (word **)memalloc(wb->size * sizeof(word *)); wb->current_index = 0; + + + word_buffer_add(wb, word_new(NULL)); /* add dummy token */ + + /* load lookahead next words */ wb->lookahead = lookahead; for(i=0; i <= lookahead; i++) word_buffer_read_next_word(wb); + + word_buffer_move_right(wb); /* pass dummy token */ + return wb; } @@ -55,6 +63,8 @@ int word_buffer_add(word_buffer *wb, word *w) wb->array = (word **)realloc(wb->array, wb->size * sizeof(word *)); } wb->array[wb->nbelem] = w; + word_set_relative_index(w, wb->nbelem); + wb->nbelem++; return wb->nbelem - 1; } @@ -64,19 +74,31 @@ word *word_buffer_get_word(word_buffer *wb, int offset) return ((wb->current_index + offset >=0) && (wb->current_index + offset <= wb->nbelem))? wb->array[wb->current_index + offset] : NULL; } +word *word_buffer_get_word_n(word_buffer *wb, int n) +{ + return ((n >=0) && (n < wb->nbelem))? wb->array[n] : NULL; + +} + +word_buffer *word_buffer_load_mcf(char *mcf_filename, mcd *mcd_struct) +{ + FILE *f = myfopen(mcf_filename, "r"); + word_buffer *wb = word_buffer_new(f, mcd_struct, 0); + while(word_buffer_read_next_word(wb) != -1){ + /* printf("load word %d\n", wb->nbelem - 1); */ + } + fclose(f); + return wb; +} int word_buffer_read_next_word(word_buffer *wb) { word *w = NULL; - int index; w = word_read(wb->input_file, wb->mcd_struct); if(w == NULL) return -1; - - - index = word_buffer_add(wb, w); - word_set_relative_index(w, index); - return index; + word_buffer_add(wb, w); + return wb->nbelem - 1; } int word_buffer_move_right(word_buffer *wb) @@ -97,41 +119,38 @@ int word_buffer_move_left(word_buffer *wb) return 0; } - -/* -word *word_buffer_b0(word_buffer *wb) -{ - return(wb->nbelem == 0)? NULL : wb->array[wb->current_index]; -} - -word *word_buffer_b1(word_buffer *wb) -{ - return(wb->current_index + 1 >= wb->nbelem)? NULL : wb->array[wb->current_index + 1]; -} - -word *word_buffer_b2(word_buffer *wb) +int word_buffer_end(word_buffer *wb) { - return(wb->current_index + 2 >= wb->nbelem)? NULL : wb->array[wb->current_index + 2]; + return (wb->current_index == wb->nbelem)? 1 : 0; } -word *word_buffer_b3(word_buffer *wb) +int word_buffer_is_last(word_buffer *wb) { - return(wb->current_index + 3 >= wb->nbelem)? NULL : wb->array[wb->current_index + 3]; + return (wb->current_index == wb->nbelem - 1)? 1 : 0; } -word *word_buffer_bm1(word_buffer *wb) +int word_buffer_is_empty(word_buffer *wb) { - return(wb->current_index - 1 < 0)? NULL : wb->array[wb->current_index - 1]; + return (wb->nbelem == 0)? 1 : 0; } -word *word_buffer_bm2(word_buffer *wb) +int word_buffer_read_sentence(word_buffer *wb) { - return(wb->current_index - 2 < 0)? NULL : wb->array[wb->current_index - 2]; -} - -word *word_buffer_bm3(word_buffer *wb) -{ - return(wb->current_index - 3 < 0)? NULL : wb->array[wb->current_index - 3]; + char buffer[10000]; + word *w = NULL; + int index = 1; + + while(fgets(buffer, 10000, word_buffer_get_input_file(wb))){ + if(feof(word_buffer_get_input_file(wb))) break; + /* fprintf(stderr, "%s", buffer); */ + if((buffer[0] == '\n') || (buffer[0] == ' ') || (buffer[0] == '\t')) break; /* end of the sentence */ + w = word_parse_buffer(buffer, word_buffer_get_mcd(wb)); + word_set_relative_index(w, index); + index++; + word_buffer_add(wb, w); + if(word_is_eos(w, word_buffer_get_mcd(wb))) break; + } + /* return bw->nbelem - 1; */ /* because of the dummy word */ + return wb->nbelem ; } -*/ diff --git a/maca_trans_parser/CMakeLists.txt b/maca_trans_parser/CMakeLists.txt index a7c7988797d35ebd6132f4722c79142955287823..f7d18f5fd462b2fac4e450356e9ca1bdda4403dc 100644 --- a/maca_trans_parser/CMakeLists.txt +++ b/maca_trans_parser/CMakeLists.txt @@ -1,10 +1,11 @@ set(SOURCES src/context.c src/feat_desc.c - src/movement_parser.c + src/movement_parser_arc_eager.c src/movement_tagger.c src/feat_fct.c src/global_feat_vec.c src/oracle_parser.c + src/oracle_parser_arc_eager.c src/oracle_tagger.c src/simple_decoder_parser.c src/simple_decoder_forrest.c @@ -16,7 +17,7 @@ set(SOURCES src/context.c src/feat_model.c src/config.c src/queue.c - src/beam.c +# src/beam.c src/feat_types.c ) @@ -63,12 +64,12 @@ target_link_libraries(maca_trans_tagger transparse) target_link_libraries(maca_trans_tagger maca_common) install (TARGETS maca_trans_tagger DESTINATION bin) -add_executable(maca_trans_parser_train ./src/train_perceptron.c) -target_compile_options(maca_trans_parser_train INTERFACE -Wall) -target_link_libraries(maca_trans_parser_train perceptron) -target_link_libraries(maca_trans_parser_train transparse) -target_link_libraries(maca_trans_parser_train maca_common) -install (TARGETS maca_trans_parser_train DESTINATION bin) +#add_executable(maca_trans_parser_train ./src/train_perceptron.c) +#target_compile_options(maca_trans_parser_train INTERFACE -Wall) +#target_link_libraries(maca_trans_parser_train perceptron) +#target_link_libraries(maca_trans_parser_train transparse) +#target_link_libraries(maca_trans_parser_train maca_common) +#install (TARGETS maca_trans_parser_train DESTINATION bin) add_executable(test_word_buffer ./src/test_word_buffer.c) target_compile_options(test_word_buffer INTERFACE -Wall) diff --git a/maca_trans_parser/src/config.c b/maca_trans_parser/src/config.c index 7f08cd7d53af6c8a7c4a4c41562e4c80b900ad13..43c4cdb2227a0853ac28edd9da5575cadb421f67 100644 --- a/maca_trans_parser/src/config.c +++ b/maca_trans_parser/src/config.c @@ -5,14 +5,14 @@ #include"dico.h" #include"feat_types.h" -config *config_new(FILE *f, mcd *mcd_struct) +config *config_new(FILE *f, mcd *mcd_struct, int lookahead) { config *c = (config *)memalloc(sizeof(config)); c->ds = depset_new(); c->f = f; c->mcd_struct = mcd_struct; c->st = stack_new(); - c->bf = queue_new(); + c->bf = word_buffer_new(f, mcd_struct, lookahead); c->score = 0; c->mvt_array = NULL; c->mvt_array_size = 0; @@ -23,7 +23,7 @@ config *config_new(FILE *f, mcd *mcd_struct) return c; } -word *config_add_next_word_to_buffer(config *c) +/*word *config_add_next_word_to_buffer(config *c) { word *w = NULL; @@ -31,19 +31,15 @@ word *config_add_next_word_to_buffer(config *c) if(w == NULL) return NULL; word_set_relative_index(w, c->current_index); - - /* if(word_get_index(w) == -1){ - word_set_index(w, c->current_index); - }*/ c->current_index++; queue_add(c->bf, w); return w; -} + }*/ void config_free(config *c) { stack_free(c->st); - queue_free(c->bf); + word_buffer_free(c->bf); depset_free(c->ds); if(c->mvt_array)free(c->mvt_array); if(c->gfv)global_feat_vec_free(c->gfv); @@ -52,40 +48,34 @@ void config_free(config *c) int config_is_terminal(config *c) { - return queue_is_empty(c->bf); + return word_buffer_is_last(c->bf); } config *config_initial(FILE *f, mcd *mcd_struct, int lookahead) { - int i; - config *c = config_new(f, mcd_struct); - - queue_add(c->bf, word_create_dummy(mcd_struct)); + config *c = config_new(f, mcd_struct, lookahead); - for(i=0; i < lookahead; i++) - config_add_next_word_to_buffer(c); + stack_push(c->st, word_create_dummy(mcd_struct)); return c; } config *config_initial_no_dummy_word(FILE *f, mcd *mcd_struct, int lookahead) { - int i; - config *c = config_new(f, mcd_struct); - - for(i=0; i < lookahead; i++) - config_add_next_word_to_buffer(c); + config *c = config_new(f, mcd_struct, lookahead); return c; } +/* must be checked things probably missing */ + config *config_copy(config *o) { int i; config *c = (config *)memalloc(sizeof(config)); c->ds = depset_copy(o->ds); c->st = stack_copy(o->st); - c->bf = queue_copy(o->bf); + /* c->bf = queue_copy(o->bf); */ c->score = o->score; c->f = o->f; @@ -117,15 +107,13 @@ void config_print(FILE *f, config *c) if(c){ if(!stack_is_empty(c->st)) s0 = stack_elt_n(c->st, 0); - b0 = queue_elt_n(c->bf, 0); + b0 = word_buffer_b0(c->bf); if(s0) { printf("s0 = "); word_print2(stdout, s0);} if(b0) { printf("b0 = "); word_print2(stdout, b0);} stack_print(f, c->st); - fprintf(f, " "); - queue_print(f, c->bf); - fprintf(f, " "); - depset_print(f, c->ds); + fprintf(f, "\n"); + word_buffer_print(f, c->bf); } } diff --git a/maca_trans_parser/src/config.h b/maca_trans_parser/src/config.h index b08204ce69aa42aac6b6eccb32e9cf4d786835d6..b122662efcc8a5915adf410187fa720c58e68b3a 100644 --- a/maca_trans_parser/src/config.h +++ b/maca_trans_parser/src/config.h @@ -8,6 +8,7 @@ #include"queue.h" #include"depset.h" #include"mcd.h" +#include"word_buffer.h" #include"feat_vec.h" #include"global_feat_vec.h" @@ -17,7 +18,7 @@ typedef struct { stack *st; /* the stack */ - queue *bf; /* the buffer */ + word_buffer *bf; /* the buffer */ depset *ds; /* the dependency set */ FILE *f; /* file from which words are read */ mcd *mcd_struct; /* description of the format of file f */ @@ -32,7 +33,7 @@ typedef struct { int config_equal(config *c1, config *c2); int config_equal2(config *c1, config *c2); -config *config_new(FILE *f, mcd *mcd_struct); +config *config_new(FILE *f, mcd *mcd_struct, int lookahead); config *config_initial(FILE *f, mcd *mcd_struct, int lookahead); config *config_initial_no_dummy_word(FILE *f, mcd *mcd_struct, int lookahead); config *config_copy(config *o); diff --git a/maca_trans_parser/src/feat_fct.c b/maca_trans_parser/src/feat_fct.c index a20da58595a799642f62863f6010acca8ad41402..c37a01b0f43e84679ecbcee31c49a041f0f089d0 100644 --- a/maca_trans_parser/src/feat_fct.c +++ b/maca_trans_parser/src/feat_fct.c @@ -7,279 +7,383 @@ /* word features */ -int s0f(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_form(stack_elt_n(config_get_stack(c), 0));} -int s0l(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_lemma(stack_elt_n(config_get_stack(c), 0));} -int s0c(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_cpos(stack_elt_n(config_get_stack(c), 0));} -int s0p(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_pos(stack_elt_n(config_get_stack(c), 0));} -int s0m(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_feats(stack_elt_n(config_get_stack(c), 0));} -int s0s(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_stag(stack_elt_n(config_get_stack(c), 0));} -int s0A(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_A(stack_elt_n(config_get_stack(c), 0));} -int s0B(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_B(stack_elt_n(config_get_stack(c), 0));} -int s0C(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_C(stack_elt_n(config_get_stack(c), 0));} -int s0D(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_D(stack_elt_n(config_get_stack(c), 0));} -int s0E(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_E(stack_elt_n(config_get_stack(c), 0));} -int s0F(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_F(stack_elt_n(config_get_stack(c), 0));} -int s0G(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_G(stack_elt_n(config_get_stack(c), 0));} -int s0H(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_H(stack_elt_n(config_get_stack(c), 0));} -int s0I(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_I(stack_elt_n(config_get_stack(c), 0));} -int s0J(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_J(stack_elt_n(config_get_stack(c), 0));} -int s0K(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_K(stack_elt_n(config_get_stack(c), 0));} -int s0L(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_L(stack_elt_n(config_get_stack(c), 0));} -int s0M(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_M(stack_elt_n(config_get_stack(c), 0));} -int s0N(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_N(stack_elt_n(config_get_stack(c), 0));} -int s0O(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_O(stack_elt_n(config_get_stack(c), 0));} -int s0P(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_P(stack_elt_n(config_get_stack(c), 0));} -int s0Q(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_Q(stack_elt_n(config_get_stack(c), 0));} -int s0R(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_R(stack_elt_n(config_get_stack(c), 0));} -int s0S(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_S(stack_elt_n(config_get_stack(c), 0));} -int s0T(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_T(stack_elt_n(config_get_stack(c), 0));} -int s0U(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_U(stack_elt_n(config_get_stack(c), 0));} -int s0V(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_V(stack_elt_n(config_get_stack(c), 0));} -int s0W(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_W(stack_elt_n(config_get_stack(c), 0));} -int s0X(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_X(stack_elt_n(config_get_stack(c), 0));} -int s0Y(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_Y(stack_elt_n(config_get_stack(c), 0));} -int s0Z(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : word_get_Z(stack_elt_n(config_get_stack(c), 0));} - -int s0U1(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : stack_elt_n(config_get_stack(c), 0)->U1;} -int s0sgn(config *c) {return (stack_nbelem(config_get_stack(c)) < 1) ? -1 : stack_elt_n(config_get_stack(c), 0)->signature;} - -int s1f(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_form(stack_elt_n(config_get_stack(c), 1));} -int s1l(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_lemma(stack_elt_n(config_get_stack(c), 1));} -int s1c(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_cpos(stack_elt_n(config_get_stack(c), 1));} -int s1p(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_pos(stack_elt_n(config_get_stack(c), 1));} -int s1m(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_feats(stack_elt_n(config_get_stack(c), 1));} -int s1s(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_stag(stack_elt_n(config_get_stack(c), 1));} -int s1A(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_A(stack_elt_n(config_get_stack(c), 1));} -int s1B(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_B(stack_elt_n(config_get_stack(c), 1));} -int s1C(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_C(stack_elt_n(config_get_stack(c), 1));} -int s1D(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_D(stack_elt_n(config_get_stack(c), 1));} -int s1E(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_E(stack_elt_n(config_get_stack(c), 1));} -int s1F(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_F(stack_elt_n(config_get_stack(c), 1));} -int s1G(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_G(stack_elt_n(config_get_stack(c), 1));} -int s1H(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_H(stack_elt_n(config_get_stack(c), 1));} -int s1I(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_I(stack_elt_n(config_get_stack(c), 1));} -int s1J(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_J(stack_elt_n(config_get_stack(c), 1));} -int s1K(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_K(stack_elt_n(config_get_stack(c), 1));} -int s1L(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_L(stack_elt_n(config_get_stack(c), 1));} -int s1M(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_M(stack_elt_n(config_get_stack(c), 1));} -int s1N(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_N(stack_elt_n(config_get_stack(c), 1));} -int s1O(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_O(stack_elt_n(config_get_stack(c), 1));} -int s1P(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_P(stack_elt_n(config_get_stack(c), 1));} -int s1Q(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_Q(stack_elt_n(config_get_stack(c), 1));} -int s1R(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_R(stack_elt_n(config_get_stack(c), 1));} -int s1S(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_S(stack_elt_n(config_get_stack(c), 1));} -int s1T(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_T(stack_elt_n(config_get_stack(c), 1));} -int s1U(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_U(stack_elt_n(config_get_stack(c), 1));} -int s1V(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_V(stack_elt_n(config_get_stack(c), 1));} -int s1W(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_W(stack_elt_n(config_get_stack(c), 1));} -int s1X(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_X(stack_elt_n(config_get_stack(c), 1));} -int s1Y(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_Y(stack_elt_n(config_get_stack(c), 1));} -int s1Z(config *c) {return (stack_nbelem(config_get_stack(c)) < 2) ? -1 : word_get_Z(stack_elt_n(config_get_stack(c), 1));} - -int s2f(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_form(stack_elt_n(config_get_stack(c), 2));} -int s2l(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_lemma(stack_elt_n(config_get_stack(c), 2));} -int s2c(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_cpos(stack_elt_n(config_get_stack(c), 2));} -int s2p(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_pos(stack_elt_n(config_get_stack(c), 2));} -int s2m(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_feats(stack_elt_n(config_get_stack(c), 2));} -int s2s(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_stag(stack_elt_n(config_get_stack(c), 2));} -int s2A(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_A(stack_elt_n(config_get_stack(c), 2));} -int s2B(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_B(stack_elt_n(config_get_stack(c), 2));} -int s2C(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_C(stack_elt_n(config_get_stack(c), 2));} -int s2D(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_D(stack_elt_n(config_get_stack(c), 2));} -int s2E(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_E(stack_elt_n(config_get_stack(c), 2));} -int s2F(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_F(stack_elt_n(config_get_stack(c), 2));} -int s2G(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_G(stack_elt_n(config_get_stack(c), 2));} -int s2H(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_H(stack_elt_n(config_get_stack(c), 2));} -int s2I(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_I(stack_elt_n(config_get_stack(c), 2));} -int s2J(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_J(stack_elt_n(config_get_stack(c), 2));} -int s2K(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_K(stack_elt_n(config_get_stack(c), 2));} -int s2L(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_L(stack_elt_n(config_get_stack(c), 2));} -int s2M(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_M(stack_elt_n(config_get_stack(c), 2));} -int s2N(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_N(stack_elt_n(config_get_stack(c), 2));} -int s2O(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_O(stack_elt_n(config_get_stack(c), 2));} -int s2P(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_P(stack_elt_n(config_get_stack(c), 2));} -int s2Q(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_Q(stack_elt_n(config_get_stack(c), 2));} -int s2R(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_R(stack_elt_n(config_get_stack(c), 2));} -int s2S(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_S(stack_elt_n(config_get_stack(c), 2));} -int s2T(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_T(stack_elt_n(config_get_stack(c), 2));} -int s2U(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_U(stack_elt_n(config_get_stack(c), 2));} -int s2V(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_V(stack_elt_n(config_get_stack(c), 2));} -int s2W(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_W(stack_elt_n(config_get_stack(c), 2));} -int s2X(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_X(stack_elt_n(config_get_stack(c), 2));} -int s2Y(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_Y(stack_elt_n(config_get_stack(c), 2));} -int s2Z(config *c) {return (stack_nbelem(config_get_stack(c)) < 3) ? -1 : word_get_Z(stack_elt_n(config_get_stack(c), 2));} - -int s3f(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_form(stack_elt_n(config_get_stack(c), 3));} -int s3l(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_lemma(stack_elt_n(config_get_stack(c), 3));} -int s3c(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_cpos(stack_elt_n(config_get_stack(c), 3));} -int s3p(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_pos(stack_elt_n(config_get_stack(c), 3));} -int s3m(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_feats(stack_elt_n(config_get_stack(c), 3));} -int s3s(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_stag(stack_elt_n(config_get_stack(c), 3));} -int s3A(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_A(stack_elt_n(config_get_stack(c), 3));} -int s3B(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_B(stack_elt_n(config_get_stack(c), 3));} -int s3C(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_C(stack_elt_n(config_get_stack(c), 3));} -int s3D(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_D(stack_elt_n(config_get_stack(c), 3));} -int s3E(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_E(stack_elt_n(config_get_stack(c), 3));} -int s3F(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_F(stack_elt_n(config_get_stack(c), 3));} -int s3G(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_G(stack_elt_n(config_get_stack(c), 3));} -int s3H(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_H(stack_elt_n(config_get_stack(c), 3));} -int s3I(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_I(stack_elt_n(config_get_stack(c), 3));} -int s3J(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_J(stack_elt_n(config_get_stack(c), 3));} -int s3K(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_K(stack_elt_n(config_get_stack(c), 3));} -int s3L(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_L(stack_elt_n(config_get_stack(c), 3));} -int s3M(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_M(stack_elt_n(config_get_stack(c), 3));} -int s3N(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_N(stack_elt_n(config_get_stack(c), 3));} -int s3O(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_O(stack_elt_n(config_get_stack(c), 3));} -int s3P(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_P(stack_elt_n(config_get_stack(c), 3));} -int s3Q(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_Q(stack_elt_n(config_get_stack(c), 3));} -int s3R(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_R(stack_elt_n(config_get_stack(c), 3));} -int s3S(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_S(stack_elt_n(config_get_stack(c), 3));} -int s3T(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_T(stack_elt_n(config_get_stack(c), 3));} -int s3U(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_U(stack_elt_n(config_get_stack(c), 3));} -int s3V(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_V(stack_elt_n(config_get_stack(c), 3));} -int s3W(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_W(stack_elt_n(config_get_stack(c), 3));} -int s3X(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_X(stack_elt_n(config_get_stack(c), 3));} -int s3Y(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_Y(stack_elt_n(config_get_stack(c), 3));} -int s3Z(config *c) {return (stack_nbelem(config_get_stack(c)) < 4) ? -1 : word_get_Z(stack_elt_n(config_get_stack(c), 3));} - -int b0f(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_form(queue_elt_n(config_get_buffer(c), 0));} -int b0l(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_lemma(queue_elt_n(config_get_buffer(c), 0));} -int b0c(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_cpos(queue_elt_n(config_get_buffer(c), 0));} -int b0p(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_pos(queue_elt_n(config_get_buffer(c), 0));} -int b0m(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_feats(queue_elt_n(config_get_buffer(c), 0));} -int b0s(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_stag(queue_elt_n(config_get_buffer(c), 0));} -int b0A(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_A(queue_elt_n(config_get_buffer(c), 0));} -int b0B(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_B(queue_elt_n(config_get_buffer(c), 0));} -int b0C(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_C(queue_elt_n(config_get_buffer(c), 0));} -int b0D(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_D(queue_elt_n(config_get_buffer(c), 0));} -int b0E(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_E(queue_elt_n(config_get_buffer(c), 0));} -int b0F(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_F(queue_elt_n(config_get_buffer(c), 0));} -int b0G(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_G(queue_elt_n(config_get_buffer(c), 0));} -int b0H(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_H(queue_elt_n(config_get_buffer(c), 0));} -int b0I(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_I(queue_elt_n(config_get_buffer(c), 0));} -int b0J(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_J(queue_elt_n(config_get_buffer(c), 0));} -int b0K(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_K(queue_elt_n(config_get_buffer(c), 0));} -int b0L(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_L(queue_elt_n(config_get_buffer(c), 0));} -int b0M(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_M(queue_elt_n(config_get_buffer(c), 0));} -int b0N(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_N(queue_elt_n(config_get_buffer(c), 0));} -int b0O(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_O(queue_elt_n(config_get_buffer(c), 0));} -int b0P(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_P(queue_elt_n(config_get_buffer(c), 0));} -int b0Q(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_Q(queue_elt_n(config_get_buffer(c), 0));} -int b0R(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_R(queue_elt_n(config_get_buffer(c), 0));} -int b0S(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_S(queue_elt_n(config_get_buffer(c), 0));} -int b0T(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_T(queue_elt_n(config_get_buffer(c), 0));} -int b0U(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_U(queue_elt_n(config_get_buffer(c), 0));} -int b0V(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_V(queue_elt_n(config_get_buffer(c), 0));} -int b0W(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_W(queue_elt_n(config_get_buffer(c), 0));} -int b0X(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_X(queue_elt_n(config_get_buffer(c), 0));} -int b0Y(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_Y(queue_elt_n(config_get_buffer(c), 0));} -int b0Z(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : word_get_Z(queue_elt_n(config_get_buffer(c), 0));} - -int b0U1(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : queue_elt_n(config_get_buffer(c), 0)->U1;} -int b0sgn(config *c) {return (queue_nbelem(config_get_buffer(c)) < 1) ? -1 : queue_elt_n(config_get_buffer(c), 0)->signature;} - - -int b1f(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_form(queue_elt_n(config_get_buffer(c), 1));} -int b1l(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_lemma(queue_elt_n(config_get_buffer(c), 1));} -int b1c(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_cpos(queue_elt_n(config_get_buffer(c), 1));} -int b1p(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_pos(queue_elt_n(config_get_buffer(c), 1));} -int b1m(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_feats(queue_elt_n(config_get_buffer(c), 1));} -int b1s(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_stag(queue_elt_n(config_get_buffer(c), 1));} -int b1A(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_A(queue_elt_n(config_get_buffer(c), 1));} -int b1B(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_B(queue_elt_n(config_get_buffer(c), 1));} -int b1C(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_C(queue_elt_n(config_get_buffer(c), 1));} -int b1D(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_D(queue_elt_n(config_get_buffer(c), 1));} -int b1E(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_E(queue_elt_n(config_get_buffer(c), 1));} -int b1F(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_F(queue_elt_n(config_get_buffer(c), 1));} -int b1G(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_G(queue_elt_n(config_get_buffer(c), 1));} -int b1H(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_H(queue_elt_n(config_get_buffer(c), 1));} -int b1I(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_I(queue_elt_n(config_get_buffer(c), 1));} -int b1J(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_J(queue_elt_n(config_get_buffer(c), 1));} -int b1K(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_K(queue_elt_n(config_get_buffer(c), 1));} -int b1L(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_L(queue_elt_n(config_get_buffer(c), 1));} -int b1M(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_M(queue_elt_n(config_get_buffer(c), 1));} -int b1N(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_N(queue_elt_n(config_get_buffer(c), 1));} -int b1O(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_O(queue_elt_n(config_get_buffer(c), 1));} -int b1P(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_P(queue_elt_n(config_get_buffer(c), 1));} -int b1Q(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_Q(queue_elt_n(config_get_buffer(c), 1));} -int b1R(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_R(queue_elt_n(config_get_buffer(c), 1));} -int b1S(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_S(queue_elt_n(config_get_buffer(c), 1));} -int b1T(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_T(queue_elt_n(config_get_buffer(c), 1));} -int b1U(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_U(queue_elt_n(config_get_buffer(c), 1));} -int b1V(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_V(queue_elt_n(config_get_buffer(c), 1));} -int b1W(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_W(queue_elt_n(config_get_buffer(c), 1));} -int b1X(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_X(queue_elt_n(config_get_buffer(c), 1));} -int b1Y(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_Y(queue_elt_n(config_get_buffer(c), 1));} -int b1Z(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : word_get_Z(queue_elt_n(config_get_buffer(c), 1));} - -int b1U1(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : queue_elt_n(config_get_buffer(c), 1)->U1;} -int b1sgn(config *c) {return (queue_nbelem(config_get_buffer(c)) < 2) ? -1 : queue_elt_n(config_get_buffer(c), 1)->signature;} - -int b2f(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_form(queue_elt_n(config_get_buffer(c), 2));} -int b2l(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_lemma(queue_elt_n(config_get_buffer(c), 2));} -int b2c(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_cpos(queue_elt_n(config_get_buffer(c), 2));} -int b2p(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_pos(queue_elt_n(config_get_buffer(c), 2));} -int b2m(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_feats(queue_elt_n(config_get_buffer(c), 2));} -int b2s(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_stag(queue_elt_n(config_get_buffer(c), 2));} -int b2A(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_A(queue_elt_n(config_get_buffer(c), 2));} -int b2B(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_B(queue_elt_n(config_get_buffer(c), 2));} -int b2C(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_C(queue_elt_n(config_get_buffer(c), 2));} -int b2D(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_D(queue_elt_n(config_get_buffer(c), 2));} -int b2E(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_E(queue_elt_n(config_get_buffer(c), 2));} -int b2F(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_F(queue_elt_n(config_get_buffer(c), 2));} -int b2G(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_G(queue_elt_n(config_get_buffer(c), 2));} -int b2H(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_H(queue_elt_n(config_get_buffer(c), 2));} -int b2I(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_I(queue_elt_n(config_get_buffer(c), 2));} -int b2J(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_J(queue_elt_n(config_get_buffer(c), 2));} -int b2K(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_K(queue_elt_n(config_get_buffer(c), 2));} -int b2L(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_L(queue_elt_n(config_get_buffer(c), 2));} -int b2M(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_M(queue_elt_n(config_get_buffer(c), 2));} -int b2N(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_N(queue_elt_n(config_get_buffer(c), 2));} -int b2O(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_O(queue_elt_n(config_get_buffer(c), 2));} -int b2P(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_P(queue_elt_n(config_get_buffer(c), 2));} -int b2Q(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_Q(queue_elt_n(config_get_buffer(c), 2));} -int b2R(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_R(queue_elt_n(config_get_buffer(c), 2));} -int b2S(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_S(queue_elt_n(config_get_buffer(c), 2));} -int b2T(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_T(queue_elt_n(config_get_buffer(c), 2));} -int b2U(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_U(queue_elt_n(config_get_buffer(c), 2));} -int b2V(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_V(queue_elt_n(config_get_buffer(c), 2));} -int b2W(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_W(queue_elt_n(config_get_buffer(c), 2));} -int b2X(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_X(queue_elt_n(config_get_buffer(c), 2));} -int b2Y(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_Y(queue_elt_n(config_get_buffer(c), 2));} -int b2Z(config *c) {return (queue_nbelem(config_get_buffer(c)) < 3) ? -1 : word_get_Z(queue_elt_n(config_get_buffer(c), 2));} - -int b3f(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_form(queue_elt_n(config_get_buffer(c), 3));} -int b3l(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_lemma(queue_elt_n(config_get_buffer(c), 3));} -int b3c(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_cpos(queue_elt_n(config_get_buffer(c), 3));} -int b3p(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_pos(queue_elt_n(config_get_buffer(c), 3));} -int b3m(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_feats(queue_elt_n(config_get_buffer(c), 3));} -int b3s(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_stag(queue_elt_n(config_get_buffer(c), 3));} -int b3A(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_A(queue_elt_n(config_get_buffer(c), 3));} -int b3B(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_B(queue_elt_n(config_get_buffer(c), 3));} -int b3C(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_C(queue_elt_n(config_get_buffer(c), 3));} -int b3D(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_D(queue_elt_n(config_get_buffer(c), 3));} -int b3E(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_E(queue_elt_n(config_get_buffer(c), 3));} -int b3F(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_F(queue_elt_n(config_get_buffer(c), 3));} -int b3G(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_G(queue_elt_n(config_get_buffer(c), 3));} -int b3H(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_H(queue_elt_n(config_get_buffer(c), 3));} -int b3I(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_I(queue_elt_n(config_get_buffer(c), 3));} -int b3J(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_J(queue_elt_n(config_get_buffer(c), 3));} -int b3K(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_K(queue_elt_n(config_get_buffer(c), 3));} -int b3L(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_L(queue_elt_n(config_get_buffer(c), 3));} -int b3M(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_M(queue_elt_n(config_get_buffer(c), 3));} -int b3N(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_N(queue_elt_n(config_get_buffer(c), 3));} -int b3O(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_O(queue_elt_n(config_get_buffer(c), 3));} -int b3P(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_P(queue_elt_n(config_get_buffer(c), 3));} -int b3Q(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_Q(queue_elt_n(config_get_buffer(c), 3));} -int b3R(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_R(queue_elt_n(config_get_buffer(c), 3));} -int b3S(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_S(queue_elt_n(config_get_buffer(c), 3));} -int b3T(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_T(queue_elt_n(config_get_buffer(c), 3));} -int b3U(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_U(queue_elt_n(config_get_buffer(c), 3));} -int b3V(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_V(queue_elt_n(config_get_buffer(c), 3));} -int b3W(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_W(queue_elt_n(config_get_buffer(c), 3));} -int b3X(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_X(queue_elt_n(config_get_buffer(c), 3));} -int b3Y(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_Y(queue_elt_n(config_get_buffer(c), 3));} -int b3Z(config *c) {return (queue_nbelem(config_get_buffer(c)) < 4) ? -1 : word_get_Z(queue_elt_n(config_get_buffer(c), 3));} +/* words in the stack */ +int s0f(config *c) {return word_get_form(stack_s0(config_get_stack(c)));} +int s0l(config *c) {return word_get_lemma(stack_s0(config_get_stack(c)));} +int s0c(config *c) {return word_get_cpos(stack_s0(config_get_stack(c)));} +int s0p(config *c) {return word_get_pos(stack_s0(config_get_stack(c)));} +int s0m(config *c) {return word_get_feats(stack_s0(config_get_stack(c)));} +int s0s(config *c) {return word_get_stag(stack_s0(config_get_stack(c)));} +int s0A(config *c) {return word_get_A(stack_s0(config_get_stack(c)));} +int s0B(config *c) {return word_get_B(stack_s0(config_get_stack(c)));} +int s0C(config *c) {return word_get_C(stack_s0(config_get_stack(c)));} +int s0D(config *c) {return word_get_D(stack_s0(config_get_stack(c)));} +int s0E(config *c) {return word_get_E(stack_s0(config_get_stack(c)));} +int s0F(config *c) {return word_get_F(stack_s0(config_get_stack(c)));} +int s0G(config *c) {return word_get_G(stack_s0(config_get_stack(c)));} +int s0H(config *c) {return word_get_H(stack_s0(config_get_stack(c)));} +int s0I(config *c) {return word_get_I(stack_s0(config_get_stack(c)));} +int s0J(config *c) {return word_get_J(stack_s0(config_get_stack(c)));} +int s0K(config *c) {return word_get_K(stack_s0(config_get_stack(c)));} +int s0L(config *c) {return word_get_L(stack_s0(config_get_stack(c)));} +int s0M(config *c) {return word_get_M(stack_s0(config_get_stack(c)));} +int s0N(config *c) {return word_get_N(stack_s0(config_get_stack(c)));} +int s0O(config *c) {return word_get_O(stack_s0(config_get_stack(c)));} +int s0P(config *c) {return word_get_P(stack_s0(config_get_stack(c)));} +int s0Q(config *c) {return word_get_Q(stack_s0(config_get_stack(c)));} +int s0R(config *c) {return word_get_R(stack_s0(config_get_stack(c)));} +int s0S(config *c) {return word_get_S(stack_s0(config_get_stack(c)));} +int s0T(config *c) {return word_get_T(stack_s0(config_get_stack(c)));} +int s0U(config *c) {return word_get_U(stack_s0(config_get_stack(c)));} +int s0V(config *c) {return word_get_V(stack_s0(config_get_stack(c)));} +int s0W(config *c) {return word_get_W(stack_s0(config_get_stack(c)));} +int s0X(config *c) {return word_get_X(stack_s0(config_get_stack(c)));} +int s0Y(config *c) {return word_get_Y(stack_s0(config_get_stack(c)));} +int s0Z(config *c) {return word_get_Z(stack_s0(config_get_stack(c)));} + +int s0U1(config *c) {return word_get_U1(stack_s0(config_get_stack(c)));} +int s0sgn(config *c) {return word_get_signature(stack_s0(config_get_stack(c)));} + +int s1f(config *c) {return word_get_form(stack_s1(config_get_stack(c)));} +int s1l(config *c) {return word_get_lemma(stack_s1(config_get_stack(c)));} +int s1c(config *c) {return word_get_cpos(stack_s1(config_get_stack(c)));} +int s1p(config *c) {return word_get_pos(stack_s1(config_get_stack(c)));} +int s1m(config *c) {return word_get_feats(stack_s1(config_get_stack(c)));} +int s1s(config *c) {return word_get_stag(stack_s1(config_get_stack(c)));} +int s1A(config *c) {return word_get_A(stack_s1(config_get_stack(c)));} +int s1B(config *c) {return word_get_B(stack_s1(config_get_stack(c)));} +int s1C(config *c) {return word_get_C(stack_s1(config_get_stack(c)));} +int s1D(config *c) {return word_get_D(stack_s1(config_get_stack(c)));} +int s1E(config *c) {return word_get_E(stack_s1(config_get_stack(c)));} +int s1F(config *c) {return word_get_F(stack_s1(config_get_stack(c)));} +int s1G(config *c) {return word_get_G(stack_s1(config_get_stack(c)));} +int s1H(config *c) {return word_get_H(stack_s1(config_get_stack(c)));} +int s1I(config *c) {return word_get_I(stack_s1(config_get_stack(c)));} +int s1J(config *c) {return word_get_J(stack_s1(config_get_stack(c)));} +int s1K(config *c) {return word_get_K(stack_s1(config_get_stack(c)));} +int s1L(config *c) {return word_get_L(stack_s1(config_get_stack(c)));} +int s1M(config *c) {return word_get_M(stack_s1(config_get_stack(c)));} +int s1N(config *c) {return word_get_N(stack_s1(config_get_stack(c)));} +int s1O(config *c) {return word_get_O(stack_s1(config_get_stack(c)));} +int s1P(config *c) {return word_get_P(stack_s1(config_get_stack(c)));} +int s1Q(config *c) {return word_get_Q(stack_s1(config_get_stack(c)));} +int s1R(config *c) {return word_get_R(stack_s1(config_get_stack(c)));} +int s1S(config *c) {return word_get_S(stack_s1(config_get_stack(c)));} +int s1T(config *c) {return word_get_T(stack_s1(config_get_stack(c)));} +int s1U(config *c) {return word_get_U(stack_s1(config_get_stack(c)));} +int s1V(config *c) {return word_get_V(stack_s1(config_get_stack(c)));} +int s1W(config *c) {return word_get_W(stack_s1(config_get_stack(c)));} +int s1X(config *c) {return word_get_X(stack_s1(config_get_stack(c)));} +int s1Y(config *c) {return word_get_Y(stack_s1(config_get_stack(c)));} +int s1Z(config *c) {return word_get_Z(stack_s1(config_get_stack(c)));} + +int s2f(config *c) {return word_get_form(stack_s2(config_get_stack(c)));} +int s2l(config *c) {return word_get_lemma(stack_s2(config_get_stack(c)));} +int s2c(config *c) {return word_get_cpos(stack_s2(config_get_stack(c)));} +int s2p(config *c) {return word_get_pos(stack_s2(config_get_stack(c)));} +int s2m(config *c) {return word_get_feats(stack_s2(config_get_stack(c)));} +int s2s(config *c) {return word_get_stag(stack_s2(config_get_stack(c)));} +int s2A(config *c) {return word_get_A(stack_s2(config_get_stack(c)));} +int s2B(config *c) {return word_get_B(stack_s2(config_get_stack(c)));} +int s2C(config *c) {return word_get_C(stack_s2(config_get_stack(c)));} +int s2D(config *c) {return word_get_D(stack_s2(config_get_stack(c)));} +int s2E(config *c) {return word_get_E(stack_s2(config_get_stack(c)));} +int s2F(config *c) {return word_get_F(stack_s2(config_get_stack(c)));} +int s2G(config *c) {return word_get_G(stack_s2(config_get_stack(c)));} +int s2H(config *c) {return word_get_H(stack_s2(config_get_stack(c)));} +int s2I(config *c) {return word_get_I(stack_s2(config_get_stack(c)));} +int s2J(config *c) {return word_get_J(stack_s2(config_get_stack(c)));} +int s2K(config *c) {return word_get_K(stack_s2(config_get_stack(c)));} +int s2L(config *c) {return word_get_L(stack_s2(config_get_stack(c)));} +int s2M(config *c) {return word_get_M(stack_s2(config_get_stack(c)));} +int s2N(config *c) {return word_get_N(stack_s2(config_get_stack(c)));} +int s2O(config *c) {return word_get_O(stack_s2(config_get_stack(c)));} +int s2P(config *c) {return word_get_P(stack_s2(config_get_stack(c)));} +int s2Q(config *c) {return word_get_Q(stack_s2(config_get_stack(c)));} +int s2R(config *c) {return word_get_R(stack_s2(config_get_stack(c)));} +int s2S(config *c) {return word_get_S(stack_s2(config_get_stack(c)));} +int s2T(config *c) {return word_get_T(stack_s2(config_get_stack(c)));} +int s2U(config *c) {return word_get_U(stack_s2(config_get_stack(c)));} +int s2V(config *c) {return word_get_V(stack_s2(config_get_stack(c)));} +int s2W(config *c) {return word_get_W(stack_s2(config_get_stack(c)));} +int s2X(config *c) {return word_get_X(stack_s2(config_get_stack(c)));} +int s2Y(config *c) {return word_get_Y(stack_s2(config_get_stack(c)));} +int s2Z(config *c) {return word_get_Z(stack_s2(config_get_stack(c)));} + +int s3f(config *c) {return word_get_form(stack_s3(config_get_stack(c)));} +int s3l(config *c) {return word_get_lemma(stack_s3(config_get_stack(c)));} +int s3c(config *c) {return word_get_cpos(stack_s3(config_get_stack(c)));} +int s3p(config *c) {return word_get_pos(stack_s3(config_get_stack(c)));} +int s3m(config *c) {return word_get_feats(stack_s3(config_get_stack(c)));} +int s3s(config *c) {return word_get_stag(stack_s3(config_get_stack(c)));} +int s3A(config *c) {return word_get_A(stack_s3(config_get_stack(c)));} +int s3B(config *c) {return word_get_B(stack_s3(config_get_stack(c)));} +int s3C(config *c) {return word_get_C(stack_s3(config_get_stack(c)));} +int s3D(config *c) {return word_get_D(stack_s3(config_get_stack(c)));} +int s3E(config *c) {return word_get_E(stack_s3(config_get_stack(c)));} +int s3F(config *c) {return word_get_F(stack_s3(config_get_stack(c)));} +int s3G(config *c) {return word_get_G(stack_s3(config_get_stack(c)));} +int s3H(config *c) {return word_get_H(stack_s3(config_get_stack(c)));} +int s3I(config *c) {return word_get_I(stack_s3(config_get_stack(c)));} +int s3J(config *c) {return word_get_J(stack_s3(config_get_stack(c)));} +int s3K(config *c) {return word_get_K(stack_s3(config_get_stack(c)));} +int s3L(config *c) {return word_get_L(stack_s3(config_get_stack(c)));} +int s3M(config *c) {return word_get_M(stack_s3(config_get_stack(c)));} +int s3N(config *c) {return word_get_N(stack_s3(config_get_stack(c)));} +int s3O(config *c) {return word_get_O(stack_s3(config_get_stack(c)));} +int s3P(config *c) {return word_get_P(stack_s3(config_get_stack(c)));} +int s3Q(config *c) {return word_get_Q(stack_s3(config_get_stack(c)));} +int s3R(config *c) {return word_get_R(stack_s3(config_get_stack(c)));} +int s3S(config *c) {return word_get_S(stack_s3(config_get_stack(c)));} +int s3T(config *c) {return word_get_T(stack_s3(config_get_stack(c)));} +int s3U(config *c) {return word_get_U(stack_s3(config_get_stack(c)));} +int s3V(config *c) {return word_get_V(stack_s3(config_get_stack(c)));} +int s3W(config *c) {return word_get_W(stack_s3(config_get_stack(c)));} +int s3X(config *c) {return word_get_X(stack_s3(config_get_stack(c)));} +int s3Y(config *c) {return word_get_Y(stack_s3(config_get_stack(c)));} +int s3Z(config *c) {return word_get_Z(stack_s3(config_get_stack(c)));} + +/* words in the buffer */ + +int b0f(config *c) {return word_get_form(word_buffer_b0(config_get_buffer(c)));} +int b0l(config *c) {return word_get_lemma(word_buffer_b0(config_get_buffer(c)));} +int b0c(config *c) {return word_get_cpos(word_buffer_b0(config_get_buffer(c)));} +int b0p(config *c) {return word_get_pos(word_buffer_b0(config_get_buffer(c)));} +int b0m(config *c) {return word_get_feats(word_buffer_b0(config_get_buffer(c)));} +int b0s(config *c) {return word_get_stag(word_buffer_b0(config_get_buffer(c)));} +int b0A(config *c) {return word_get_A(word_buffer_b0(config_get_buffer(c)));} +int b0B(config *c) {return word_get_B(word_buffer_b0(config_get_buffer(c)));} +int b0C(config *c) {return word_get_C(word_buffer_b0(config_get_buffer(c)));} +int b0D(config *c) {return word_get_D(word_buffer_b0(config_get_buffer(c)));} +int b0E(config *c) {return word_get_E(word_buffer_b0(config_get_buffer(c)));} +int b0F(config *c) {return word_get_F(word_buffer_b0(config_get_buffer(c)));} +int b0G(config *c) {return word_get_G(word_buffer_b0(config_get_buffer(c)));} +int b0H(config *c) {return word_get_H(word_buffer_b0(config_get_buffer(c)));} +int b0I(config *c) {return word_get_I(word_buffer_b0(config_get_buffer(c)));} +int b0J(config *c) {return word_get_J(word_buffer_b0(config_get_buffer(c)));} +int b0K(config *c) {return word_get_K(word_buffer_b0(config_get_buffer(c)));} +int b0L(config *c) {return word_get_L(word_buffer_b0(config_get_buffer(c)));} +int b0M(config *c) {return word_get_M(word_buffer_b0(config_get_buffer(c)));} +int b0N(config *c) {return word_get_N(word_buffer_b0(config_get_buffer(c)));} +int b0O(config *c) {return word_get_O(word_buffer_b0(config_get_buffer(c)));} +int b0P(config *c) {return word_get_P(word_buffer_b0(config_get_buffer(c)));} +int b0Q(config *c) {return word_get_Q(word_buffer_b0(config_get_buffer(c)));} +int b0R(config *c) {return word_get_R(word_buffer_b0(config_get_buffer(c)));} +int b0S(config *c) {return word_get_S(word_buffer_b0(config_get_buffer(c)));} +int b0T(config *c) {return word_get_T(word_buffer_b0(config_get_buffer(c)));} +int b0U(config *c) {return word_get_U(word_buffer_b0(config_get_buffer(c)));} +int b0V(config *c) {return word_get_V(word_buffer_b0(config_get_buffer(c)));} +int b0W(config *c) {return word_get_W(word_buffer_b0(config_get_buffer(c)));} +int b0X(config *c) {return word_get_X(word_buffer_b0(config_get_buffer(c)));} +int b0Y(config *c) {return word_get_Y(word_buffer_b0(config_get_buffer(c)));} +int b0Z(config *c) {return word_get_Z(word_buffer_b0(config_get_buffer(c)));} + +int b0U1(config *c) {return word_get_U1(word_buffer_b0(config_get_buffer(c)));} +int b0sgn(config *c) {return word_get_signature(word_buffer_b0(config_get_buffer(c)));} + +int b1f(config *c) {return word_get_form(word_buffer_b1(config_get_buffer(c)));} +int b1l(config *c) {return word_get_lemma(word_buffer_b1(config_get_buffer(c)));} +int b1c(config *c) {return word_get_cpos(word_buffer_b1(config_get_buffer(c)));} +int b1p(config *c) {return word_get_pos(word_buffer_b1(config_get_buffer(c)));} +int b1m(config *c) {return word_get_feats(word_buffer_b1(config_get_buffer(c)));} +int b1s(config *c) {return word_get_stag(word_buffer_b1(config_get_buffer(c)));} +int b1A(config *c) {return word_get_A(word_buffer_b1(config_get_buffer(c)));} +int b1B(config *c) {return word_get_B(word_buffer_b1(config_get_buffer(c)));} +int b1C(config *c) {return word_get_C(word_buffer_b1(config_get_buffer(c)));} +int b1D(config *c) {return word_get_D(word_buffer_b1(config_get_buffer(c)));} +int b1E(config *c) {return word_get_E(word_buffer_b1(config_get_buffer(c)));} +int b1F(config *c) {return word_get_F(word_buffer_b1(config_get_buffer(c)));} +int b1G(config *c) {return word_get_G(word_buffer_b1(config_get_buffer(c)));} +int b1H(config *c) {return word_get_H(word_buffer_b1(config_get_buffer(c)));} +int b1I(config *c) {return word_get_I(word_buffer_b1(config_get_buffer(c)));} +int b1J(config *c) {return word_get_J(word_buffer_b1(config_get_buffer(c)));} +int b1K(config *c) {return word_get_K(word_buffer_b1(config_get_buffer(c)));} +int b1L(config *c) {return word_get_L(word_buffer_b1(config_get_buffer(c)));} +int b1M(config *c) {return word_get_M(word_buffer_b1(config_get_buffer(c)));} +int b1N(config *c) {return word_get_N(word_buffer_b1(config_get_buffer(c)));} +int b1O(config *c) {return word_get_O(word_buffer_b1(config_get_buffer(c)));} +int b1P(config *c) {return word_get_P(word_buffer_b1(config_get_buffer(c)));} +int b1Q(config *c) {return word_get_Q(word_buffer_b1(config_get_buffer(c)));} +int b1R(config *c) {return word_get_R(word_buffer_b1(config_get_buffer(c)));} +int b1S(config *c) {return word_get_S(word_buffer_b1(config_get_buffer(c)));} +int b1T(config *c) {return word_get_T(word_buffer_b1(config_get_buffer(c)));} +int b1U(config *c) {return word_get_U(word_buffer_b1(config_get_buffer(c)));} +int b1V(config *c) {return word_get_V(word_buffer_b1(config_get_buffer(c)));} +int b1W(config *c) {return word_get_W(word_buffer_b1(config_get_buffer(c)));} +int b1X(config *c) {return word_get_X(word_buffer_b1(config_get_buffer(c)));} +int b1Y(config *c) {return word_get_Y(word_buffer_b1(config_get_buffer(c)));} +int b1Z(config *c) {return word_get_Z(word_buffer_b1(config_get_buffer(c)));} + +int b1U1(config *c) {return word_get_U1(word_buffer_b1(config_get_buffer(c)));} +int b1sgn(config *c) {return word_get_signature(word_buffer_b1(config_get_buffer(c)));} + +int b2f(config *c) {return word_get_form(word_buffer_b2(config_get_buffer(c)));} +int b2l(config *c) {return word_get_lemma(word_buffer_b2(config_get_buffer(c)));} +int b2c(config *c) {return word_get_cpos(word_buffer_b2(config_get_buffer(c)));} +int b2p(config *c) {return word_get_pos(word_buffer_b2(config_get_buffer(c)));} +int b2m(config *c) {return word_get_feats(word_buffer_b2(config_get_buffer(c)));} +int b2s(config *c) {return word_get_stag(word_buffer_b2(config_get_buffer(c)));} +int b2A(config *c) {return word_get_A(word_buffer_b2(config_get_buffer(c)));} +int b2B(config *c) {return word_get_B(word_buffer_b2(config_get_buffer(c)));} +int b2C(config *c) {return word_get_C(word_buffer_b2(config_get_buffer(c)));} +int b2D(config *c) {return word_get_D(word_buffer_b2(config_get_buffer(c)));} +int b2E(config *c) {return word_get_E(word_buffer_b2(config_get_buffer(c)));} +int b2F(config *c) {return word_get_F(word_buffer_b2(config_get_buffer(c)));} +int b2G(config *c) {return word_get_G(word_buffer_b2(config_get_buffer(c)));} +int b2H(config *c) {return word_get_H(word_buffer_b2(config_get_buffer(c)));} +int b2I(config *c) {return word_get_I(word_buffer_b2(config_get_buffer(c)));} +int b2J(config *c) {return word_get_J(word_buffer_b2(config_get_buffer(c)));} +int b2K(config *c) {return word_get_K(word_buffer_b2(config_get_buffer(c)));} +int b2L(config *c) {return word_get_L(word_buffer_b2(config_get_buffer(c)));} +int b2M(config *c) {return word_get_M(word_buffer_b2(config_get_buffer(c)));} +int b2N(config *c) {return word_get_N(word_buffer_b2(config_get_buffer(c)));} +int b2O(config *c) {return word_get_O(word_buffer_b2(config_get_buffer(c)));} +int b2P(config *c) {return word_get_P(word_buffer_b2(config_get_buffer(c)));} +int b2Q(config *c) {return word_get_Q(word_buffer_b2(config_get_buffer(c)));} +int b2R(config *c) {return word_get_R(word_buffer_b2(config_get_buffer(c)));} +int b2S(config *c) {return word_get_S(word_buffer_b2(config_get_buffer(c)));} +int b2T(config *c) {return word_get_T(word_buffer_b2(config_get_buffer(c)));} +int b2U(config *c) {return word_get_U(word_buffer_b2(config_get_buffer(c)));} +int b2V(config *c) {return word_get_V(word_buffer_b2(config_get_buffer(c)));} +int b2W(config *c) {return word_get_W(word_buffer_b2(config_get_buffer(c)));} +int b2X(config *c) {return word_get_X(word_buffer_b2(config_get_buffer(c)));} +int b2Y(config *c) {return word_get_Y(word_buffer_b2(config_get_buffer(c)));} +int b2Z(config *c) {return word_get_Z(word_buffer_b2(config_get_buffer(c)));} + +int b3f(config *c) {return word_get_form(word_buffer_b3(config_get_buffer(c)));} +int b3l(config *c) {return word_get_lemma(word_buffer_b3(config_get_buffer(c)));} +int b3c(config *c) {return word_get_cpos(word_buffer_b3(config_get_buffer(c)));} +int b3p(config *c) {return word_get_pos(word_buffer_b3(config_get_buffer(c)));} +int b3m(config *c) {return word_get_feats(word_buffer_b3(config_get_buffer(c)));} +int b3s(config *c) {return word_get_stag(word_buffer_b3(config_get_buffer(c)));} +int b3A(config *c) {return word_get_A(word_buffer_b3(config_get_buffer(c)));} +int b3B(config *c) {return word_get_B(word_buffer_b3(config_get_buffer(c)));} +int b3C(config *c) {return word_get_C(word_buffer_b3(config_get_buffer(c)));} +int b3D(config *c) {return word_get_D(word_buffer_b3(config_get_buffer(c)));} +int b3E(config *c) {return word_get_E(word_buffer_b3(config_get_buffer(c)));} +int b3F(config *c) {return word_get_F(word_buffer_b3(config_get_buffer(c)));} +int b3G(config *c) {return word_get_G(word_buffer_b3(config_get_buffer(c)));} +int b3H(config *c) {return word_get_H(word_buffer_b3(config_get_buffer(c)));} +int b3I(config *c) {return word_get_I(word_buffer_b3(config_get_buffer(c)));} +int b3J(config *c) {return word_get_J(word_buffer_b3(config_get_buffer(c)));} +int b3K(config *c) {return word_get_K(word_buffer_b3(config_get_buffer(c)));} +int b3L(config *c) {return word_get_L(word_buffer_b3(config_get_buffer(c)));} +int b3M(config *c) {return word_get_M(word_buffer_b3(config_get_buffer(c)));} +int b3N(config *c) {return word_get_N(word_buffer_b3(config_get_buffer(c)));} +int b3O(config *c) {return word_get_O(word_buffer_b3(config_get_buffer(c)));} +int b3P(config *c) {return word_get_P(word_buffer_b3(config_get_buffer(c)));} +int b3Q(config *c) {return word_get_Q(word_buffer_b3(config_get_buffer(c)));} +int b3R(config *c) {return word_get_R(word_buffer_b3(config_get_buffer(c)));} +int b3S(config *c) {return word_get_S(word_buffer_b3(config_get_buffer(c)));} +int b3T(config *c) {return word_get_T(word_buffer_b3(config_get_buffer(c)));} +int b3U(config *c) {return word_get_U(word_buffer_b3(config_get_buffer(c)));} +int b3V(config *c) {return word_get_V(word_buffer_b3(config_get_buffer(c)));} +int b3W(config *c) {return word_get_W(word_buffer_b3(config_get_buffer(c)));} +int b3X(config *c) {return word_get_X(word_buffer_b3(config_get_buffer(c)));} +int b3Y(config *c) {return word_get_Y(word_buffer_b3(config_get_buffer(c)));} +int b3Z(config *c) {return word_get_Z(word_buffer_b3(config_get_buffer(c)));} + +int bm1f(config *c) {return word_get_form(word_buffer_bm1(config_get_buffer(c)));} +int bm1l(config *c) {return word_get_lemma(word_buffer_bm1(config_get_buffer(c)));} +int bm1c(config *c) {return word_get_cpos(word_buffer_bm1(config_get_buffer(c)));} +int bm1p(config *c) {return word_get_pos(word_buffer_bm1(config_get_buffer(c)));} +int bm1m(config *c) {return word_get_feats(word_buffer_bm1(config_get_buffer(c)));} +int bm1s(config *c) {return word_get_stag(word_buffer_bm1(config_get_buffer(c)));} +int bm1A(config *c) {return word_get_A(word_buffer_bm1(config_get_buffer(c)));} +int bm1B(config *c) {return word_get_B(word_buffer_bm1(config_get_buffer(c)));} +int bm1C(config *c) {return word_get_C(word_buffer_bm1(config_get_buffer(c)));} +int bm1D(config *c) {return word_get_D(word_buffer_bm1(config_get_buffer(c)));} +int bm1E(config *c) {return word_get_E(word_buffer_bm1(config_get_buffer(c)));} +int bm1F(config *c) {return word_get_F(word_buffer_bm1(config_get_buffer(c)));} +int bm1G(config *c) {return word_get_G(word_buffer_bm1(config_get_buffer(c)));} +int bm1H(config *c) {return word_get_H(word_buffer_bm1(config_get_buffer(c)));} +int bm1I(config *c) {return word_get_I(word_buffer_bm1(config_get_buffer(c)));} +int bm1J(config *c) {return word_get_J(word_buffer_bm1(config_get_buffer(c)));} +int bm1K(config *c) {return word_get_K(word_buffer_bm1(config_get_buffer(c)));} +int bm1L(config *c) {return word_get_L(word_buffer_bm1(config_get_buffer(c)));} +int bm1M(config *c) {return word_get_M(word_buffer_bm1(config_get_buffer(c)));} +int bm1N(config *c) {return word_get_N(word_buffer_bm1(config_get_buffer(c)));} +int bm1O(config *c) {return word_get_O(word_buffer_bm1(config_get_buffer(c)));} +int bm1P(config *c) {return word_get_P(word_buffer_bm1(config_get_buffer(c)));} +int bm1Q(config *c) {return word_get_Q(word_buffer_bm1(config_get_buffer(c)));} +int bm1R(config *c) {return word_get_R(word_buffer_bm1(config_get_buffer(c)));} +int bm1S(config *c) {return word_get_S(word_buffer_bm1(config_get_buffer(c)));} +int bm1T(config *c) {return word_get_T(word_buffer_bm1(config_get_buffer(c)));} +int bm1U(config *c) {return word_get_U(word_buffer_bm1(config_get_buffer(c)));} +int bm1V(config *c) {return word_get_V(word_buffer_bm1(config_get_buffer(c)));} +int bm1W(config *c) {return word_get_W(word_buffer_bm1(config_get_buffer(c)));} +int bm1X(config *c) {return word_get_X(word_buffer_bm1(config_get_buffer(c)));} +int bm1Y(config *c) {return word_get_Y(word_buffer_bm1(config_get_buffer(c)));} +int bm1Z(config *c) {return word_get_Z(word_buffer_bm1(config_get_buffer(c)));} + +int bm1U1(config *c) {return word_get_U1(word_buffer_bm1(config_get_buffer(c)));} +int bm1sgn(config *c) {return word_get_signature(word_buffer_bm1(config_get_buffer(c)));} + +int bm2f(config *c) {return word_get_form(word_buffer_bm2(config_get_buffer(c)));} +int bm2l(config *c) {return word_get_lemma(word_buffer_bm2(config_get_buffer(c)));} +int bm2c(config *c) {return word_get_cpos(word_buffer_bm2(config_get_buffer(c)));} +int bm2p(config *c) {return word_get_pos(word_buffer_bm2(config_get_buffer(c)));} +int bm2m(config *c) {return word_get_feats(word_buffer_bm2(config_get_buffer(c)));} +int bm2s(config *c) {return word_get_stag(word_buffer_bm2(config_get_buffer(c)));} +int bm2A(config *c) {return word_get_A(word_buffer_bm2(config_get_buffer(c)));} +int bm2B(config *c) {return word_get_B(word_buffer_bm2(config_get_buffer(c)));} +int bm2C(config *c) {return word_get_C(word_buffer_bm2(config_get_buffer(c)));} +int bm2D(config *c) {return word_get_D(word_buffer_bm2(config_get_buffer(c)));} +int bm2E(config *c) {return word_get_E(word_buffer_bm2(config_get_buffer(c)));} +int bm2F(config *c) {return word_get_F(word_buffer_bm2(config_get_buffer(c)));} +int bm2G(config *c) {return word_get_G(word_buffer_bm2(config_get_buffer(c)));} +int bm2H(config *c) {return word_get_H(word_buffer_bm2(config_get_buffer(c)));} +int bm2I(config *c) {return word_get_I(word_buffer_bm2(config_get_buffer(c)));} +int bm2J(config *c) {return word_get_J(word_buffer_bm2(config_get_buffer(c)));} +int bm2K(config *c) {return word_get_K(word_buffer_bm2(config_get_buffer(c)));} +int bm2L(config *c) {return word_get_L(word_buffer_bm2(config_get_buffer(c)));} +int bm2M(config *c) {return word_get_M(word_buffer_bm2(config_get_buffer(c)));} +int bm2N(config *c) {return word_get_N(word_buffer_bm2(config_get_buffer(c)));} +int bm2O(config *c) {return word_get_O(word_buffer_bm2(config_get_buffer(c)));} +int bm2P(config *c) {return word_get_P(word_buffer_bm2(config_get_buffer(c)));} +int bm2Q(config *c) {return word_get_Q(word_buffer_bm2(config_get_buffer(c)));} +int bm2R(config *c) {return word_get_R(word_buffer_bm2(config_get_buffer(c)));} +int bm2S(config *c) {return word_get_S(word_buffer_bm2(config_get_buffer(c)));} +int bm2T(config *c) {return word_get_T(word_buffer_bm2(config_get_buffer(c)));} +int bm2U(config *c) {return word_get_U(word_buffer_bm2(config_get_buffer(c)));} +int bm2V(config *c) {return word_get_V(word_buffer_bm2(config_get_buffer(c)));} +int bm2W(config *c) {return word_get_W(word_buffer_bm2(config_get_buffer(c)));} +int bm2X(config *c) {return word_get_X(word_buffer_bm2(config_get_buffer(c)));} +int bm2Y(config *c) {return word_get_Y(word_buffer_bm2(config_get_buffer(c)));} +int bm2Z(config *c) {return word_get_Z(word_buffer_bm2(config_get_buffer(c)));} + +int bm3f(config *c) {return word_get_form(word_buffer_bm3(config_get_buffer(c)));} +int bm3l(config *c) {return word_get_lemma(word_buffer_bm3(config_get_buffer(c)));} +int bm3c(config *c) {return word_get_cpos(word_buffer_bm3(config_get_buffer(c)));} +int bm3p(config *c) {return word_get_pos(word_buffer_bm3(config_get_buffer(c)));} +int bm3m(config *c) {return word_get_feats(word_buffer_bm3(config_get_buffer(c)));} +int bm3s(config *c) {return word_get_stag(word_buffer_bm3(config_get_buffer(c)));} +int bm3A(config *c) {return word_get_A(word_buffer_bm3(config_get_buffer(c)));} +int bm3B(config *c) {return word_get_B(word_buffer_bm3(config_get_buffer(c)));} +int bm3C(config *c) {return word_get_C(word_buffer_bm3(config_get_buffer(c)));} +int bm3D(config *c) {return word_get_D(word_buffer_bm3(config_get_buffer(c)));} +int bm3E(config *c) {return word_get_E(word_buffer_bm3(config_get_buffer(c)));} +int bm3F(config *c) {return word_get_F(word_buffer_bm3(config_get_buffer(c)));} +int bm3G(config *c) {return word_get_G(word_buffer_bm3(config_get_buffer(c)));} +int bm3H(config *c) {return word_get_H(word_buffer_bm3(config_get_buffer(c)));} +int bm3I(config *c) {return word_get_I(word_buffer_bm3(config_get_buffer(c)));} +int bm3J(config *c) {return word_get_J(word_buffer_bm3(config_get_buffer(c)));} +int bm3K(config *c) {return word_get_K(word_buffer_bm3(config_get_buffer(c)));} +int bm3L(config *c) {return word_get_L(word_buffer_bm3(config_get_buffer(c)));} +int bm3M(config *c) {return word_get_M(word_buffer_bm3(config_get_buffer(c)));} +int bm3N(config *c) {return word_get_N(word_buffer_bm3(config_get_buffer(c)));} +int bm3O(config *c) {return word_get_O(word_buffer_bm3(config_get_buffer(c)));} +int bm3P(config *c) {return word_get_P(word_buffer_bm3(config_get_buffer(c)));} +int bm3Q(config *c) {return word_get_Q(word_buffer_bm3(config_get_buffer(c)));} +int bm3R(config *c) {return word_get_R(word_buffer_bm3(config_get_buffer(c)));} +int bm3S(config *c) {return word_get_S(word_buffer_bm3(config_get_buffer(c)));} +int bm3T(config *c) {return word_get_T(word_buffer_bm3(config_get_buffer(c)));} +int bm3U(config *c) {return word_get_U(word_buffer_bm3(config_get_buffer(c)));} +int bm3V(config *c) {return word_get_V(word_buffer_bm3(config_get_buffer(c)));} +int bm3W(config *c) {return word_get_W(word_buffer_bm3(config_get_buffer(c)));} +int bm3X(config *c) {return word_get_X(word_buffer_bm3(config_get_buffer(c)));} +int bm3Y(config *c) {return word_get_Y(word_buffer_bm3(config_get_buffer(c)));} +int bm3Z(config *c) {return word_get_Z(word_buffer_bm3(config_get_buffer(c)));} /* structural features */ @@ -334,7 +438,7 @@ int rdep_s0r(config *c){ }*/ int ldep_b0r(config *c){ - word *top = queue_elt_n(c->bf,0); + word *top = word_buffer_b0(c->bf); int i; if(top){ @@ -360,7 +464,7 @@ int ldep_b0r(config *c){ }*/ int rdep_b0r(config *c){ - word *top = queue_elt_n(c->bf,0); + word *top = word_buffer_b0(c->bf); int i; if(top) @@ -390,7 +494,7 @@ int rdep_b0r(config *c){ int ndep_b0(config *c){ - word *top = queue_elt_n(c->bf,0); + word *top = word_buffer_b0(c->bf); int i = 0; int n = 0; @@ -438,10 +542,10 @@ int ndep_s0(config *c){ int dist_s0_b0(config *c){ int dist; - if(stack_is_empty(c->st) || queue_is_empty(c->bf)) + if(stack_is_empty(c->st) || word_buffer_is_empty(c->bf)) return 0; - dist = word_get_relative_index(queue_elt_n(c->bf,0)) - word_get_relative_index(stack_top(c->st)); + dist = word_get_relative_index(word_buffer_b0(c->bf)) - word_get_relative_index(stack_top(c->st)); return (abs(dist) > 6)? 6 : dist; } diff --git a/maca_trans_parser/src/feat_fct.h b/maca_trans_parser/src/feat_fct.h index cce0f63febd02a6ac80c0000023645b9603ec309..84f8b2adacab1ec71540ef6fde58490b794373e3 100644 --- a/maca_trans_parser/src/feat_fct.h +++ b/maca_trans_parser/src/feat_fct.h @@ -296,6 +296,109 @@ int b3Z(config *c); int b3r(config *c); + +int bm1f(config *c); +int bm1l(config *c); +int bm1c(config *c); +int bm1p(config *c); +int bm1m(config *c); +int bm1s(config *c); +int bm1A(config *c); +int bm1B(config *c); +int bm1C(config *c); +int bm1D(config *c); +int bm1E(config *c); +int bm1F(config *c); +int bm1G(config *c); +int bm1H(config *c); +int bm1I(config *c); +int bm1J(config *c); +int bm1K(config *c); +int bm1L(config *c); +int bm1M(config *c); +int bm1N(config *c); +int bm1O(config *c); +int bm1P(config *c); +int bm1Q(config *c); +int bm1R(config *c); +int bm1S(config *c); +int bm1T(config *c); +int bm1U(config *c); +int bm1V(config *c); +int bm1W(config *c); +int bm1X(config *c); +int bm1Y(config *c); +int bm1Z(config *c); + +int bm1U1(config *c); +int bm1sgn(config *c); + +int bm2f(config *c); +int bm2l(config *c); +int bm2c(config *c); +int bm2p(config *c); +int bm2m(config *c); +int bm2s(config *c); +int bm2A(config *c); +int bm2B(config *c); +int bm2C(config *c); +int bm2D(config *c); +int bm2E(config *c); +int bm2F(config *c); +int bm2G(config *c); +int bm2H(config *c); +int bm2I(config *c); +int bm2J(config *c); +int bm2K(config *c); +int bm2L(config *c); +int bm2M(config *c); +int bm2N(config *c); +int bm2O(config *c); +int bm2P(config *c); +int bm2Q(config *c); +int bm2R(config *c); +int bm2S(config *c); +int bm2T(config *c); +int bm2U(config *c); +int bm2V(config *c); +int bm2W(config *c); +int bm2X(config *c); +int bm2Y(config *c); +int bm2Z(config *c); + +int bm3f(config *c); +int bm3l(config *c); +int bm3c(config *c); +int bm3p(config *c); +int bm3m(config *c); +int bm3s(config *c); +int bm3A(config *c); +int bm3B(config *c); +int bm3C(config *c); +int bm3D(config *c); +int bm3E(config *c); +int bm3F(config *c); +int bm3G(config *c); +int bm3H(config *c); +int bm3I(config *c); +int bm3J(config *c); +int bm3K(config *c); +int bm3L(config *c); +int bm3M(config *c); +int bm3N(config *c); +int bm3O(config *c); +int bm3P(config *c); +int bm3Q(config *c); +int bm3R(config *c); +int bm3S(config *c); +int bm3T(config *c); +int bm3U(config *c); +int bm3V(config *c); +int bm3W(config *c); +int bm3X(config *c); +int bm3Y(config *c); +int bm3Z(config *c); + /* structural features */ int gs0l(config *c); diff --git a/maca_trans_parser/src/feat_lib.c b/maca_trans_parser/src/feat_lib.c index a75a8130e5be273cd76a5910b74abc5df9b19076..1567bd72904f9042a2d129df18f396109926e8c7 100644 --- a/maca_trans_parser/src/feat_lib.c +++ b/maca_trans_parser/src/feat_lib.c @@ -66,10 +66,8 @@ feat_lib *feat_lib_build(void) feat_lib_add(fl, FEAT_TYPE_X, (char *)"s0X", s0X); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"s0Y", s0Y); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"s0Z", s0Z); - - feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"s0U1", s0U1); - feat_lib_add(fl, FEAT_TYPE_INT, (char *)"s0sgn", s0sgn); - + feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"s0U1", s0U1); + feat_lib_add(fl, FEAT_TYPE_INT, (char *)"s0sgn", s0sgn); feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"s1f", s1f); feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"s1l", s1l); @@ -104,8 +102,6 @@ feat_lib *feat_lib_build(void) feat_lib_add(fl, FEAT_TYPE_X, (char *)"s1X", s1X); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"s1Y", s1Y); feat_lib_add(fl, FEAT_TYPE_Z, (char *)"s1Z", s1Z); - - feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"s2f", s2f); feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"s2l", s2l); @@ -140,9 +136,6 @@ feat_lib *feat_lib_build(void) feat_lib_add(fl, FEAT_TYPE_X, (char *)"s2X", s2X); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"s2Y", s2Y); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"s2Z", s2Z); - - - feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"s3f", s3f); feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"s3l", s3l); @@ -178,7 +171,6 @@ feat_lib *feat_lib_build(void) feat_lib_add(fl, FEAT_TYPE_Y, (char *)"s3Y", s3Y); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"s3Z", s3Z); - feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"b0f", b0f); feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"b0l", b0l); feat_lib_add(fl, FEAT_TYPE_CPOS, (char *)"b0c", b0c); @@ -212,9 +204,116 @@ feat_lib *feat_lib_build(void) feat_lib_add(fl, FEAT_TYPE_X, (char *)"b0X", b0X); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"b0Y", b0Y); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"b0Z", b0Z); + feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"b0U1", b0U1); + feat_lib_add(fl, FEAT_TYPE_INT, (char *)"b0sgn", b0sgn); - feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"b0U1", b0U1); - feat_lib_add(fl, FEAT_TYPE_INT, (char *)"b0sgn", b0sgn); + feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"bm1f", bm1f); + feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"bm1l", bm1l); + feat_lib_add(fl, FEAT_TYPE_CPOS, (char *)"bm1c", bm1c); + feat_lib_add(fl, FEAT_TYPE_POS, (char *)"bm1p", bm1p); + feat_lib_add(fl, FEAT_TYPE_FEATS, (char *)"bm1m", bm1m); + feat_lib_add(fl, FEAT_TYPE_STAG, (char *)"bm1s", bm1s); + /* feat_lib_add(fl, FEAT_TYPE_LABEL, (char *)"bm1r", bm1r); */ + feat_lib_add(fl, FEAT_TYPE_A, (char *)"bm1A", bm1A); + feat_lib_add(fl, FEAT_TYPE_B, (char *)"bm1B", bm1B); + feat_lib_add(fl, FEAT_TYPE_C, (char *)"bm1C", bm1C); + feat_lib_add(fl, FEAT_TYPE_D, (char *)"bm1D", bm1D); + feat_lib_add(fl, FEAT_TYPE_E, (char *)"bm1E", bm1E); + feat_lib_add(fl, FEAT_TYPE_F, (char *)"bm1F", bm1F); + feat_lib_add(fl, FEAT_TYPE_G, (char *)"bm1G", bm1G); + feat_lib_add(fl, FEAT_TYPE_H, (char *)"bm1H", bm1H); + feat_lib_add(fl, FEAT_TYPE_I, (char *)"bm1I", bm1I); + feat_lib_add(fl, FEAT_TYPE_J, (char *)"bm1J", bm1J); + feat_lib_add(fl, FEAT_TYPE_K, (char *)"bm1K", bm1K); + feat_lib_add(fl, FEAT_TYPE_L, (char *)"bm1L", bm1L); + feat_lib_add(fl, FEAT_TYPE_M, (char *)"bm1M", bm1M); + feat_lib_add(fl, FEAT_TYPE_N, (char *)"bm1N", bm1N); + feat_lib_add(fl, FEAT_TYPE_O, (char *)"bm1O", bm1O); + feat_lib_add(fl, FEAT_TYPE_P, (char *)"bm1P", bm1P); + feat_lib_add(fl, FEAT_TYPE_Q, (char *)"bm1Q", bm1Q); + feat_lib_add(fl, FEAT_TYPE_R, (char *)"bm1R", bm1R); + feat_lib_add(fl, FEAT_TYPE_S, (char *)"bm1S", bm1S); + feat_lib_add(fl, FEAT_TYPE_T, (char *)"bm1T", bm1T); + feat_lib_add(fl, FEAT_TYPE_U, (char *)"bm1U", bm1U); + feat_lib_add(fl, FEAT_TYPE_V, (char *)"bm1V", bm1V); + feat_lib_add(fl, FEAT_TYPE_W, (char *)"bm1W", bm1W); + feat_lib_add(fl, FEAT_TYPE_X, (char *)"bm1X", bm1X); + feat_lib_add(fl, FEAT_TYPE_Y, (char *)"bm1Y", bm1Y); + feat_lib_add(fl, FEAT_TYPE_Y, (char *)"bm1Z", bm1Z); + feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"bm1U1", bm1U1); + feat_lib_add(fl, FEAT_TYPE_INT, (char *)"bm1sgn", bm1sgn); + + feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"bm2f", bm2f); + feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"bm2l", bm2l); + feat_lib_add(fl, FEAT_TYPE_CPOS, (char *)"bm2c", bm2c); + feat_lib_add(fl, FEAT_TYPE_POS, (char *)"bm2p", bm2p); + feat_lib_add(fl, FEAT_TYPE_FEATS, (char *)"bm2m", bm2m); + feat_lib_add(fl, FEAT_TYPE_STAG, (char *)"bm2s", bm2s); + /* feat_lib_add(fl, FEAT_TYPE_LABEL, (char *)"bm2r", bm2r); */ + feat_lib_add(fl, FEAT_TYPE_A, (char *)"bm2A", bm2A); + feat_lib_add(fl, FEAT_TYPE_B, (char *)"bm2B", bm2B); + feat_lib_add(fl, FEAT_TYPE_C, (char *)"bm2C", bm2C); + feat_lib_add(fl, FEAT_TYPE_D, (char *)"bm2D", bm2D); + feat_lib_add(fl, FEAT_TYPE_E, (char *)"bm2E", bm2E); + feat_lib_add(fl, FEAT_TYPE_F, (char *)"bm2F", bm2F); + feat_lib_add(fl, FEAT_TYPE_G, (char *)"bm2G", bm2G); + feat_lib_add(fl, FEAT_TYPE_H, (char *)"bm2H", bm2H); + feat_lib_add(fl, FEAT_TYPE_I, (char *)"bm2I", bm2I); + feat_lib_add(fl, FEAT_TYPE_J, (char *)"bm2J", bm2J); + feat_lib_add(fl, FEAT_TYPE_K, (char *)"bm2K", bm2K); + feat_lib_add(fl, FEAT_TYPE_L, (char *)"bm2L", bm2L); + feat_lib_add(fl, FEAT_TYPE_M, (char *)"bm2M", bm2M); + feat_lib_add(fl, FEAT_TYPE_N, (char *)"bm2N", bm2N); + feat_lib_add(fl, FEAT_TYPE_O, (char *)"bm2O", bm2O); + feat_lib_add(fl, FEAT_TYPE_P, (char *)"bm2P", bm2P); + feat_lib_add(fl, FEAT_TYPE_Q, (char *)"bm2Q", bm2Q); + feat_lib_add(fl, FEAT_TYPE_R, (char *)"bm2R", bm2R); + feat_lib_add(fl, FEAT_TYPE_S, (char *)"bm2S", bm2S); + feat_lib_add(fl, FEAT_TYPE_T, (char *)"bm2T", bm2T); + feat_lib_add(fl, FEAT_TYPE_U, (char *)"bm2U", bm2U); + feat_lib_add(fl, FEAT_TYPE_V, (char *)"bm2V", bm2V); + feat_lib_add(fl, FEAT_TYPE_W, (char *)"bm2W", bm2W); + feat_lib_add(fl, FEAT_TYPE_X, (char *)"bm2X", bm2X); + feat_lib_add(fl, FEAT_TYPE_Y, (char *)"bm2Y", bm2Y); + feat_lib_add(fl, FEAT_TYPE_Y, (char *)"bm2Z", bm2Z); + /* feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"bm2U1", bm2U1); */ + /* feat_lib_add(fl, FEAT_TYPE_INT, (char *)"bm2sgn", bm2sgn); */ + + feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"bm3f", bm3f); + feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"bm3l", bm3l); + feat_lib_add(fl, FEAT_TYPE_CPOS, (char *)"bm3c", bm3c); + feat_lib_add(fl, FEAT_TYPE_POS, (char *)"bm3p", bm3p); + feat_lib_add(fl, FEAT_TYPE_FEATS, (char *)"bm3m", bm3m); + feat_lib_add(fl, FEAT_TYPE_STAG, (char *)"bm3s", bm3s); + /* feat_lib_add(fl, FEAT_TYPE_LABEL, (char *)"bm3r", bm3r); */ + feat_lib_add(fl, FEAT_TYPE_A, (char *)"bm3A", bm3A); + feat_lib_add(fl, FEAT_TYPE_B, (char *)"bm3B", bm3B); + feat_lib_add(fl, FEAT_TYPE_C, (char *)"bm3C", bm3C); + feat_lib_add(fl, FEAT_TYPE_D, (char *)"bm3D", bm3D); + feat_lib_add(fl, FEAT_TYPE_E, (char *)"bm3E", bm3E); + feat_lib_add(fl, FEAT_TYPE_F, (char *)"bm3F", bm3F); + feat_lib_add(fl, FEAT_TYPE_G, (char *)"bm3G", bm3G); + feat_lib_add(fl, FEAT_TYPE_H, (char *)"bm3H", bm3H); + feat_lib_add(fl, FEAT_TYPE_I, (char *)"bm3I", bm3I); + feat_lib_add(fl, FEAT_TYPE_J, (char *)"bm3J", bm3J); + feat_lib_add(fl, FEAT_TYPE_K, (char *)"bm3K", bm3K); + feat_lib_add(fl, FEAT_TYPE_L, (char *)"bm3L", bm3L); + feat_lib_add(fl, FEAT_TYPE_M, (char *)"bm3M", bm3M); + feat_lib_add(fl, FEAT_TYPE_N, (char *)"bm3N", bm3N); + feat_lib_add(fl, FEAT_TYPE_O, (char *)"bm3O", bm3O); + feat_lib_add(fl, FEAT_TYPE_P, (char *)"bm3P", bm3P); + feat_lib_add(fl, FEAT_TYPE_Q, (char *)"bm3Q", bm3Q); + feat_lib_add(fl, FEAT_TYPE_R, (char *)"bm3R", bm3R); + feat_lib_add(fl, FEAT_TYPE_S, (char *)"bm3S", bm3S); + feat_lib_add(fl, FEAT_TYPE_T, (char *)"bm3T", bm3T); + feat_lib_add(fl, FEAT_TYPE_U, (char *)"bm3U", bm3U); + feat_lib_add(fl, FEAT_TYPE_V, (char *)"bm3V", bm3V); + feat_lib_add(fl, FEAT_TYPE_W, (char *)"bm3W", bm3W); + feat_lib_add(fl, FEAT_TYPE_X, (char *)"bm3X", bm3X); + feat_lib_add(fl, FEAT_TYPE_Y, (char *)"bm3Y", bm3Y); + feat_lib_add(fl, FEAT_TYPE_Y, (char *)"bm3Z", bm3Z); + /* feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"bm3U1", bm3U1); */ + /* feat_lib_add(fl, FEAT_TYPE_INT, (char *)"bm3sgn", bm3sgn); */ feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"b1f", b1f); feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"b1l", b1l); @@ -249,10 +348,8 @@ feat_lib *feat_lib_build(void) feat_lib_add(fl, FEAT_TYPE_X, (char *)"b1X", b1X); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"b1Y", b1Y); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"b1Z", b1Z); - - feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"b1U1", b1U1); - feat_lib_add(fl, FEAT_TYPE_INT, (char *)"b1sgn", b1sgn); - + feat_lib_add(fl, FEAT_TYPE_INT_3, (char *)"b1U1", b1U1); + feat_lib_add(fl, FEAT_TYPE_INT, (char *)"b1sgn", b1sgn); feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"b2f", b2f); feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"b2l", b2l); @@ -288,8 +385,6 @@ feat_lib *feat_lib_build(void) feat_lib_add(fl, FEAT_TYPE_Y, (char *)"b2Y", b2Y); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"b2Z", b2Z); - - feat_lib_add(fl, FEAT_TYPE_FORM, (char *)"b3f", b3f); feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"b3l", b3l); feat_lib_add(fl, FEAT_TYPE_CPOS, (char *)"b3c", b3c); @@ -324,8 +419,6 @@ feat_lib *feat_lib_build(void) feat_lib_add(fl, FEAT_TYPE_Y, (char *)"b3Y", b3Y); feat_lib_add(fl, FEAT_TYPE_Y, (char *)"b3Z", b3Z); - - /* feat_lib_add(fl, FEAT_TYPE_LEMMA, (char *)"gs0l", gs0l); */ /* feat_lib_add(fl, FEAT_TYPE_POS, (char *)"gs0p", gs0p); */ diff --git a/maca_trans_parser/src/maca_trans_parser_mcf2cff.c b/maca_trans_parser/src/maca_trans_parser_mcf2cff.c index d920d327b1d7e4ba855b19108ec160a58226474d..64cd4dfbc8bbfe9b2b365a019783d2413ca9061a 100644 --- a/maca_trans_parser/src/maca_trans_parser_mcf2cff.c +++ b/maca_trans_parser/src/maca_trans_parser_mcf2cff.c @@ -3,8 +3,8 @@ #include<string.h> #include<unistd.h> #include<getopt.h> -#include"movement_parser.h" -#include"oracle_parser.h" +#include"movement_parser_arc_eager.h" +#include"oracle_parser_arc_eager.h" #include"feat_fct.h" #include"context.h" #include"feat_vec.h" @@ -12,7 +12,7 @@ #include"word_emb.h" #include"config2feat_vec.h" -void maca_trans_parser_conll2cff_help_message(context *ctx) +void maca_trans_parser_mcf2cff_help_message(context *ctx) { context_general_help_message(ctx); context_mode_help_message(ctx); @@ -30,14 +30,14 @@ void maca_trans_parser_conll2cff_help_message(context *ctx) } -void maca_trans_parser_conll2cff_check_options(context *ctx) +void maca_trans_parser_mcf2cff_check_options(context *ctx) { if(!ctx->input_filename || ctx->help /* || !ctx->mcd_filename */ /* || !(ctx->cff_filename || ctx->fann_filename) */ ){ - maca_trans_parser_conll2cff_help_message(ctx); + maca_trans_parser_mcf2cff_help_message(ctx); exit(1); } } @@ -49,74 +49,73 @@ void generate_training_file_stream(FILE *output_file, context *ctx) char mvt_type; int mvt_label; feat_vec *fv = feat_vec_new(feature_types_nb); - sentence *ref = NULL; int sentence_nb = 0; - /* int root_label = dico_string2int(mcd_get_dico_label(ctx->mcd_struct), (char *) ctx->root_label); */ int root_label = dico_string2int(ctx->dico_labels, (char *) ctx->root_label); - FILE *conll_file = myfopen(ctx->input_filename, "r"); - FILE *conll_file_ref = myfopen(ctx->input_filename, "r"); + word_buffer *ref = word_buffer_load_mcf(ctx->input_filename, ctx->mcd_struct); + FILE *mcf_file = myfopen(ctx->input_filename, "r"); - c = config_initial(conll_file, ctx->mcd_struct, 5); + mcd *mcd_struct_hyp = mcd_copy(ctx->mcd_struct); + mcd_remove_wf_column(mcd_struct_hyp, MCD_WF_GOV); + mcd_remove_wf_column(mcd_struct_hyp, MCD_WF_LABEL); - while((ref = sentence_read(conll_file_ref , ctx->mcd_struct)) && (sentence_nb < ctx->sent_nb)){ - sentence_print(stdout, ref, ctx->dico_labels); - while(1){ - config_print(stdout,c); - config2feat_vec_cff(ctx->features_model, c, ctx->d_perceptron_features, fv, ctx->mode); - - /* feat_vec_print(stdout, fv); */ - - mvt_code = oracle_parser(c, ref); + c = config_initial(mcf_file, mcd_struct_hyp, 5); + + while(!word_buffer_end(ref)){ + printf("************ REF ************\n"); + word_buffer_print(stdout, ref); + printf("*****************************\n"); + + config_print(stdout,c); + config2feat_vec_cff(ctx->features_model, c, ctx->d_perceptron_features, fv, ctx->mode); + + /* feat_vec_print(stdout, fv); */ + + mvt_code = oracle_parser_arc_eager(c, ref); - mvt_type = movement_type(mvt_code); - mvt_label = movement_label(mvt_code); + mvt_type = movement_type(mvt_code); + mvt_label = movement_label(mvt_code); - /* printf("mvt code = %d\n", mvt_code); */ - /* movement_print(stdout, mvt_code, ctx->dico_labels); */ + /* printf("mvt code = %d\n", mvt_code); */ + movement_print(stdout, mvt_code, ctx->dico_labels); + + fprintf(output_file, "%d", mvt_code); + feat_vec_print(output_file, fv); - fprintf(output_file, "%d", mvt_code); - feat_vec_print(output_file, fv); + if((mvt_type == MVT_RIGHT) && (mvt_label == root_label)){ /* sentence is complete */ - if(queue_is_empty(c->bf)) break; + /* create the root arc */ + movement_right_arc(c, mvt_label, 0); - if((mvt_type == MVT_RIGHT) && (mvt_label == root_label)){ /* sentence is complete */ - - /* create the root arc */ - movement_right_arc(c, mvt_label, 0); - - /* shift dummy word in stack */ - movement_shift(c, 1, 0); - - /* printf("sentence complete config : "); - config_print(stdout,c); */ - - /* empty depset */ - depset_free(c->ds); - c->ds = depset_new(); - sentence_free(ref); - sentence_nb++; - - c->current_index = queue_renumber_words(c->bf); - - break; - } + /* pop root from stack */ + stack_pop(config_get_stack(c)); - if(mvt_type == MVT_LEFT){ - movement_left_arc(c, mvt_label, 0); - continue; - } - if(mvt_type == MVT_RIGHT){ - movement_right_arc(c, mvt_label, 0); - continue; - } - if(mvt_type == MVT_SHIFT){ - movement_shift(c, 1, 0); - continue; - } + /* printf("sentence complete config : "); + config_print(stdout,c); */ } - } -} + + if(mvt_type == MVT_LEFT){ + movement_left_arc(c, mvt_label, 0); + continue; + } + if(mvt_type == MVT_RIGHT){ + movement_right_arc(c, mvt_label, 0); + word_buffer_move_right(ref); + continue; + } + if(mvt_type == MVT_REDUCE){ + movement_reduce(c, 0); + continue; + } + if(mvt_type == MVT_SHIFT){ + movement_shift(c, 1, 0); + word_buffer_move_right(ref); + continue; + } + } +} + +#if 0 void generate_training_file_buffer(FILE *output_file, context *ctx) { config *c; @@ -133,7 +132,7 @@ void generate_training_file_buffer(FILE *output_file, context *ctx) while((ref = sentence_read(conll_file_ref, ctx->mcd_struct)) && (sentence_nb < ctx->sent_nb)){ /* sentence_print(stdout, ref, NULL); */ - queue_read_sentence(c->bf, conll_file, ctx->mcd_struct); + word_buffer_read_sentence(c->bf); while(!config_is_terminal(c)){ /* config_print(stdout,c); */ @@ -167,6 +166,7 @@ void generate_training_file_buffer(FILE *output_file, context *ctx) sentence_nb++; } } +#endif int main(int argc, char *argv[]) { @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) FILE *output_file; ctx = context_read_options(argc, argv); - maca_trans_parser_conll2cff_check_options(ctx); + maca_trans_parser_mcf2cff_check_options(ctx); ctx->features_model = feat_model_read(ctx->features_model_filename, ctx->verbose); @@ -219,14 +219,14 @@ int main(int argc, char *argv[]) output_file = stdout; + generate_training_file_stream(output_file, ctx); - - + /* if(ctx->stream_mode) generate_training_file_stream(output_file, ctx); else generate_training_file_buffer(output_file, ctx); - + */ if(ctx->mode == TRAIN_MODE){ /* dico_print(ctx->perceptron_features_filename, ctx->d_perceptron_features); */ dico_vec_print(ctx->vocabs_filename, ctx->vocabs); diff --git a/maca_trans_parser/src/maca_trans_parser_mcf2fann.c b/maca_trans_parser/src/maca_trans_parser_mcf2fann.c index ed3991282fcfc90f51b8bd9581e2c49dc2514806..534f7417b17f62269764eede4740fd30989e94f1 100644 --- a/maca_trans_parser/src/maca_trans_parser_mcf2fann.c +++ b/maca_trans_parser/src/maca_trans_parser_mcf2fann.c @@ -83,7 +83,7 @@ int generate_training_file_buffer(FILE *output_file, context *ctx) while((ref = sentence_read(conll_file_ref, ctx->mcd_struct)) && (sentence_nb < ctx->sent_nb)){ /* sentence_print(stdout, ref, NULL); */ - queue_read_sentence(c->bf, conll_file, ctx->mcd_struct); + word_buffer_read_sentence(c->bf); while(!config_is_terminal(c)){ /* config_print(stdout,c); */ config2feat_vec_fann(ctx->features_model, c, fv, ctx->mode); diff --git a/maca_trans_parser/src/maca_trans_tagger_mcf2cff.c b/maca_trans_parser/src/maca_trans_tagger_mcf2cff.c index 8ca8e53d3f40f5fecf48ec24ea881b4b06bd00bd..3dadf7bbb07deb0a9d498b45b18bebf959b40552 100644 --- a/maca_trans_parser/src/maca_trans_tagger_mcf2cff.c +++ b/maca_trans_parser/src/maca_trans_tagger_mcf2cff.c @@ -26,8 +26,19 @@ void add_signature_to_words_in_queue(queue *bf, form2pos *f2p) } } +void add_signature_to_words_in_word_buffer(word_buffer *bf, form2pos *f2p) +{ + int i; + word *w; + + for(i = word_buffer_get_nbelem(bf) - 1; i >=0 ; i--){ + w = word_buffer_get_word_n(bf, i); + if(word_get_signature(w) != -1) break; + w->signature = form2pos_get_signature(f2p, w->form); + } +} -void maca_trans_parser_conll2cff_help_message(context *ctx) +void maca_trans_parser_mcf2cff_help_message(context *ctx) { context_general_help_message(ctx); context_mode_help_message(ctx); @@ -47,14 +58,14 @@ void maca_trans_parser_conll2cff_help_message(context *ctx) } -void maca_trans_parser_conll2cff_check_options(context *ctx) +void maca_trans_parser_mcf2cff_check_options(context *ctx) { if(!ctx->input_filename || ctx->help /* || !ctx->mcd_filename */ || !(ctx->cff_filename || ctx->fann_filename) ){ - maca_trans_parser_conll2cff_help_message(ctx); + maca_trans_parser_mcf2cff_help_message(ctx); exit(1); } } @@ -71,7 +82,7 @@ void generate_training_file_stream(FILE *output_file, context *ctx) while(!config_is_terminal(c)){ /* config_print(stdout,c); */ if(ctx->f2p) - add_signature_to_words_in_queue(c->bf, ctx->f2p); + add_signature_to_words_in_word_buffer(c->bf, ctx->f2p); config2feat_vec_cff(ctx->features_model, c, ctx->d_perceptron_features, fv, ctx->mode); postag = oracle_tagger(c, NULL); fprintf(output_file, "%d", postag); @@ -93,11 +104,12 @@ void generate_training_file_buffer(FILE *output_file, context *ctx) while((ref = sentence_read(conll_file_ref, ctx->mcd_struct)) && (sentence_nb < ctx->sent_nb)){ /* sentence_print(stdout, ref, NULL); */ - queue_read_sentence(c->bf, conll_file, ctx->mcd_struct); - queue_remove(c->bf); /* get rid of dummy token */ + word_buffer_read_sentence(c->bf); + /* get rid of dummy token */ + /* queue_remove(c->bf); */ if(ctx->f2p) - add_signature_to_words_in_queue(c->bf, ctx->f2p); + add_signature_to_words_in_word_buffer(c->bf, ctx->f2p); while(!config_is_terminal(c)){ /* config_print(stdout, c); */ @@ -121,7 +133,7 @@ int main(int argc, char *argv[]) FILE *output_file; ctx = context_read_options(argc, argv); - maca_trans_parser_conll2cff_check_options(ctx); + maca_trans_parser_mcf2cff_check_options(ctx); ctx->features_model = feat_model_read(ctx->features_model_filename, ctx->verbose); diff --git a/maca_trans_parser/src/movement_parser.c b/maca_trans_parser/src/movement_parser.c index 5ec8262ecfc83dedf089c5c80987223e8fb84710..254cab39d47f915545df5cb42b183986191b2d7a 100644 --- a/maca_trans_parser/src/movement_parser.c +++ b/maca_trans_parser/src/movement_parser.c @@ -4,34 +4,6 @@ #include"util.h" #include"movement_parser.h" -#if 0 -int movement_label(int mvt) -{ - if(mvt == 0) return -1; /* 0 is the code of shift */ - if(mvt == 1) return -1; /* 1 is the code of cut */ - if(mvt % 2 == 0) /* even codes correspond to left movements */ - return (mvt - 2) / 2; - return (mvt - 3) / 2; /* odd codes correspond to right movements */ -} - -int movement_type(int mvt) -{ - if(mvt == 0) return MVT_SHIFT; /* 0 is the code of shift */ - if(mvt == 1) return MVT_CUT; /* 1 is the code of cut */ - if(mvt % 2 == 0) return MVT_LEFT; /* even movements are left movements */ - return MVT_RIGHT; /* odd movements are right movements */ -} - -int movement_cut(config *c) -{ - if(stack_is_empty(c->st)) return 0; - stack_pop(c->st); - depset_free(c->ds); - c->ds = NULL; - return 1; -} -#endif - void movement_print(FILE *f, int mvt_code, dico *dico_labels){ int mvt_type = movement_type(mvt_code); int mvt_label = movement_label(mvt_code); @@ -46,7 +18,6 @@ void movement_print(FILE *f, int mvt_code, dico *dico_labels){ fprintf(f, "\n"); } - int movement_type(int mvt) { if(mvt == 0) return MVT_SHIFT; /* 0 is the code of shift */ @@ -65,73 +36,78 @@ int movement_label(int mvt) int movement_left_arc(config *c, int label, float score) { if(stack_is_empty(c->st)) return 0; - if(queue_is_empty(c->bf)) return 0; - if(word_get_relative_index(stack_top(c->st)) == 0) return 0; - depset_add(c->ds, queue_elt_n(c->bf, 0), label, stack_top(c->st)); + if(word_buffer_is_empty(c->bf)) return 0; + if(word_get_relative_index(stack_top(c->st)) == 0) return 0; /* the dummy word cannot be a dependent */ + + /* create a new dependency */ + word_set_gov(stack_top(c->st), word_get_relative_index(word_buffer_b0(c->bf))); + word_set_label(stack_top(c->st), label); + + /* depset_add(c->ds, word_buffer_b0(c->bf), label, stack_top(c->st)); */ stack_pop(c->st); config_add_mvt(c, movement_left_code(label)); return 1; } -config *movement_left_arc_dup(config *c, int label, float score, feat_vec *fv) + +int movement_right_arc(config *c, int label, float score) { - config *copy = NULL; - if(stack_is_empty(c->st)) return NULL; - if(queue_is_empty(c->bf)) return NULL; - if(word_get_relative_index(stack_top(c->st)) == 0) return NULL; + /* printf("RA "); */ + if(stack_is_empty(c->st)) return 0; + if(word_buffer_is_empty(c->bf)) return 0; - copy = config_copy(c); - depset_add(copy->ds, queue_elt_n(copy->bf, 0), label, stack_top(copy->st)); - stack_pop(copy->st); - copy->score = score; - config_add_mvt(copy, movement_left_code(label)); + /* create a new dependency */ + word_set_gov(word_buffer_b0(c->bf), word_get_relative_index(stack_top(c->st))); + word_set_label(word_buffer_b0(c->bf), label); + + /* depset_add(c->ds, stack_top(c->st), label, word_buffer_b0(c->bf)); */ + stack_push(c->st, word_buffer_b0(c->bf)); + word_buffer_move_right(c->bf); + + config_add_mvt(c, movement_right_code(label)); + return 1; +} - if(fv) global_feat_vec_add(copy->gfv, movement_left_code(label), feat_vec_copy(fv)); + +int movement_shift(config *c, int stream, float score) +{ + if(word_buffer_is_empty(c->bf)) return 0; + /* printf("SH\n"); */ + + stack_push(c->st, word_buffer_b0(c->bf)); + word_buffer_move_right(c->bf); - return copy; + config_add_mvt(c, MVT_SHIFT); + return 1; } -int movement_right_arc(config *c, int label, float score) +int movement_reduce(config *c, float score) { - /* printf("RA "); */ if(stack_is_empty(c->st)) return 0; - if(queue_is_empty(c->bf)) return 0; - - depset_add(c->ds, stack_top(c->st), label, queue_elt_n(c->bf, 0)); - queue_remove(c->bf); - queue_add_in_front(c->bf, stack_pop(c->st)); - config_add_mvt(c, movement_right_code(label)); + if(word_get_gov(stack_top(c->st)) == -1) return 0; /* word on top of stack does not have a governor */ + stack_pop(c->st); return 1; } -config *movement_right_arc_dup(config *c, int label, float score, feat_vec *fv) +#if 0 + +config *movement_left_arc_dup(config *c, int label, float score, feat_vec *fv) { config *copy = NULL; - /* fprintf(stderr, "RIGHT ARC\n"); */ if(stack_is_empty(c->st)) return NULL; - if(queue_is_empty(c->bf)) return NULL; + if(word_buffer_is_empty(c->bf)) return NULL; + if(word_get_relative_index(stack_top(c->st)) == 0) return NULL; copy = config_copy(c); - depset_add(copy->ds, stack_top(copy->st), label, queue_elt_n(copy->bf, 0)); - queue_remove(copy->bf); - queue_add_in_front(copy->bf, stack_pop(copy->st)); - copy->score = score; - config_add_mvt(copy, movement_right_code(label)); - if(fv) global_feat_vec_add(copy->gfv, movement_right_code(label), feat_vec_copy(fv)); - return copy; -} + depset_add(copy->ds, word_buffer_b0(copy->bf), label, stack_top(copy->st)); -int movement_shift(config *c, int stream, float score) -{ - if(queue_is_empty(c->bf)) return 0; - /* printf("SH\n"); */ - - stack_push(c->st, queue_remove(c->bf)); + stack_pop(copy->st); + copy->score = score; + config_add_mvt(copy, movement_left_code(label)); - config_add_mvt(c, MVT_SHIFT); - if(stream) - config_add_next_word_to_buffer(c); - return 1; + if(fv) global_feat_vec_add(copy->gfv, movement_left_code(label), feat_vec_copy(fv)); + + return copy; } config *movement_shift_dup(config *c, int stream, float score, feat_vec *fv) @@ -153,8 +129,20 @@ config *movement_shift_dup(config *c, int stream, float score, feat_vec *fv) return copy; } +config *movement_right_arc_dup(config *c, int label, float score, feat_vec *fv) +{ + config *copy = NULL; + /* fprintf(stderr, "RIGHT ARC\n"); */ + if(stack_is_empty(c->st)) return NULL; + if(queue_is_empty(c->bf)) return NULL; - - - - + copy = config_copy(c); + depset_add(copy->ds, stack_top(copy->st), label, queue_elt_n(copy->bf, 0)); + queue_remove(copy->bf); + queue_add_in_front(copy->bf, stack_pop(copy->st)); + copy->score = score; + config_add_mvt(copy, movement_right_code(label)); + if(fv) global_feat_vec_add(copy->gfv, movement_right_code(label), feat_vec_copy(fv)); + return copy; +} +#endif diff --git a/maca_trans_parser/src/movement_parser.h b/maca_trans_parser/src/movement_parser.h index 4078c482906852ffb05798673e9b1d641215e414..3a73f275e9dafd8caaf13cdac802501d9215a397 100644 --- a/maca_trans_parser/src/movement_parser.h +++ b/maca_trans_parser/src/movement_parser.h @@ -37,6 +37,8 @@ int movement_label(int mvt); int movement_left_arc(config *c, int label, float score); int movement_right_arc(config *c, int label, float score); int movement_shift(config *c, int stream, float score); +int movement_reduce(config *c, float score); + config *movement_left_arc_dup(config *c, int label, float score, feat_vec *fv); config *movement_right_arc_dup(config *c, int label, float score, feat_vec *fv); config *movement_shift_dup(config *c, int stream, float score, feat_vec *fv); diff --git a/maca_trans_parser/src/movement_parser_arc_eager.c b/maca_trans_parser/src/movement_parser_arc_eager.c new file mode 100644 index 0000000000000000000000000000000000000000..c1f8a207bd46315ccc791aa672a7b93c62e541fc --- /dev/null +++ b/maca_trans_parser/src/movement_parser_arc_eager.c @@ -0,0 +1,98 @@ +#include<stdio.h> +#include<stdlib.h> +#include<string.h> +#include"util.h" +#include"movement_parser_arc_eager.h" + +void movement_print(FILE *f, int mvt_code, dico *dico_labels){ + int mvt_type = movement_type(mvt_code); + int mvt_label = movement_label(mvt_code); + char *label; + if(mvt_type == MVT_SHIFT) {fprintf(f, "SHIFT\n"); return;} + if(mvt_type == MVT_REDUCE) {fprintf(f, "REDUCE\n"); return;} + if(mvt_type == MVT_RIGHT) fprintf(f, "RIGHT"); + else fprintf(f, "LEFT"); + label = dico_int2string(dico_labels, mvt_label); + fprintf(f, " %s\n", label); +} + +int movement_type(int mvt) +{ + if(mvt == 0) return MVT_SHIFT; /* 0 is the code of shift */ + if(mvt == 1) return MVT_REDUCE; /* 1 is the code of reduce */ + if(mvt % 2 == 0) return MVT_LEFT; /* even movements are left movements */ + return MVT_LEFT; /* odd movements are right movements */ +} + +int movement_label(int mvt) +{ + if(mvt == 0) return -1; /* 0 is the code of shift */ + if(mvt == 1) return -1; /* 1 is the code of reduce */ + if(mvt % 2 == 0) /* even codes correspond to left movements */ + return mvt / 2 - 1; + return (mvt - 1) / 2 - 1; /* odd codes correspond to right movements */ +} + +int movement_left_arc(config *c, int label, float score) +{ + + if(stack_height(c->st) < 2) return 0; /* the dummy word cannot be a dependent */ + if(word_buffer_is_empty(c->bf)) return 0; + + /* word on top of the stack should not have a governor */ + + printf("word_get_gov_relative_index(stack_top(c->st)) = %d\n", word_get_gov_relative_index(stack_top(c->st))); + + if(word_get_gov_relative_index(stack_top(c->st)) != -1) return 0; + + + /* create a new dependency */ + word_set_gov(stack_top(c->st), word_get_relative_index(word_buffer_b0(c->bf))); + word_set_label(stack_top(c->st), label); + + /* depset_add(c->ds, word_buffer_b0(c->bf), label, stack_top(c->st)); */ + stack_pop(c->st); + config_add_mvt(c, movement_left_code(label)); + return 1; +} + +int movement_right_arc(config *c, int label, float score) +{ + /* printf("RA "); */ + if(stack_is_empty(c->st)) return 0; + if(word_buffer_is_empty(c->bf)) return 0; + + + /* create a new dependency */ + word_set_gov(word_buffer_b0(c->bf), word_get_relative_index(stack_top(c->st))); + word_set_label(word_buffer_b0(c->bf), label); + + /* depset_add(c->ds, stack_top(c->st), label, word_buffer_b0(c->bf)); */ + stack_push(c->st, word_buffer_b0(c->bf)); + word_buffer_move_right(c->bf); + + config_add_mvt(c, movement_right_code(label)); + return 1; +} + + +int movement_shift(config *c, int stream, float score) +{ + if(word_buffer_is_empty(c->bf)) return 0; + /* printf("SH\n"); */ + + stack_push(c->st, word_buffer_b0(c->bf)); + word_buffer_move_right(c->bf); + + config_add_mvt(c, MVT_SHIFT); + return 1; +} + +int movement_reduce(config *c, float score) +{ + if(stack_is_empty(c->st)) return 0; + if(word_get_gov(stack_top(c->st)) == -1) return 0; /* word on top of stack does not have a governor */ + stack_pop(c->st); + return 1; +} + diff --git a/maca_trans_parser/src/movement_parser_arc_eager.h b/maca_trans_parser/src/movement_parser_arc_eager.h new file mode 100644 index 0000000000000000000000000000000000000000..d117c5cf942c3b6ab03da7b5ec0d7b381405f2ec --- /dev/null +++ b/maca_trans_parser/src/movement_parser_arc_eager.h @@ -0,0 +1,30 @@ +#ifndef __MOVEMENT_PARSER_ARC_EAGER__ +#define __MOVEMENT_PARSER_ARC_EAGER__ + +#include"config.h" +#include"feat_vec.h" + + +#define MVT_SHIFT 0 +#define MVT_REDUCE 1 +#define MVT_LEFT 2 +#define MVT_RIGHT 3 + + +/* even movements are left movements (except 0, which is shift) */ +#define movement_left_code(label) (2 * (label) + 2) + +/* odd movements are right movements (except 1, which is reduce) */ +#define movement_right_code(label) (2 * (label) + 3) + +int movement_type(int mvt); +int movement_label(int mvt); + +int movement_left_arc(config *c, int label, float score); +int movement_right_arc(config *c, int label, float score); +int movement_shift(config *c, int stream, float score); +int movement_reduce(config *c, float score); + +void movement_print(FILE *f, int mvt_code, dico *dico_labels); + +#endif diff --git a/maca_trans_parser/src/movement_tagger.c b/maca_trans_parser/src/movement_tagger.c index d1f46b682675d693e0cfe3c26321ba10e90ce10f..3ac695a1e63c5336b9745560c04e985fb5001f5d 100644 --- a/maca_trans_parser/src/movement_tagger.c +++ b/maca_trans_parser/src/movement_tagger.c @@ -6,20 +6,10 @@ int movement_tagger(config *c, int postag, float score, int stream) { - word *b0 = NULL; - int k = 5; - - if(queue_is_empty(c->bf)) return 0; + if(word_buffer_is_empty(c->bf)) return 0; - b0 = queue_remove(c->bf); - word_set_pos(b0, postag); - stack_push(c->st, b0); - - /* in stream mode, read a new word, add it to the buffer and keen only (k = 5) elts in the stack */ - if(stream){ - stack_trim_to_size(c->st, k); - config_add_next_word_to_buffer(c); - } + word_set_pos(word_buffer_b0(c->bf), postag); + word_buffer_move_right(c->bf); return 1; } diff --git a/maca_trans_parser/src/oracle_parser.c b/maca_trans_parser/src/oracle_parser.c index b4145749558a3bc88926460e1b93e07f77177418..418f422bb4500ab6bf642300fe9b6c4d809f1180 100644 --- a/maca_trans_parser/src/oracle_parser.c +++ b/maca_trans_parser/src/oracle_parser.c @@ -27,11 +27,11 @@ int oracle_parser(config *c, sentence *ref) word *b0; /* next word in the bufer */ int s0_index, b0_index; - if(!stack_is_empty(c->st) && !queue_is_empty(c->bf)){ + if(!stack_is_empty(c->st) && !word_buffer_is_empty(c->bf)){ s0 = stack_top(c->st); s0_index = word_get_relative_index(s0); - b0 = queue_elt_n(c->bf, 0); + b0 = word_buffer_b0(c->bf); b0_index = word_get_relative_index(b0); /* printf("s0 = %d b0 = %d\n", s0_index, b0_index); */ diff --git a/maca_trans_parser/src/oracle_parser_arc_eager.c b/maca_trans_parser/src/oracle_parser_arc_eager.c new file mode 100644 index 0000000000000000000000000000000000000000..f719363d27f95d661d1ed3efb2e26a18878e2e6e --- /dev/null +++ b/maca_trans_parser/src/oracle_parser_arc_eager.c @@ -0,0 +1,68 @@ +#include<stdio.h> +#include<stdlib.h> +#include<string.h> +#include"word_buffer.h" +#include"movement_parser_arc_eager.h" + +int check_all_dependents_of_word_in_ref_are_in_hyp(config *c, word_buffer *ref, int word_index) +{ + int dep; + + for(dep=1; dep < ref->nbelem; dep++){ + if(word_get_gov_relative_index(word_buffer_get_word_n(ref, dep)) == word_index){ /* found a dependent of word in ref */ + /* look for a dependency in hyp such that its dependent is dep */ + + if(word_get_gov_relative_index(word_buffer_get_word_n(config_get_buffer(c), dep)) != word_index) return 0; + /* + if((dep >= c->ds->length) + || (c->ds->array[dep].gov == NULL) + || (word_get_relative_index(c->ds->array[dep].gov) != word_index) + || (c->ds->array[dep].label != word_get_label(ref->words[dep]))) + return 0;*/ + } + } + return 1; +} + +int oracle_parser_arc_eager(config *c, word_buffer *ref) +{ + word *s0; /* word on top of stack */ + word *b0; /* next word in the bufer */ + int s0_index, b0_index; + + if(!stack_is_empty(c->st) && !word_buffer_is_empty(c->bf)){ + s0 = stack_top(c->st); + s0_index = word_get_relative_index(s0); + + b0 = word_buffer_b0(c->bf); + b0_index = word_get_relative_index(b0); + + printf("s0_index = %d b0_index = %d\n", s0_index, b0_index); + printf("dans ref gov de s0 (%d) = %d\n", s0_index, word_get_gov_relative_index(word_buffer_get_word_n(ref, s0_index))); + printf("dans ref gov de b0 (%d) = %d\n", b0_index, word_get_gov_relative_index(word_buffer_get_word_n(ref, b0_index))); + + /* LEFT ARC b0 is the governor and s0 the dependent */ + if(word_get_gov_relative_index(word_buffer_get_word_n(ref, s0_index)) == b0_index){ + + printf("oracle says left\n"); + return movement_left_code(word_get_label(word_buffer_get_word_n(ref, s0_index))); + } + + /* RIGHT ARC s0 is the governor and b0 the dependent */ + if((word_get_gov_relative_index(word_buffer_get_word_n(ref, b0_index)) == s0_index)) + return movement_right_code(word_get_label(word_buffer_get_word_n(ref, b0_index))); + + /* REDUCE */ + if((stack_height(c->st) > 2) && check_all_dependents_of_word_in_ref_are_in_hyp(c, ref, s0_index)) + + /* if(word_get_gov_relative_index(stack_top(c->st)) != -1) */ + return MVT_REDUCE; + + + /* if(check_all_dependents_of_word_in_ref_are_in_hyp(c, ref, s0_index)) + return MVT_REDUCE;*/ + + /* SHIFT */ + return MVT_SHIFT; + } +} diff --git a/maca_trans_parser/src/oracle_parser_arc_eager.h b/maca_trans_parser/src/oracle_parser_arc_eager.h new file mode 100644 index 0000000000000000000000000000000000000000..1aad136a6348a0f5aae413f5e2142a6454628a45 --- /dev/null +++ b/maca_trans_parser/src/oracle_parser_arc_eager.h @@ -0,0 +1,11 @@ +#ifndef __ORACLE_ARC_EAGER__ +#define __ORACLE_ARC_EAGER__ + + +#include"config.h" +#include"word_buffer.h" + + +int oracle_parser_arc_eager(config *c, word_buffer *ref); + +#endif diff --git a/maca_trans_parser/src/oracle_tagger.c b/maca_trans_parser/src/oracle_tagger.c index 10d53d8ffa4def5f6c27b9b21d6c4f45df7b3a92..d948b278380e3332d9fde398c6d6a1d07fbe5d5f 100644 --- a/maca_trans_parser/src/oracle_tagger.c +++ b/maca_trans_parser/src/oracle_tagger.c @@ -5,8 +5,8 @@ int oracle_tagger(config *c, sentence *ref) word *b0; /* next word in the bufer */ /* int b0_index; */ int b0_pos; - if(!queue_is_empty(c->bf)){ - b0 = queue_elt_n(c->bf, 0); + if(!word_buffer_is_empty(c->bf)){ + b0 = word_buffer_b0(c->bf); b0_pos = word_get_pos(b0); /* printf("b0_pos = %d\n", b0_pos); */ /* b0_index = word_get_index(b0); */ diff --git a/maca_trans_parser/src/simple_decoder_forrest.c b/maca_trans_parser/src/simple_decoder_forrest.c index 52f1194ab3a56015e674923b4d34e0cca59404e2..e2db79762d45b1a1230874cda175526749a0502c 100644 --- a/maca_trans_parser/src/simple_decoder_forrest.c +++ b/maca_trans_parser/src/simple_decoder_forrest.c @@ -21,7 +21,7 @@ void simple_decoder_buffer_forrest(context *ctx, FILE *f, feature_table *ft, int config *c = config_initial(f, ctx->mcd_struct, 0); /* read a sentence and put it in the buffer */ - while(queue_read_sentence(c->bf, f, ctx->mcd_struct)){ + while(word_buffer_read_sentence(c->bf)){ while(!config_is_terminal(c)){ /* config2feat_vec_cff(ctx->features_model, c, ctx->d_perceptron_features, fv, LOOKUP_MODE); */ config2feat_vec_fann(ctx->features_model, c, fv, LOOKUP_MODE); diff --git a/maca_trans_parser/src/simple_decoder_parser.c b/maca_trans_parser/src/simple_decoder_parser.c index f803a8105a6ee189c14249abe2c010ee1ff6c61b..b71f307ea6afb0851b0d8b2980d06abeb9984ff5 100644 --- a/maca_trans_parser/src/simple_decoder_parser.c +++ b/maca_trans_parser/src/simple_decoder_parser.c @@ -4,13 +4,13 @@ #include<unistd.h> #include<getopt.h> #include"context.h" -#include"movement_parser.h" -#include"oracle_parser.h" +#include"movement_parser_arc_eager.h" #include"feat_fct.h" #include"config2feat_vec.h" #include"feature_table.h" #include"dico.h" +#if 0 void simple_decoder_buffer(context *ctx, FILE *f, feature_table *ft, int root_label) { int mvt_code; @@ -21,7 +21,7 @@ void simple_decoder_buffer(context *ctx, FILE *f, feature_table *ft, int root_la config *c = config_initial(f, ctx->mcd_struct, 0); /* read a sentence and put it in the buffer */ - while(queue_read_sentence(c->bf, f, ctx->mcd_struct) > 1){ + while(word_buffer_read_sentence(c->bf) > 1){ while(!config_is_terminal(c)){ config2feat_vec_cff(ctx->features_model, c, ctx->d_perceptron_features, fv, LOOKUP_MODE); mvt_code = feature_table_argmax(fv, ft, &max); @@ -52,6 +52,7 @@ void simple_decoder_buffer(context *ctx, FILE *f, feature_table *ft, int root_la feat_vec_free(fv); } +#endif void simple_decoder_stream(context *ctx, FILE *f, feature_table *ft, int root_label) { @@ -85,7 +86,7 @@ void simple_decoder_stream(context *ctx, FILE *f, feature_table *ft, int root_la movement_right_arc(c, mvt_label, 0); /* shift dummy word in stack */ - movement_shift(c, 1, 0); + stack_pop(config_get_stack(c)); /* config_print(stdout, c); */ @@ -104,7 +105,7 @@ void simple_decoder_stream(context *ctx, FILE *f, feature_table *ft, int root_la c->ds = depset_new(); /* renumber the words that are left in the buffer */ - c->current_index = queue_renumber_words(c->bf); + /* c->current_index = queue_renumber_words(c->bf); */ continue; } @@ -116,6 +117,10 @@ void simple_decoder_stream(context *ctx, FILE *f, feature_table *ft, int root_la if(movement_right_arc(c, mvt_label, max)) continue; + if(mvt_type == MVT_REDUCE) + if(movement_reduce(c, max)) + continue; + movement_shift(c, 1, max); } @@ -140,11 +145,13 @@ void simple_decoder(context *ctx) root_label = dico_string2int(ctx->dico_labels, ctx->root_label); if(root_label == -1) root_label = 0; + simple_decoder_stream(ctx, f, ft, root_label); + /* if(ctx->stream_mode) simple_decoder_stream(ctx, f, ft, root_label); else simple_decoder_buffer(ctx, f, ft, root_label); - + */ feature_table_free(ft); if(ctx->input_filename) fclose(f); diff --git a/maca_trans_parser/src/simple_decoder_tagger.c b/maca_trans_parser/src/simple_decoder_tagger.c index dd4eb79c9ee333a9670425206db32d038e8210c5..a145fee8ef889546f71fb55375ecf88bf6d265d8 100644 --- a/maca_trans_parser/src/simple_decoder_tagger.c +++ b/maca_trans_parser/src/simple_decoder_tagger.c @@ -22,6 +22,18 @@ void add_signature_to_words_in_queue(queue *bf, form2pos *f2p) } } +void add_signature_to_words_in_word_buffer(word_buffer *bf, form2pos *f2p) +{ + int i; + word *w; + + for(i = word_buffer_get_nbelem(bf) - 1; i >=0 ; i--){ + w = word_buffer_get_word_n(bf, i); + if(word_get_signature(w) != -1) break; + w->signature = form2pos_get_signature(f2p, w->form); + } +} + void simple_decoder_buffer(context *ctx) { dico *dico_pos = dico_vec_get_dico(ctx->vocabs, (char *)"POS"); @@ -35,11 +47,11 @@ void simple_decoder_buffer(context *ctx) config *c = config_initial_no_dummy_word(f, ctx->mcd_struct, 0); /* read a sentence and put it in the buffer */ - while(queue_read_sentence(c->bf, f, ctx->mcd_struct)){ + while(word_buffer_read_sentence(c->bf)){ /* queue_remove(c->bf); */ /* get rid of dummy token */ if(ctx->f2p) - add_signature_to_words_in_queue(c->bf, ctx->f2p); + add_signature_to_words_in_word_buffer(c->bf, ctx->f2p); while(!config_is_terminal(c)){ config2feat_vec_cff(ctx->features_model, c, ctx->d_perceptron_features, fv, LOOKUP_MODE); @@ -74,10 +86,10 @@ void simple_decoder_stream(context *ctx) word *w; dico *dico_pos = dico_vec_get_dico(ctx->vocabs, (char *)"POS"); - c = config_initial_no_dummy_word(f, ctx->mcd_struct, 5); + c = config_initial_no_dummy_word(f, ctx->mcd_struct, 5); while(!config_is_terminal(c)){ if(ctx->f2p) - add_signature_to_words_in_queue(c->bf, ctx->f2p); + add_signature_to_words_in_word_buffer(c->bf, ctx->f2p); /* config_print(stdout, c); */ config2feat_vec_cff(ctx->features_model, c, ctx->d_perceptron_features, fv, LOOKUP_MODE); @@ -85,7 +97,7 @@ void simple_decoder_stream(context *ctx) postag = feature_table_argmax(fv, ft, &max); /* printf("postag = %d\n", postag); */ - w = queue_elt_n(c->bf, 0); + w = word_buffer_b0(c->bf); printf("%s\t%s\n", w->input, dico_int2string(dico_pos, postag)); if(postag != -1) diff --git a/maca_trans_parser/src/stack.h b/maca_trans_parser/src/stack.h index de01374ad877b47e896a9917bde87ab00b71febd..a9dcaba18f55017f40bba0b6fbe41bd559316613 100644 --- a/maca_trans_parser/src/stack.h +++ b/maca_trans_parser/src/stack.h @@ -8,6 +8,14 @@ #define stack_nbelem(s) (s)->top #define stack_elt_n(s, n) (s)->array[(s)->top - (n) - 1] +#define stack_s0(s) ((s)->top > 0)? (s)->array[(s)->top - 1] : NULL +#define stack_s1(s) ((s)->top > 1)? (s)->array[(s)->top - 2] : NULL +#define stack_s2(s) ((s)->top > 2)? (s)->array[(s)->top - 3] : NULL +#define stack_s3(s) ((s)->top > 3)? (s)->array[(s)->top - 4] : NULL +#define stack_s4(s) ((s)->top > 4)? (s)->array[(s)->top - 5] : NULL +#define stack_s5(s) ((s)->top > 5)? (s)->array[(s)->top - 6] : NULL + + typedef struct { int size; word **array;