Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alexis Nasr
macaon2
Commits
bc8b7248
Commit
bc8b7248
authored
Apr 03, 2018
by
Alexis Nasr
Browse files
json2mcf : update the dependencies in json file to mcf file
parent
3e35914b
Changes
1
Hide whitespace changes
Inline
Side-by-side
maca_tools/src/json2mcf.c
View file @
bc8b7248
...
...
@@ -228,7 +228,7 @@ void json2mcf_print_word_buffer(FILE *f, word_buffer *wb)
*/
void
update_segment
(
word_buffer
*
wb
,
int
start
,
int
end
,
char
*
label
,
char
*
status_seg
,
char
*
status_lab
)
void
update_segment
(
word_buffer
*
wb
,
int
start
,
int
end
,
char
*
label
,
char
*
status_seg
,
char
*
status_lab
,
int
offset
)
{
int
index
;
word
*
w
;
...
...
@@ -241,9 +241,7 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat
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_with_offset
(
wb
,
start
);
w
=
word_buffer_get_word_n
(
wb
,
index
);
w
=
word_buffer_get_word_n
(
wb
,
offset
+
start
);
if
(
d
)
label_code
=
dico_string2int
(
d
,
label
);
if
(
label_code
==
-
1
)
...
...
@@ -253,7 +251,7 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat
}
}
void
process_segment
(
json_attr_val
*
avl
,
word_buffer
*
wb
)
void
process_segment
(
json_attr_val
*
avl
,
word_buffer
*
wb
,
int
offset
)
{
int
start
,
end
;
char
*
label
,
*
status_seg
,
*
status_lab
;
...
...
@@ -267,27 +265,27 @@ void process_segment(json_attr_val *avl, word_buffer *wb)
if
(
!
strcmp
(
av
->
attr
,
"status_seg"
)){
status_seg
=
av
->
val
->
u
.
string
;
continue
;}
if
(
!
strcmp
(
av
->
attr
,
"status_lab"
)){
status_lab
=
av
->
val
->
u
.
string
;
continue
;}
}
update_segment
(
wb
,
start
,
end
,
label
,
status_seg
,
status_lab
);
update_segment
(
wb
,
start
,
end
,
label
,
status_seg
,
status_lab
,
offset
);
// printf("segment : start = %d end = %d label = %s status_seg = %s status_lab = %s\n", start, end, label, status_seg, status_lab);
}
void
process_segments
(
json_struct
*
segments
,
word_buffer
*
wb
)
void
process_segments
(
json_struct
*
segments
,
word_buffer
*
wb
,
int
offset
)
{
json_struct
*
segment
;
// printf("process_segments\n");
for
(
segment
=
segments
->
u
.
first
;
segment
!=
NULL
;
segment
=
segment
->
next
){
process_segment
(
segment
->
u
.
attr_val_list
,
wb
);
process_segment
(
segment
->
u
.
attr_val_list
,
wb
,
offset
);
}
}
// {"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
)
void
update_link
(
word_buffer
*
wb
,
int
orig
,
int
dest
,
char
*
label
,
char
*
status_link
,
char
*
status_lab
,
int
offset
)
{
int
index
;
word
*
w
;
word
*
w
=
NULL
;
int
label_code
=
-
1
;
dico
*
d
;
mcd
*
mcd_struct
=
NULL
;
...
...
@@ -297,8 +295,7 @@ void update_link(word_buffer *wb, int orig, int dest, char *label, char *status
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
);
w
=
word_buffer_get_word_n
(
wb
,
offset
+
orig
);
if
(
d
)
label_code
=
dico_string2int
(
d
,
label
);
...
...
@@ -310,15 +307,15 @@ void update_link(word_buffer *wb, int orig, int dest, char *label, char *status
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
);
w
=
word_buffer_get_word_n
(
wb
,
offset
+
orig
)
;
printf
(
"dest - orig = %d
\n
"
,
dest
-
orig
);
word_set_gov
(
w
,
dest
-
orig
);
}
}
void
process_link
(
json_attr_val
*
avl
,
word_buffer
*
wb
)
void
process_link
(
json_attr_val
*
avl
,
word_buffer
*
wb
,
int
offset
)
{
int
orig
,
dest
;
char
*
label
,
*
status_link
,
*
status_lab
;
...
...
@@ -332,18 +329,18 @@ 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_lab"
)){
status_lab
=
av
->
val
->
u
.
string
;
continue
;}
}
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
);
//
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
,
offset
);
}
void
process_links
(
json_struct
*
links
,
word_buffer
*
wb
)
void
process_links
(
json_struct
*
links
,
word_buffer
*
wb
,
int
offset
)
{
json_struct
*
link
;
// printf("process_links\n");
for
(
link
=
links
->
u
.
first
;
link
!=
NULL
;
link
=
link
->
next
){
process_link
(
link
->
u
.
attr_val_list
,
wb
);
process_link
(
link
->
u
.
attr_val_list
,
wb
,
offset
);
}
}
...
...
@@ -374,11 +371,11 @@ void process_document(json_struct *document, word_buffer *wb)
{
json_attr_val
*
avl
=
NULL
;
int
offset
=
get_id_of_first_token_in_document
(
document
);
printf
(
"process_document, offset = %d
\n
"
,
offset
);
//
printf("process_document, offset = %d\n", offset);
for
(
avl
=
document
->
u
.
attr_val_list
;
avl
!=
NULL
;
avl
=
avl
->
next
){
// if(!strcmp(avl->attr, (char *)"id")) printf("id = %s\n", avl->val->u.string);
if
(
!
strcmp
(
avl
->
attr
,
(
char
*
)
"segments"
))
process_segments
(
avl
->
val
,
wb
);
if
(
!
strcmp
(
avl
->
attr
,
(
char
*
)
"links"
))
process_links
(
avl
->
val
,
wb
);
if
(
!
strcmp
(
avl
->
attr
,
(
char
*
)
"segments"
))
process_segments
(
avl
->
val
,
wb
,
offset
);
if
(
!
strcmp
(
avl
->
attr
,
(
char
*
)
"links"
))
process_links
(
avl
->
val
,
wb
,
offset
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment