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

minor changes in mcf2json, the root dependency has -1 as a governor

parent 723cafa9
No related branches found
No related tags found
No related merge requests found
...@@ -153,6 +153,7 @@ dico *dico_extract_from_corpus(char *filename, int column, char *dico_name) ...@@ -153,6 +153,7 @@ dico *dico_extract_from_corpus(char *filename, int column, char *dico_name)
char *token; char *token;
int column_nb = 0; int column_nb = 0;
if(feof(f)) return NULL; /* no more words to read */ if(feof(f)) return NULL; /* no more words to read */
while(fgets(buffer, 10000, f)){ while(fgets(buffer, 10000, f)){
...@@ -164,7 +165,7 @@ dico *dico_extract_from_corpus(char *filename, int column, char *dico_name) ...@@ -164,7 +165,7 @@ dico *dico_extract_from_corpus(char *filename, int column, char *dico_name)
column_nb = 0; column_nb = 0;
do{ do{
if(column_nb == column){ if(column_nb == column){
/* printf("token = %s\n", token); */ // printf("token = %s\n", token);
dico_add(d, token); dico_add(d, token);
} }
column_nb++; column_nb++;
......
...@@ -232,14 +232,18 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat ...@@ -232,14 +232,18 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat
{ {
int index; int index;
word *w; word *w;
int label_code; int label_code = -1;
dico *d; dico *d;
mcd *mcd_struct = NULL;
if(status_lab && !strcmp(status_lab, "GOLD")){ mcd_struct = word_buffer_get_mcd(wb);
printf("updating label of segment [%d-%d] with \"%s\"\n", start, end, label); d = mcd_struct->dico_array[mcd_get_pos_col(mcd_struct)];
if(status_lab && !strcmp(status_lab, "G")){
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(wb, start);
w = word_buffer_get_word_n(wb, index); w = word_buffer_get_word_n(wb, index);
d = word_buffer_get_mcd(wb)->dico_array[MCD_WF_CPOS];
if(d) if(d)
label_code = dico_string2int(d, label); label_code = dico_string2int(d, label);
if(label_code == -1) if(label_code == -1)
......
...@@ -176,7 +176,7 @@ void print_header(FILE *output_file, mcd *mcd_struct, char *filename) ...@@ -176,7 +176,7 @@ void print_header(FILE *output_file, mcd *mcd_struct, char *filename)
} }
void print_link(FILE *output_file, word_buffer *wb, int index) void print_link(FILE *output_file, word_buffer *wb, int index_first_word, int index)
{ {
int gov_col = mcd_get_gov_col(word_buffer_get_mcd(wb)); int gov_col = mcd_get_gov_col(word_buffer_get_mcd(wb));
int label_col = mcd_get_label_col(word_buffer_get_mcd(wb)); int label_col = mcd_get_label_col(word_buffer_get_mcd(wb));
...@@ -186,15 +186,15 @@ void print_link(FILE *output_file, word_buffer *wb, int index) ...@@ -186,15 +186,15 @@ void print_link(FILE *output_file, word_buffer *wb, int index)
fprintf(output_file, "{"); fprintf(output_file, "{");
// fprintf(output_file, "\"orig\": %d, ", word_get_offset(w)); // fprintf(output_file, "\"orig\": %d, ", word_get_offset(w));
fprintf(output_file, "\"orig\": %d, ", index); fprintf(output_file, "\"orig\": %d, ", index - index_first_word);
fprintf(output_file, "\"dest\":"); fprintf(output_file, "\"dest\":");
if(gov_col){ if(gov_col){
if((word_get_gov(w) == 0) || ((word_get_gov(w) + index) < 0)) if((word_get_gov(w) == 0) || ((word_get_gov(w) + index) < 0))
fprintf(output_file, "0"); fprintf(output_file, "-1");
else{ else{
word *gov = word_buffer_get_word_n(wb, word_get_gov(w) + index); word *gov = word_buffer_get_word_n(wb, word_get_gov(w) + index);
// fprintf(output_file, "%d", word_get_offset(gov)); // fprintf(output_file, "%d", word_get_offset(gov));
fprintf(output_file, "%d", word_get_gov(w) + index); fprintf(output_file, "%d", word_get_gov(w) + index - index_first_word);
} }
} }
else else
...@@ -228,7 +228,7 @@ void print_links(FILE *output_file, word_buffer *wb, int index_first_word, int i ...@@ -228,7 +228,7 @@ void print_links(FILE *output_file, word_buffer *wb, int index_first_word, int i
for(index = index_first_word; index <= index_last_word; index++){ for(index = index_first_word; index <= index_last_word; index++){
if(first_link == 1) first_link = 0; else fprintf(output_file, ","); if(first_link == 1) first_link = 0; else fprintf(output_file, ",");
fprintf(output_file, "\n"); fprintf(output_file, "\n");
print_link(output_file, wb, index); print_link(output_file, wb, index_first_word, index);
} }
fprintf(output_file," ]"); fprintf(output_file," ]");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment