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
0705ed04
Commit
0705ed04
authored
Apr 23, 2018
by
Alexis Nasr
Browse files
fixed few bugs in conll_lib
parent
b86a0bf2
Changes
1
Hide whitespace changes
Inline
Side-by-side
maca_common/src/conll_lib.c
View file @
0705ed04
...
...
@@ -24,7 +24,7 @@ int conll_parse_line(FILE *f, conll_sentence *s);
void
conll_compute_relative_index_of_heads
(
conll_sentence
*
s
)
{
int
i
;
unsigned
i
;
conll_word
*
w
;
for
(
i
=
1
;
i
<
s
->
l
;
i
++
){
...
...
@@ -39,7 +39,7 @@ void conll_compute_relative_index_of_heads(conll_sentence *s)
void
conll_renumber_sentence
(
conll_sentence
*
s
)
{
int
i
;
unsigned
i
;
conll_word
*
w
;
for
(
i
=
0
;
i
<
s
->
l
;
i
++
){
s
->
words
[
i
]
->
id
=
i
;
...
...
@@ -56,21 +56,21 @@ void conll_renumber_sentence(conll_sentence *s)
void
conll_reset_sentence
(
conll_sentence
*
s
)
{
int
i
;
unsigned
i
;
for
(
i
=
0
;
i
<
s
->
l
;
i
++
){
if
(
s
->
words
[
i
]){
free
(
s
->
words
[
i
]);
s
->
words
[
i
]
=
NULL
;
}
}
s
->
words
[
0
]
=
conll_allocate_word
(
0
,
"ROOT"
,
"ROOT"
,
"ROOT"
,
"ROOT"
,
"ROOT"
,
-
1
,
"ROOT"
);
s
->
words
[
0
]
=
conll_allocate_word
(
0
,
(
char
*
)
"ROOT"
,
(
char
*
)
"ROOT"
,
(
char
*
)
"ROOT"
,
(
char
*
)
"ROOT"
,
(
char
*
)
"ROOT"
,
-
1
,
(
char
*
)
"ROOT"
);
s
->
l
=
1
;
}
void
conll_free_sentence
(
conll_sentence
*
s
)
{
int
i
;
unsigned
i
;
for
(
i
=
0
;
i
<
s
->
l
;
i
++
){
if
(
s
->
words
[
i
]){
/* free(s->words[i]); */
...
...
@@ -104,7 +104,7 @@ conll_word *conll_allocate_word(unsigned id, char *form, char *lemma, char *cpos
conll_sentence
*
conll_allocate_sentence
(
void
)
{
conll_sentence
*
s
;
int
i
;
unsigned
i
;
s
=
(
conll_sentence
*
)
malloc
(
sizeof
(
conll_sentence
));
if
(
s
==
NULL
){
...
...
@@ -123,7 +123,7 @@ conll_sentence *conll_allocate_sentence(void)
int
conll_load_sentence
(
FILE
*
f
,
conll_sentence
*
s
)
{
int
res
;
int
i
;
unsigned
i
;
if
(
feof
(
f
))
return
0
;
conll_reset_sentence
(
s
);
...
...
@@ -136,7 +136,7 @@ int conll_load_sentence(FILE *f, conll_sentence *s)
/* build the tree structure */
s
->
words
[
0
]
->
mother
=
NULL
;
for
(
i
=
1
;
i
<
s
->
l
;
++
i
){
if
((
s
->
words
[
i
]
->
head
>=
0
)
&&
(
s
->
words
[
i
]
->
head
<=
s
->
l
)){
/* check that head attribute is not out of range */
if
((
s
->
words
[
i
]
->
head
>=
0
)
&&
(
s
->
words
[
i
]
->
head
<=
(
int
)
s
->
l
)){
/* check that head attribute is not out of range */
conll_add_daughter
(
s
->
words
[
i
],
s
->
words
[
s
->
words
[
i
]
->
head
]);
}
}
...
...
@@ -236,7 +236,7 @@ int conll_parse_line(FILE *f, conll_sentence *s)
void
conll_print_sentence_mcf2
(
conll_sentence
*
s
,
int
print_id
,
int
print_form
,
int
print_lemma
,
int
print_cpostag
,
int
print_postag
,
int
print_feats
,
int
print_head
,
int
print_deprel
)
{
int
i
;
unsigned
i
;
conll_word
*
w
;
if
((
s
->
l
==
1
)
||
(
s
->
l
==
0
))
return
;
...
...
@@ -267,7 +267,8 @@ void conll_print_sentence_mcf2(conll_sentence *s, int print_id, int print_form,
void
conll_print_sentence_mcf3
(
conll_sentence
*
s
,
char
*
columns
,
int
nb_col
)
{
int
i
,
j
;
unsigned
i
;
int
j
;
conll_word
*
w
;
if
((
s
->
l
==
1
)
||
(
s
->
l
==
0
))
return
;
...
...
@@ -312,7 +313,7 @@ void conll_print_sentence_mcf3(conll_sentence *s, char *columns, int nb_col)
void
conll_print_sentence_mcf
(
conll_sentence
*
s
,
int
coarse_pos
)
{
int
i
;
unsigned
i
;
conll_word
*
w
;
if
((
s
->
l
==
1
)
||
(
s
->
l
==
0
))
return
;
...
...
@@ -342,7 +343,7 @@ void conll_print_sentence_mcf(conll_sentence *s, int coarse_pos)
void
conll_print_sentence
(
conll_sentence
*
s
)
{
int
i
;
unsigned
i
;
conll_word
*
w
;
if
((
s
->
l
==
1
)
||
(
s
->
l
==
0
))
return
;
...
...
@@ -369,7 +370,7 @@ void conll_print_sentence(conll_sentence *s)
void
conll_compact_sentence
(
conll_sentence
*
s
)
{
int
i
,
j
;
unsigned
i
,
j
;
for
(
i
=
0
;
i
<
s
->
l
;
i
++
){
if
(
s
->
words
[
i
]
==
NULL
){
for
(
j
=
i
;
j
<
s
->
l
-
1
;
j
++
){
...
...
@@ -397,7 +398,7 @@ void conll_add_daughter(conll_word *daughter, conll_word *mother)
void
conll_remove_daughter
(
conll_sentence
*
s
,
int
i
)
{
int
j
,
k
;
unsigned
j
,
k
;
conll_word
*
dep
=
s
->
words
[
i
];
conll_word
*
gov
;
if
(
dep
){
...
...
@@ -417,7 +418,7 @@ void conll_remove_daughter(conll_sentence *s, int i)
void
conll_remove_word_rec
(
conll_sentence
*
s
,
int
i
)
{
int
j
;
unsigned
j
;
conll_word
*
w
=
s
->
words
[
i
];
for
(
j
=
1
;
j
<
s
->
l
;
j
++
){
...
...
@@ -437,22 +438,22 @@ void conll_remove_subtree(conll_sentence *s, int root)
void
conll_add_word
(
conll_sentence
*
s
,
conll_word
*
w
,
int
index
,
conll_word
*
gov
)
{
int
i
;
unsigned
i
;
if
(
s
->
words
[
index
]
!=
NULL
){
for
(
i
=
s
->
l
;
i
>
index
;
i
--
){
for
(
i
=
s
->
l
;
i
>
(
unsigned
)
index
;
i
--
){
s
->
words
[
i
]
=
s
->
words
[
i
-
1
];
}
s
->
l
++
;
}
s
->
words
[
index
]
=
w
;
if
(
index
>=
s
->
l
)
s
->
l
=
index
+
1
;
if
(
(
unsigned
)
index
>=
s
->
l
)
s
->
l
=
(
unsigned
)
index
+
1
;
if
(
gov
!=
NULL
)
conll_add_daughter
(
w
,
gov
);
}
void
conll_split_node_in_two
(
conll_sentence
*
s
,
int
index
,
conll_word
*
gov
,
conll_word
*
dep
,
int
index_gov
,
int
index_dep
)
{
int
i
;
unsigned
i
;
conll_word
*
w
=
s
->
words
[
index
];
conll_word
*
mother
=
w
->
mother
;
...
...
@@ -473,7 +474,7 @@ void conll_split_node_in_two(conll_sentence *s, int index, conll_word *gov, conl
void
conll_change_cpos
(
conll_sentence
*
s
,
hash_str
*
h_cpos
)
{
int
i
;
unsigned
i
;
conll_word
*
w
;
char
*
val
;
...
...
@@ -495,7 +496,7 @@ void conll_change_cpos(conll_sentence *s, hash_str *h_cpos)
/*---------------------------------------------------------------------------------*/
void
conll_change_pos
(
conll_sentence
*
s
,
hash_str
*
h_pos
)
{
int
i
;
unsigned
i
;
conll_word
*
w
;
char
*
val
;
...
...
@@ -520,7 +521,7 @@ void conll_change_pos(conll_sentence *s, hash_str *h_pos)
void
conll_change_fct
(
conll_sentence
*
s
,
hash_str
*
h_fct
)
{
int
i
;
unsigned
i
;
conll_word
*
w
;
char
*
val
;
...
...
@@ -554,7 +555,7 @@ int conll_is_num(char *s)
void
conll_renumber_sentence_offset
(
conll_sentence
*
s
,
int
offset
)
{
int
i
;
unsigned
i
;
for
(
i
=
0
;
i
<
s
->
l
;
i
++
){
s
->
words
[
i
]
->
id
=
i
+
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