Skip to content
Snippets Groups Projects
Commit 98375cb1 authored by robin.perrotin's avatar robin.perrotin
Browse files

probabilistic parser

parent 8ed0b928
Branches
No related tags found
No related merge requests found
...@@ -151,6 +151,10 @@ void simple_decoder_parser_arc_eager(context *ctx) ...@@ -151,6 +151,10 @@ void simple_decoder_parser_arc_eager(context *ctx)
int index; int index;
float score; float score;
double sumExp = 0.;
double currentSumExp = 0.;
double ScoreTranslation = -150.;
word* word_scored; word* word_scored;
root_label = dico_string2int(ctx->dico_labels, ctx->root_label); root_label = dico_string2int(ctx->dico_labels, ctx->root_label);
...@@ -182,7 +186,25 @@ void simple_decoder_parser_arc_eager(context *ctx) ...@@ -182,7 +186,25 @@ void simple_decoder_parser_arc_eager(context *ctx)
if(ctx->debug_mode){ if(ctx->debug_mode){
vcode *vcode_array = feature_table_get_vcode_array(fv, ft); vcode *vcode_array = feature_table_get_vcode_array(fv, ft);
for(int i=0; i < ctx->mvt_nb && i < 1000; i++){
/* Get the probabilistic parameters */
for(int i=0; i < ft->classes_nb; i++){
int b1 = respect_standard_constraint(c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code));
int b2 = respect_stack_constraint(ctx->partial_mode, c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code));
int b3 = respect_buffer_constraint(ctx->partial_mode, c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code));
if(b1 && b2 && b3){
if(sumExp == 0.){
sumExp += vcode_array[i].score;
}
if(vcode_array[i].score - sumExp >= 0){
sumExp += exp(vcode_array[i].score - sumExp);
}
}
}
currentSumExp = 0.;
for(int i=0; i < ft->classes_nb && i < 1000; i++){
printf("%d\t", i); printf("%d\t", i);
movement_parser_print(stdout, vcode_array[i].class_code, ctx->dico_labels); movement_parser_print(stdout, vcode_array[i].class_code, ctx->dico_labels);
printf("\t%.4f", vcode_array[i].score); printf("\t%.4f", vcode_array[i].score);
...@@ -190,13 +212,17 @@ void simple_decoder_parser_arc_eager(context *ctx) ...@@ -190,13 +212,17 @@ void simple_decoder_parser_arc_eager(context *ctx)
int b1 = respect_standard_constraint(c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code)); int b1 = respect_standard_constraint(c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code));
int b2 = respect_stack_constraint(ctx->partial_mode, c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code)); int b2 = respect_stack_constraint(ctx->partial_mode, c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code));
int b3 = respect_buffer_constraint(ctx->partial_mode, c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code)); int b3 = respect_buffer_constraint(ctx->partial_mode, c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code));
printf(" %f ",exp(vcode_array[i].score)); if(b1 && b2 && b3){
if(b1 && b2 && b3) if(vcode_array[i].score - sumExp >= 0){
printf(" [%f-",currentSumExp/sumExp));
currentSumExp += exp(vcode_array[i].score - sumExp);
printf("%f[", currentSumExp/sumExp));
}
printf("\t<----"); printf("\t<----");
else }else
printf("\t<%d,%d,%d>",b1,b2,b3); printf("\t<%d,%d,%d>",b1,b2,b3);
// printf("\t%d", respect_standard_constraint(c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code))); // printf("\t%d", respect_standard_constraint(c, movement_parser_type(vcode_array[i].class_code), movement_parser_label(vcode_array[i].class_code)));
printf("AAAAAAA\n"); //printf("AAAAAAA\n");
printf("\n"); printf("\n");
} }
free(vcode_array); free(vcode_array);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment