Commit 1d536e6c authored by Alexis Nasr's avatar Alexis Nasr
Browse files

fixed a bug in word.h

parent 326f414c
......@@ -3,6 +3,7 @@ project(macaon2)
find_package(FLEX)
find_package(BLAS)
find_package(DyNet)
add_definitions("-Wall" )
SET(CMAKE_C_COMPILER g++)
......
......@@ -59,7 +59,7 @@ typedef struct _word {
#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) ? 0 : (w)->wf_array[MCD_WF_GOV])
#define word_get_gov(w) (((w) == NULL) ? WORD_INVALID_GOV : (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) ? 0 : (w)->wf_array[MCD_WF_SENT_SEG])
......
......@@ -4,33 +4,6 @@
#include"util.h"
#include"movements.h"
int movement_eos(config *c, int movement_code)
{
if(stack_is_empty(config_get_stack(c))) return 0;
word *s0 = stack_top(config_get_stack(c));
/* word on top of stack is already eos */
if(word_get_sent_seg(s0) == 1) return 0;
/* set word on the top of the stack to eos */
word_set_sent_seg(s0, 1);
config_push_mvt(c, movement_code, s0, NULL);
return 1;
}
int movement_eos_undo(config *c)
{
word *gov = mvt_get_gov(mvt_stack_top(config_get_history(c)));
/* word on the top of the stack is not eos anymore */
word_set_sent_seg(gov, 0);
mvt_free(config_pop_mvt(c));
return 1;
}
int movement_left_arc(config *c, int movement_code, int label)
{
if(stack_is_empty(config_get_stack(c))) return 0;
......@@ -158,8 +131,9 @@ int movement_root(config *c, int movement_code, int 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);
// 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);
......@@ -179,6 +153,32 @@ int movement_root_undo(config *c)
return 1;
}
int movement_eos(config *c, int movement_code)
{
if(stack_is_empty(config_get_stack(c))) return 0;
word *s0 = stack_top(config_get_stack(c));
/* word on top of stack is already eos */
if(word_get_sent_seg(s0) == 1) return 0;
/* set word on the top of the stack to eos */
word_set_sent_seg(s0, 1);
stack_pop(config_get_stack(c));
config_push_mvt(c, movement_code, s0, NULL);
return 1;
}
int movement_eos_undo(config *c)
{
word *gov = mvt_get_gov(mvt_stack_top(config_get_history(c)));
/* word on the top of the stack is not eos anymore */
word_set_sent_seg(gov, 0);
mvt_free(config_pop_mvt(c));
return 1;
}
int movement_add_pos(config *c, int movement_code, int pos)
{
if(word_buffer_b0(config_get_buffer(c)) == NULL) return 0;
......
......@@ -61,17 +61,20 @@ int oracle_parser_arc_eager(config *c, word_buffer *ref, int root_label)
printf("dans ref gov de b0 (%d) = %d\n", b0_index, b0_gov_index);*/
/* s0 is the root of the sentence */
/* if((s0_label == root_label)
&& check_all_dependents_of_word_in_ref_are_in_hyp(c, ref, s0_index)
if((s0_label == root_label)
// && (word_get_label(word_buffer_get_word_n(config_get_buffer(c), s0_index)) != root_label)
&& check_all_dependents_of_word_in_ref_are_in_hyp(c, ref, s0_index)
){
return MVT_PARSER_ROOT;
}*/
}
/* 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)
&& (word_get_sent_seg(word_buffer_get_word_n(config_get_buffer(c), s0_index)) != 1)){
// && (word_get_sent_seg(word_buffer_get_word_n(config_get_buffer(c), s0_index)) != 1)
&& check_all_dependents_of_word_in_ref_are_in_hyp(c, ref, s0_index)
){
return MVT_PARSER_EOS;
}
}
/* LEFT ARC b0 is the governor and s0 the dependent */
if(s0_gov_index == b0_index){
return movement_parser_left_code(word_get_label(word_buffer_get_word_n(ref, s0_index)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment