Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexis Nasr
macaon2
Commits
bc8b7248
Commit
bc8b7248
authored
7 years ago
by
Alexis Nasr
Browse files
Options
Downloads
Patches
Plain Diff
json2mcf : update the dependencies in json file to mcf file
parent
3e35914b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
maca_tools/src/json2mcf.c
+20
-23
20 additions, 23 deletions
maca_tools/src/json2mcf.c
with
20 additions
and
23 deletions
maca_tools/src/json2mcf.c
+
20
−
23
View file @
bc8b7248
...
@@ -228,7 +228,7 @@ void json2mcf_print_word_buffer(FILE *f, word_buffer *wb)
...
@@ -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
;
int
index
;
word
*
w
;
word
*
w
;
...
@@ -241,9 +241,7 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat
...
@@ -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"
)){
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_with_offset
(
wb
,
start
);
w
=
word_buffer_get_word_n
(
wb
,
offset
+
start
);
w
=
word_buffer_get_word_n
(
wb
,
index
);
if
(
d
)
if
(
d
)
label_code
=
dico_string2int
(
d
,
label
);
label_code
=
dico_string2int
(
d
,
label
);
if
(
label_code
==
-
1
)
if
(
label_code
==
-
1
)
...
@@ -253,7 +251,7 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat
...
@@ -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
;
int
start
,
end
;
char
*
label
,
*
status_seg
,
*
status_lab
;
char
*
label
,
*
status_seg
,
*
status_lab
;
...
@@ -267,27 +265,27 @@ void process_segment(json_attr_val *avl, word_buffer *wb)
...
@@ -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_seg"
)){
status_seg
=
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
;}
}
}
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);
// 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
;
json_struct
*
segment
;
// printf("process_segments\n");
// printf("process_segments\n");
for
(
segment
=
segments
->
u
.
first
;
segment
!=
NULL
;
segment
=
segment
->
next
){
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": ""},
// {"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
;
int
index
;
word
*
w
;
word
*
w
=
NULL
;
int
label_code
=
-
1
;
int
label_code
=
-
1
;
dico
*
d
;
dico
*
d
;
mcd
*
mcd_struct
=
NULL
;
mcd
*
mcd_struct
=
NULL
;
...
@@ -297,8 +295,7 @@ void update_link(word_buffer *wb, int orig, int dest, char *label, char *status
...
@@ -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"
)){
if
(
status_lab
&&
!
strcmp
(
status_lab
,
"G"
)){
fprintf
(
stderr
,
"updating label of link %d -> %d with
\"
%s
\"\n
"
,
orig
,
dest
,
label
);
fprintf
(
stderr
,
"updating label of link %d -> %d with
\"
%s
\"\n
"
,
orig
,
dest
,
label
);
index
=
orig
;
w
=
word_buffer_get_word_n
(
wb
,
offset
+
orig
);
w
=
word_buffer_get_word_n
(
wb
,
index
);
if
(
d
)
if
(
d
)
label_code
=
dico_string2int
(
d
,
label
);
label_code
=
dico_string2int
(
d
,
label
);
...
@@ -310,15 +307,15 @@ void update_link(word_buffer *wb, int orig, int dest, char *label, char *status
...
@@ -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"
)){
if
(
status_link
&&
!
strcmp
(
status_link
,
"G"
)){
fprintf
(
stderr
,
"updating governor of token %d with %d
\n
"
,
orig
,
dest
);
fprintf
(
stderr
,
"updating governor of token %d with %d
\n
"
,
orig
,
dest
);
index
=
orig
;
w
=
word_buffer_get_word_n
(
wb
,
offset
+
orig
)
;
w
=
word_buffer_get_word_n
(
wb
,
index
);
printf
(
"dest - orig = %d
\n
"
,
dest
-
orig
);
word_set_gov
(
w
,
dest
);
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
;
int
orig
,
dest
;
char
*
label
,
*
status_link
,
*
status_lab
;
char
*
label
,
*
status_link
,
*
status_lab
;
...
@@ -332,18 +329,18 @@ void process_link(json_attr_val *avl, word_buffer *wb)
...
@@ -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_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
;}
}
}
fprintf
(
stderr
,
"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
);
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
;
json_struct
*
link
;
// printf("process_links\n");
// printf("process_links\n");
for
(
link
=
links
->
u
.
first
;
link
!=
NULL
;
link
=
link
->
next
){
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)
...
@@ -374,11 +371,11 @@ void process_document(json_struct *document, word_buffer *wb)
{
{
json_attr_val
*
avl
=
NULL
;
json_attr_val
*
avl
=
NULL
;
int
offset
=
get_id_of_first_token_in_document
(
document
);
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
){
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 *)"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
*
)
"segments"
))
process_segments
(
avl
->
val
,
wb
,
offset
);
if
(
!
strcmp
(
avl
->
attr
,
(
char
*
)
"links"
))
process_links
(
avl
->
val
,
wb
);
if
(
!
strcmp
(
avl
->
attr
,
(
char
*
)
"links"
))
process_links
(
avl
->
val
,
wb
,
offset
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment