From b662e2f8a4d35b37bfee80a84e0339e8a873c6af Mon Sep 17 00:00:00 2001 From: Alexis Nasr <alexis.nasr@lif.univ-mrs.fr> Date: Tue, 19 Dec 2017 22:01:22 +0100 Subject: [PATCH] simplified the actions system, got rid of action EOS, action ROOT is now responsible to set the sentence boundary --- maca_common/include/word.h | 2 ++ maca_common/src/word_buffer.c | 2 +- maca_trans_parser/src/movement_parser_arc_eager.h | 6 +++--- maca_trans_parser/src/movements.c | 8 ++++++++ maca_trans_parser/src/oracle_parser_arc_eager.c | 4 ++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/maca_common/include/word.h b/maca_common/include/word.h index 33fd8c1..c6a4b56 100644 --- a/maca_common/include/word.h +++ b/maca_common/include/word.h @@ -16,6 +16,8 @@ typedef struct _word { char16 *form_char16; int index; int is_root; + int lspan; + int rspan; } word; /* diff --git a/maca_common/src/word_buffer.c b/maca_common/src/word_buffer.c index e9355d5..b72f72e 100644 --- a/maca_common/src/word_buffer.c +++ b/maca_common/src/word_buffer.c @@ -80,7 +80,7 @@ int word_buffer_add(word_buffer *wb, word *w) } wb->array[wb->nbelem] = w; word_set_index(w, wb->nbelem); - + w->rspan = w->lspan = wb->nbelem; wb->nbelem++; return wb->nbelem - 1; } diff --git a/maca_trans_parser/src/movement_parser_arc_eager.h b/maca_trans_parser/src/movement_parser_arc_eager.h index 2b11bf0..3a040d5 100644 --- a/maca_trans_parser/src/movement_parser_arc_eager.h +++ b/maca_trans_parser/src/movement_parser_arc_eager.h @@ -7,9 +7,9 @@ #define MVT_PARSER_SHIFT 0 #define MVT_PARSER_REDUCE 1 #define MVT_PARSER_ROOT 2 -#define MVT_PARSER_EOS 3 -#define MVT_PARSER_LEFT 4 -#define MVT_PARSER_RIGHT 5 +#define MVT_PARSER_EOS -1 +#define MVT_PARSER_LEFT 3 +#define MVT_PARSER_RIGHT 4 /* even movements are left movements (except 0, which is shift and 2 which is root) */ #define movement_parser_left_code(label) (2 * (label) + 4) diff --git a/maca_trans_parser/src/movements.c b/maca_trans_parser/src/movements.c index 36e3ff7..8622e4a 100644 --- a/maca_trans_parser/src/movements.c +++ b/maca_trans_parser/src/movements.c @@ -47,6 +47,8 @@ int movement_left_arc(config *c, int movement_code, int label) word_set_gov(dep, dist); word_set_label(dep, label); + gov->lspan = dep->lspan; + config_push_mvt(c, movement_code, gov, dep); stack_pop(config_get_stack(c)); @@ -81,6 +83,9 @@ int movement_right_arc(config *c, int movement_code, int label) /* create a new dependency */ word_set_gov(dep, dist); word_set_label(dep, label); + + gov->rspan = dep->rspan; + stack_push(config_get_stack(c), word_buffer_b0(config_get_buffer(c))); word_buffer_move_right(config_get_buffer(c)); @@ -152,6 +157,9 @@ int movement_root(config *c, int movement_code, int root_code) word_set_label(s0, root_code); s0->is_root = 1; + /*---- ajout 19/12/17 ----------*/ + word_set_sent_seg(word_buffer_get_word_n(config_get_buffer(c), s0->rspan), 1); + /*-----------------------------*/ stack_pop(config_get_stack(c)); config_push_mvt(c, movement_code, s0, NULL); diff --git a/maca_trans_parser/src/oracle_parser_arc_eager.c b/maca_trans_parser/src/oracle_parser_arc_eager.c index 074400e..e258c93 100644 --- a/maca_trans_parser/src/oracle_parser_arc_eager.c +++ b/maca_trans_parser/src/oracle_parser_arc_eager.c @@ -68,10 +68,10 @@ int oracle_parser_arc_eager(config *c, word_buffer *ref, int root_label) } /* word on the top of the stack is an end of sentence marker */ - if((word_get_sent_seg(word_buffer_get_word_n(ref, s0_index)) == 1) + /* if((word_get_sent_seg(word_buffer_get_word_n(ref, s0_index)) == 1) && (word_get_sent_seg(word_buffer_get_word_n(config_get_buffer(c), s0_index)) != 1)){ return MVT_PARSER_EOS; - } + }*/ /* LEFT ARC b0 is the governor and s0 the dependent */ if(s0_gov_index == b0_index){ -- GitLab