From 3d2ba36393d717fb907222afaeddce4941544fa9 Mon Sep 17 00:00:00 2001 From: Alexis Nasr <alexis.nasr@lif.univ-mrs.fr> Date: Thu, 27 Oct 2016 22:21:26 -0400 Subject: [PATCH] uncommented function call that computes all features of a sentence --- maca_graph_parser/maca_graph_parser_decoder.c | 4 ++++ maca_graph_parser/maca_graph_parser_model.c | 1 + maca_graph_parser/maca_graph_parser_train.c | 4 +++- maca_tools/src/mcf2conll.c | 2 +- .../src/maca_trans_parser_arc_eager_mcf2cff.c | 3 ++- .../src/maca_trans_tagparser_arc_eager_mcf2cff.c | 3 ++- maca_trans_parser/src/simple_decoder_tagparser_arc_eager.c | 7 ++++++- 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/maca_graph_parser/maca_graph_parser_decoder.c b/maca_graph_parser/maca_graph_parser_decoder.c index 3095550..3d76cb3 100644 --- a/maca_graph_parser/maca_graph_parser_decoder.c +++ b/maca_graph_parser/maca_graph_parser_decoder.c @@ -69,6 +69,10 @@ void maca_graph_parser_decoder_parse(maca_graph_parser_ctx *ctx, maca_graph_pars fprintf(stderr, "parsing sentence\n"); }*/ + + /* extract features */ + maca_graph_parser_feature_table_fill(ctx, s, ctx->feature_table); + maca_graph_parser_decoder_init(ctx, s); if(ctx->k){ maca_graph_parser_hyperdecoder_parse(ctx, s, ctx->feature_table); diff --git a/maca_graph_parser/maca_graph_parser_model.c b/maca_graph_parser/maca_graph_parser_model.c index 978b471..b1e3bd6 100644 --- a/maca_graph_parser/maca_graph_parser_model.c +++ b/maca_graph_parser/maca_graph_parser_model.c @@ -262,6 +262,7 @@ float score_feature_counter_array(feature_counter_array *a, maca_graph_parser_mo if(v != 0){ float *w = recherche_hash(model->feat_ht, c->keys[j]); if(w != NULL){ + /* printf("AN value = %d score = %f\n", v, score); */ score += (v * (*w)); } } diff --git a/maca_graph_parser/maca_graph_parser_train.c b/maca_graph_parser/maca_graph_parser_train.c index 76df607..dbbdabd 100644 --- a/maca_graph_parser/maca_graph_parser_train.c +++ b/maca_graph_parser/maca_graph_parser_train.c @@ -38,9 +38,11 @@ void update_weights(maca_graph_parser_ctx *ctx, maca_graph_parser_sentence *ref_ /* with the projective decoder, this can happen if ref is non-projective */ /* TODO: check that it only happens in this case */ + float score_ref = score_feature_counter_array(ref_feat_cnt_array, ctx->model); float score_hyp = score_feature_counter_array(hyp_feat_cnt_array, ctx->model); - if(score_hyp < score_ref){ + + if(score_hyp < score_ref){ /* baseline strategy: skip update */ return; } diff --git a/maca_tools/src/mcf2conll.c b/maca_tools/src/mcf2conll.c index 1eb8b1a..272c181 100644 --- a/maca_tools/src/mcf2conll.c +++ b/maca_tools/src/mcf2conll.c @@ -196,7 +196,7 @@ int main(int argc, char *argv[]) fprintf(output_file, "\t"); /* fprintf(output_file, "\t_\t\n"); */ - fprintf(output_file, "\n"); + fprintf(output_file, "_\t_\n"); if((sent_seg_col) && (word_get_sent_seg(w))){ fprintf(output_file, "\n"); index = 0; diff --git a/maca_trans_parser/src/maca_trans_parser_arc_eager_mcf2cff.c b/maca_trans_parser/src/maca_trans_parser_arc_eager_mcf2cff.c index f0a16c0..dfca5e5 100644 --- a/maca_trans_parser/src/maca_trans_parser_arc_eager_mcf2cff.c +++ b/maca_trans_parser/src/maca_trans_parser_arc_eager_mcf2cff.c @@ -94,7 +94,7 @@ void generate_training_file(FILE *output_file, context *ctx) movement_parser_eos(c); sentence_nb++; if((sentence_nb % 100) == 0) - fprintf(stderr, "sentence %d\n", sentence_nb); + fprintf(stderr, "\rsentence %d", sentence_nb); /* if(word_buffer_is_last(ref)) */ break; case MVT_PARSER_LEFT : @@ -116,6 +116,7 @@ void generate_training_file(FILE *output_file, context *ctx) break; } } + fprintf(stderr, "\n"); } int main(int argc, char *argv[]) diff --git a/maca_trans_parser/src/maca_trans_tagparser_arc_eager_mcf2cff.c b/maca_trans_parser/src/maca_trans_tagparser_arc_eager_mcf2cff.c index 11c163c..cf95405 100644 --- a/maca_trans_parser/src/maca_trans_tagparser_arc_eager_mcf2cff.c +++ b/maca_trans_parser/src/maca_trans_tagparser_arc_eager_mcf2cff.c @@ -117,7 +117,7 @@ void generate_training_file(FILE *output_file, context *ctx) movement_tagparser_eos(c); sentence_nb++; if((sentence_nb % 100) == 0) - fprintf(stderr, "sentence %d\n", sentence_nb); + fprintf(stderr, "\rsentence %d", sentence_nb); break; case MVT_TAGPARSER_POSTAG : movement_tagparser_add_pos(c, mvt_label); @@ -141,6 +141,7 @@ void generate_training_file(FILE *output_file, context *ctx) break; } } + fprintf(stderr, "\n"); } int main(int argc, char *argv[]) diff --git a/maca_trans_parser/src/simple_decoder_tagparser_arc_eager.c b/maca_trans_parser/src/simple_decoder_tagparser_arc_eager.c index 15b8767..85791ef 100644 --- a/maca_trans_parser/src/simple_decoder_tagparser_arc_eager.c +++ b/maca_trans_parser/src/simple_decoder_tagparser_arc_eager.c @@ -161,7 +161,12 @@ void simple_decoder_tagparser_arc_eager(context *ctx) if(ctx->debug_mode){ fprintf(stdout, "WARNING : movement cannot be executed doing a SHIFT instead !\n"); } - movement_tagparser_shift(c); + result = movement_tagparser_shift(c); + if(result == 0){ /* SHIFT failed no more words to read, let's get out of here ! */ + if(ctx->debug_mode) fprintf(stdout, "WARNING : cannot exectue a SHIFT emptying stack !\n"); + while(!stack_is_empty(config_get_stack(c))) + movement_tagparser_root(c, root_label); + } } } -- GitLab