Skip to content
Snippets Groups Projects
Commit b4b15f51 authored by Alexis Nasr's avatar Alexis Nasr
Browse files

introduced update of depenencies in tool json2mcf

parent cf114feb
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,7 @@ void word_buffer_print(FILE *f, word_buffer *wb); ...@@ -54,7 +54,7 @@ void word_buffer_print(FILE *f, word_buffer *wb);
void word_buffer_print_compact(FILE *f, word_buffer *wb); void word_buffer_print_compact(FILE *f, word_buffer *wb);
int word_buffer_read_sentence(word_buffer *bw); int word_buffer_read_sentence(word_buffer *bw);
word_buffer *word_buffer_load_mcf(char *mcf_filename, mcd *mcd_struct); word_buffer *word_buffer_load_mcf(char *mcf_filename, mcd *mcd_struct);
int word_buffer_locate_token(word_buffer *wb, int offset); int word_buffer_locate_token_with_offset(word_buffer *wb, int offset);
/* /*
int word_buffer_is_empty(word_buffer *wb); int word_buffer_is_empty(word_buffer *wb);
int word_buffer_is_last(word_buffer *wb); int word_buffer_is_last(word_buffer *wb);
......
...@@ -156,7 +156,7 @@ int word_buffer_read_sentence(word_buffer *wb) ...@@ -156,7 +156,7 @@ int word_buffer_read_sentence(word_buffer *wb)
return wb->nbelem ; return wb->nbelem ;
} }
int word_buffer_locate_token(word_buffer *wb, int offset) int word_buffer_locate_token_with_offset(word_buffer *wb, int offset)
{ {
int c, first, last, middle; int c, first, last, middle;
word *w_middle; word *w_middle;
......
...@@ -241,7 +241,7 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat ...@@ -241,7 +241,7 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat
if(status_lab && !strcmp(status_lab, "G")){ if(status_lab && !strcmp(status_lab, "G")){
fprintf(stderr, "updating label of segment [%d-%d] with \"%s\"\n", start, end, label); fprintf(stderr, "updating label of segment [%d-%d] with \"%s\"\n", start, end, label);
index = word_buffer_locate_token(wb, start); index = word_buffer_locate_token_with_offset(wb, start);
w = word_buffer_get_word_n(wb, index); w = word_buffer_get_word_n(wb, index);
if(d) if(d)
...@@ -287,6 +287,40 @@ void process_segments(json_struct *segments, word_buffer *wb) ...@@ -287,6 +287,40 @@ void process_segments(json_struct *segments, word_buffer *wb)
// {"orig": 1, "dest":2, "label": "suj", "status_link": "", "status_lab": "", "timestamp": "", "author": "", "target": ""}, // {"orig": 1, "dest":2, "label": "suj", "status_link": "", "status_lab": "", "timestamp": "", "author": "", "target": ""},
void update_link(word_buffer *wb, int orig, int dest, char *label, char *status_link, char *status_lab)
{
int index;
word *w;
int label_code = -1;
dico *d;
mcd *mcd_struct = NULL;
mcd_struct = word_buffer_get_mcd(wb);
d = mcd_struct->dico_array[mcd_get_label_col(mcd_struct)];
if(status_lab && !strcmp(status_lab, "G")){
fprintf(stderr, "updating label of link %d -> %d with \"%s\"\n", orig, dest, label);
index = orig;
w = word_buffer_get_word_n(wb, index);
if(d)
label_code = dico_string2int(d, label);
if(label_code == -1)
fprintf(stderr, "label %s unknown\n", label);
else
word_set_label(w, label_code);
}
if(status_link && !strcmp(status_link, "G")){
fprintf(stderr, "updating governor of token %d with %d\n", orig, dest);
index = orig;
w = word_buffer_get_word_n(wb, index);
word_set_gov(w, dest);
}
}
void process_link(json_attr_val *avl, word_buffer *wb) void process_link(json_attr_val *avl, word_buffer *wb)
{ {
...@@ -302,7 +336,10 @@ void process_link(json_attr_val *avl, word_buffer *wb) ...@@ -302,7 +336,10 @@ void process_link(json_attr_val *avl, word_buffer *wb)
if(!strcmp(av->attr, "status_link")){status_link = av->val->u.string; continue;} if(!strcmp(av->attr, "status_link")){status_link = av->val->u.string; continue;}
if(!strcmp(av->attr, "status_lab")){status_lab = av->val->u.string; continue;} if(!strcmp(av->attr, "status_lab")){status_lab = av->val->u.string; continue;}
} }
// printf("link : orig = %d dest = %d label = %s status_link = %s status_lab = %s\n", orig, dest, label, status_link, status_lab); fprintf(stderr, "link : orig = %d dest = %d label = %s status_link = %s status_lab = %s\n", orig, dest, label, status_link, status_lab);
update_link(wb, orig, dest, label, status_link, status_lab);
} }
void process_links(json_struct *segments, word_buffer *wb) void process_links(json_struct *segments, word_buffer *wb)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment