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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexis Nasr
macaon2
Commits
fb1f6e3c
Commit
fb1f6e3c
authored
8 years ago
by
Marjorie Armando
Browse files
Options
Downloads
Patches
Plain Diff
generate train and test files, generate cff, predict test's forms' classes
parent
7a39a7b8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
maca_morpho/src/fplm_fct.c
+101
-0
101 additions, 0 deletions
maca_morpho/src/fplm_fct.c
with
101 additions
and
0 deletions
maca_morpho/src/fplm_fct.c
0 → 100644
+
101
−
0
View file @
fb1f6e3c
#include
<stdlib.h>
#include
<stdio.h>
#include
<string.h>
#include
"fplm.h"
/* Read a line from the fplm file and extract the form/pos/lemma/morpho.
* Return -1 if there's no more line to read, else the number of string read*/
int
read_line_fplm
(
FILE
*
fplm
,
char
*
form
,
char
*
pos
,
char
*
lemma
,
char
*
morpho
)
{
int
fields_nb
;
char
buffer
[
10000
];
if
(
fgets
(
buffer
,
10000
,
fplm
)
==
NULL
)
return
-
1
;
fields_nb
=
sscanf
(
buffer
,
"%[^
\t
]
\t
%s
\t
%[^
\t
]
\t
%s
\n
"
,
form
,
pos
,
lemma
,
morpho
);
return
fields_nb
;
}
/* Return the class' position in morpho
* (the class could be the tense, the person, the gender or the number of a word)*/
int
extract_class_position
(
CLASS
class
)
{
switch
(
class
)
{
case
TENSE
:
return
0
;
case
PERSON
:
return
1
;
case
GENDER
:
return
2
;
case
NUMBER
:
return
3
;
default:
fprintf
(
stderr
,
"Error morpho
\n
"
);
exit
(
EXIT_FAILURE
);
}
return
-
1
;
}
/* Return the class choosen by the user if their class exists*/
int
choose_class
(
char
*
class
)
{
if
(
!
strcmp
(
class
,
"tense"
))
return
TENSE
;
else
if
(
!
strcmp
(
class
,
"person"
))
return
PERSON
;
else
if
(
!
strcmp
(
class
,
"gender"
))
return
GENDER
;
else
if
(
!
strcmp
(
class
,
"number"
))
return
NUMBER
;
else
{
fprintf
(
stderr
,
"-c argument must be
\"
tense
\"
,
\"
person
\"
,
\"
gender
\"
or
\"
number
\"\n
"
);
exit
(
EXIT_FAILURE
);
}
return
-
1
;
}
void
extract_morpho_feature
(
CLASS
class
,
char
*
morpho_feature
,
char
*
morpho
)
{
int
cpt_diese
=
0
;
int
i
=
0
;
int
j
;
int
position
=
extract_class_position
(
class
);
if
(
class
==
TENSE
)
{
while
(
morpho
[
i
]
!=
'#'
)
{
morpho_feature
[
i
]
=
morpho
[
i
];
i
++
;
}
morpho_feature
[
i
]
=
'\0'
;
}
else
{
while
(
i
<
(
int
)
strlen
(
morpho
)
&&
cpt_diese
!=
position
)
{
if
(
morpho
[
i
]
==
'#'
)
cpt_diese
++
;
if
(
cpt_diese
==
position
)
{
i
++
;
for
(
j
=
0
;
morpho
[
i
]
!=
'#'
;
j
++
,
i
++
)
morpho_feature
[
j
]
=
morpho
[
i
];
}
i
++
;
}
morpho_feature
[
j
]
=
'\0'
;
}
}
int
associate_number_to_classes
(
char
*
classes_array
,
char
class
)
{
int
i
;
int
size
=
(
int
)
strlen
(
classes_array
);
for
(
i
=
1
;
i
<
size
;
i
++
)
if
(
classes_array
[
i
]
==
class
)
return
i
;
classes_array
[
size
]
=
class
;
classes_array
[
size
+
1
]
=
'\0'
;
return
size
;
}
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