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
dbd7270d
Commit
dbd7270d
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
c4f8f22f
Branches
Branches containing commit
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/predict_fct.c
+89
-0
89 additions, 0 deletions
maca_morpho/src/predict_fct.c
with
89 additions
and
0 deletions
maca_morpho/src/predict_fct.c
0 → 100644
+
89
−
0
View file @
dbd7270d
#include
<stdlib.h>
#include
<stdio.h>
#include
"predict.h"
void
predict_help_message
(
context
*
ctx
)
{
context_general_help_message
(
ctx
);
context_language_help_message
(
ctx
);
context_fplm_help_message
(
ctx
);
context_maca_data_path_help_message
(
ctx
);
context_features_filename_help_message
(
ctx
);
context_weights_matrix_filename_help_message
(
ctx
);
context_features_model_help_message
(
ctx
);
exit
(
1
);
}
void
create_predictions_file
(
context
*
ctx
)
{
FILE
*
fplm_test
=
NULL
;
FILE
*
predictions
=
NULL
;
feature_table
*
cfw
=
NULL
;
feat_vec
*
fv
=
NULL
;
dico
*
dico_features
=
NULL
;
feat_model
*
fm
=
NULL
;
int
fields_nb
;
char
form
[
100
];
char
pos
[
50
];
char
lemma
[
100
];
char
morpho
[
50
];
fplm_test
=
fopen
(
ctx
->
fplm_filename
,
"r"
);
if
(
fplm_test
==
NULL
)
{
fprintf
(
stderr
,
"Could not open input file.
\n
You can generate a fplm_test file with fplm2train_test
\n
The fplm_test file will be in the Files directory.
\n
"
);
exit
(
EXIT_FAILURE
);
}
cfw
=
feature_table_load
(
ctx
->
cfw_filename
,
ctx
->
verbose
);
fv
=
feat_vec_new
(
10
);
dico_features
=
dico_read
(
ctx
->
features_filename
,
0
.
5
);
fm
=
feat_model_read
(
ctx
->
fm_filename
,
feat_lib_build
(),
ctx
->
verbose
);
predictions
=
fopen
(
"../../Files/prediction.txt"
,
"w"
);
if
(
predictions
==
NULL
)
{
fprintf
(
stderr
,
"Problem with the prediction file.
\n
"
);
exit
(
EXIT_FAILURE
);
}
while
((
fields_nb
=
read_line_fplm
(
fplm_test
,
form
,
pos
,
lemma
,
morpho
))
!=
-
1
)
{
if
(
fields_nb
!=
4
)
{
if
(
1
)
{
fprintf
(
stderr
,
"form = %s pos = %s lemma = %s morpho = %s
\n
"
,
form
,
pos
,
lemma
,
morpho
);
fprintf
(
stderr
,
"incorrect fplm entry, skipping it
\n
"
);
}
continue
;
}
make_prediction
(
predictions
,
form
,
morpho
,
cfw
,
fv
,
dico_features
,
fm
);
}
if
(
ctx
->
features_filename
)
dico_print
(
ctx
->
features_filename
,
dico_features
);
fclose
(
fplm_test
);
fclose
(
predictions
);
}
void
make_prediction
(
FILE
*
predictions
,
char
*
form
,
char
*
morpho
,
feature_table
*
cfw
,
feat_vec
*
fv
,
dico
*
dico_features
,
feat_model
*
fm
)
{
int
class
;
float
max
;
fprintf
(
predictions
,
"form = %s
\n
"
,
form
);
form2fv
(
form
,
fv
,
fm
,
dico_features
,
LOOKUP_MODE
);
class
=
feature_table_argmax
(
fv
,
cfw
,
&
max
);
feat_vec_print
(
predictions
,
fv
);
fprintf
(
predictions
,
"class predicted = %d
\n
"
,
class
);
}
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