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
91721019
Commit
91721019
authored
7 years ago
by
Alexis Nasr
Browse files
Options
Downloads
Patches
Plain Diff
a new function in json2mcf to get the id of the first token of a sentence
parent
cf114feb
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
maca_tools/src/json2mcf.c
+26
-7
26 additions, 7 deletions
maca_tools/src/json2mcf.c
maca_tools/src/mcf2json.c
+1
-10
1 addition, 10 deletions
maca_tools/src/mcf2json.c
maca_trans_parser/src/movements.c
+1
-1
1 addition, 1 deletion
maca_trans_parser/src/movements.c
with
28 additions
and
18 deletions
maca_tools/src/json2mcf.c
+
26
−
7
View file @
91721019
...
@@ -251,12 +251,8 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat
...
@@ -251,12 +251,8 @@ void update_segment(word_buffer *wb, int start, int end, char *label, char *stat
else
else
word_set_pos
(
w
,
label_code
);
word_set_pos
(
w
,
label_code
);
}
}
}
}
void
process_segment
(
json_attr_val
*
avl
,
word_buffer
*
wb
)
void
process_segment
(
json_attr_val
*
avl
,
word_buffer
*
wb
)
{
{
int
start
,
end
;
int
start
,
end
;
...
@@ -305,20 +301,43 @@ void process_link(json_attr_val *avl, word_buffer *wb)
...
@@ -305,20 +301,43 @@ void process_link(json_attr_val *avl, word_buffer *wb)
// printf("link : orig = %d dest = %d label = %s status_link = %s status_lab = %s\n", orig, dest, label, status_link, status_lab);
// printf("link : orig = %d dest = %d label = %s status_link = %s status_lab = %s\n", orig, dest, label, status_link, status_lab);
}
}
void
process_links
(
json_struct
*
segment
s
,
word_buffer
*
wb
)
void
process_links
(
json_struct
*
link
s
,
word_buffer
*
wb
)
{
{
json_struct
*
link
;
json_struct
*
link
;
// printf("process_links\n");
// printf("process_links\n");
for
(
link
=
segment
s
->
u
.
first
;
link
!=
NULL
;
link
=
link
->
next
){
for
(
link
=
link
s
->
u
.
first
;
link
!=
NULL
;
link
=
link
->
next
){
process_link
(
link
->
u
.
attr_val_list
,
wb
);
process_link
(
link
->
u
.
attr_val_list
,
wb
);
}
}
}
}
int
get_id_of_first_token_in_document
(
json_struct
*
document
)
{
json_attr_val
*
avl
=
NULL
;
json_struct
*
tokens
,
*
token
;
json_attr_val
*
avl2
=
NULL
;
for
(
avl
=
document
->
u
.
attr_val_list
;
avl
!=
NULL
;
avl
=
avl
->
next
){
if
(
!
strcmp
(
avl
->
attr
,
(
char
*
)
"tokens"
)){
tokens
=
avl
->
val
;
if
(
tokens
){
token
=
tokens
->
u
.
first
;
if
(
token
){
for
(
avl2
=
token
->
u
.
attr_val_list
;
avl2
!=
NULL
;
avl2
=
avl2
->
next
){
if
(
!
strcmp
(
avl2
->
attr
,
(
char
*
)
"id"
))
return
(
int
)
avl2
->
val
->
u
.
number
;
}
}
}
}
}
return
-
1
;
}
void
process_document
(
json_struct
*
document
,
word_buffer
*
wb
)
void
process_document
(
json_struct
*
document
,
word_buffer
*
wb
)
{
{
json_attr_val
*
avl
=
NULL
;
json_attr_val
*
avl
=
NULL
;
// printf("process_document\n");
int
offset
=
get_id_of_first_token_in_document
(
document
);
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
);
...
...
This diff is collapsed.
Click to expand it.
maca_tools/src/mcf2json.c
+
1
−
10
View file @
91721019
...
@@ -184,8 +184,6 @@ void print_link(FILE *output_file, word_buffer *wb, int index_first_word, int in
...
@@ -184,8 +184,6 @@ void print_link(FILE *output_file, word_buffer *wb, int index_first_word, int in
word
*
w
=
word_buffer_get_word_n
(
wb
,
index
);
word
*
w
=
word_buffer_get_word_n
(
wb
,
index
);
fprintf
(
output_file
,
"{"
);
fprintf
(
output_file
,
"{"
);
// fprintf(output_file, "\"orig\": %d, ", word_get_offset(w));
fprintf
(
output_file
,
"
\"
orig
\"
: %d, "
,
index
-
index_first_word
);
fprintf
(
output_file
,
"
\"
orig
\"
: %d, "
,
index
-
index_first_word
);
fprintf
(
output_file
,
"
\"
dest
\"
:"
);
fprintf
(
output_file
,
"
\"
dest
\"
:"
);
if
(
gov_col
){
if
(
gov_col
){
...
@@ -193,7 +191,6 @@ void print_link(FILE *output_file, word_buffer *wb, int index_first_word, int in
...
@@ -193,7 +191,6 @@ void print_link(FILE *output_file, word_buffer *wb, int index_first_word, int in
fprintf
(
output_file
,
"-1"
);
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_gov
(
w
)
+
index
-
index_first_word
);
fprintf
(
output_file
,
"%d"
,
word_get_gov
(
w
)
+
index
-
index_first_word
);
}
}
}
}
...
@@ -240,9 +237,7 @@ void print_segment(FILE *output_file, word_buffer *wb, int index_first_word, int
...
@@ -240,9 +237,7 @@ void print_segment(FILE *output_file, word_buffer *wb, int index_first_word, int
word
*
w
=
word_buffer_get_word_n
(
wb
,
index
);
word
*
w
=
word_buffer_get_word_n
(
wb
,
index
);
fprintf
(
output_file
,
"{ "
);
fprintf
(
output_file
,
"{ "
);
/* fprintf(output_file, "\"start\": %d, ", word_get_offset(w)); */
fprintf
(
output_file
,
"
\"
start
\"
: %d, "
,
index
-
index_first_word
);
fprintf
(
output_file
,
"
\"
start
\"
: %d, "
,
index
-
index_first_word
);
/* fprintf(output_file, "\"end\": %d, ", word_get_offset(w) + word_get_length(w) - 1); */
fprintf
(
output_file
,
"
\"
end
\"
: %d, "
,
index
-
index_first_word
);
fprintf
(
output_file
,
"
\"
end
\"
: %d, "
,
index
-
index_first_word
);
fprintf
(
output_file
,
"
\"
label
\"
:
\"
"
);
fprintf
(
output_file
,
"
\"
label
\"
:
\"
"
);
...
@@ -278,16 +273,12 @@ void print_segments(FILE *output_file, word_buffer *wb, int index_first_word, in
...
@@ -278,16 +273,12 @@ void print_segments(FILE *output_file, word_buffer *wb, int index_first_word, in
void
print_token
(
FILE
*
output_file
,
word_buffer
*
wb
,
int
index
)
void
print_token
(
FILE
*
output_file
,
word_buffer
*
wb
,
int
index
)
{
{
int
form_col
=
mcd_get_form_col
(
word_buffer_get_mcd
(
wb
));
int
form_col
=
mcd_get_form_col
(
word_buffer_get_mcd
(
wb
));
int
offset_col
=
mcd_get_offset_col
(
word_buffer_get_mcd
(
wb
));
int
length_col
=
mcd_get_length_col
(
word_buffer_get_mcd
(
wb
));
int
length_col
=
mcd_get_length_col
(
word_buffer_get_mcd
(
wb
));
word
*
w
=
word_buffer_get_word_n
(
wb
,
index
);
word
*
w
=
word_buffer_get_word_n
(
wb
,
index
);
char
token
[
5000
];
char
token
[
5000
];
int
length_token
,
i
;
int
length_token
,
i
;
fprintf
(
output_file
,
"{ "
);
fprintf
(
output_file
,
"{ "
);
if
(
word_get_offset
(
w
)
!=
-
1
)
fprintf
(
output_file
,
"
\"
id
\"
: %d, "
,
word_get_offset
(
w
));
else
fprintf
(
output_file
,
"
\"
id
\"
: %d, "
,
word_get_index
(
w
));
fprintf
(
output_file
,
"
\"
id
\"
: %d, "
,
word_get_index
(
w
));
fprintf
(
output_file
,
"
\"
word
\"
:
\"
"
);
fprintf
(
output_file
,
"
\"
word
\"
:
\"
"
);
if
(
form_col
!=
-
1
){
if
(
form_col
!=
-
1
){
...
...
This diff is collapsed.
Click to expand it.
maca_trans_parser/src/movements.c
+
1
−
1
View file @
91721019
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