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
36ddf619
Commit
36ddf619
authored
8 years ago
by
alexis.nasr
Browse files
Options
Downloads
Patches
Plain Diff
updated maca_trans_parser/src/context.h to accomodate for options specific to maca_trans_parser_nn
parent
9fca2984
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
CMakeLists.txt
+4
-0
4 additions, 0 deletions
CMakeLists.txt
maca_trans_parser/src/context.h
+8
-0
8 additions, 0 deletions
maca_trans_parser/src/context.h
maca_trans_parser/src/maca_trans_parser_nn.cc
+26
-32
26 additions, 32 deletions
maca_trans_parser/src/maca_trans_parser_nn.cc
with
38 additions
and
32 deletions
CMakeLists.txt
+
4
−
0
View file @
36ddf619
...
...
@@ -8,6 +8,10 @@ SET(CMAKE_C_COMPILER g++)
SET
(
CMAKE_CXX_COMPILER g++
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Ofast -DUSE_CBLAS"
)
SET
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
-lm -lopenblas"
)
if
(
${
CMAKE_C_COMPILER_VERSION
}
VERSION_LESS 5.3
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-std=gnu11"
)
# better, but needs CMake >= 3.0
...
...
This diff is collapsed.
Click to expand it.
maca_trans_parser/src/context.h
+
8
−
0
View file @
36ddf619
...
...
@@ -24,6 +24,14 @@
#define DEFAULT_VOCABS_TAGPARSER_FILENAME "maca_trans_tagparser.vocab"
#define DEFAULT_MODEL_TAGPARSER_FILENAME "maca_trans_tagparser.model"
#define DEFAULT_MULTI_COL_DESC_PARSER_NN_FILENAME "maca_trans_parser_nn.mcd"
#define DEFAULT_FEATURES_MODEL_PARSER_NN_FILENAME "maca_trans_parser_nn.fm"
#define DEFAULT_VOCABS_PARSER_NN_FILENAME "maca_trans_parser_nn.vocab"
#define DEFAULT_MODEL_PARSER_NN_FILENAME "maca_trans_parser_nn.weights"
#define DEFAULT_JSON_PARSER_NN_FILENAME "maca_trans_parser_nn.json"
#define DEFAULT_F2P_FILENAME "fP"
#define DEFAULT_FPLM_FILENAME "fplm"
...
...
This diff is collapsed.
Click to expand it.
maca_trans_parser/src/maca_trans_parser_nn.cc
+
26
−
32
View file @
36ddf619
...
...
@@ -44,41 +44,40 @@ void maca_trans_parser_nn_check_options(context *ctx){
}
}
void
set_linguistic_resources_filenames_parser
(
context
*
ctx
)
{
char
absolute_filename
[
500
];
if
(
!
ctx
->
perc
_model_filename
){
if
(
!
ctx
->
dnn
_model_filename
){
strcpy
(
absolute_filename
,
ctx
->
maca_data_path
);
strcat
(
absolute_filename
,
DEFAULT_MODEL_FILENAME
);
ctx
->
perc
_model_filename
=
strdup
(
absolute_filename
);
strcat
(
absolute_filename
,
DEFAULT_MODEL_
PARSER_NN_
FILENAME
);
ctx
->
dnn
_model_filename
=
strdup
(
absolute_filename
);
}
if
(
!
ctx
->
vocabs
_filename
){
if
(
!
ctx
->
json
_filename
){
strcpy
(
absolute_filename
,
ctx
->
maca_data_path
);
strcat
(
absolute_filename
,
DEFAULT_
VOCABS
_FILENAME
);
ctx
->
vocabs
_filename
=
strdup
(
absolute_filename
);
strcat
(
absolute_filename
,
DEFAULT_
JSON_PARSER_NN
_FILENAME
);
ctx
->
json
_filename
=
strdup
(
absolute_filename
);
}
/*
if(!ctx->
mcd
_filename){
if
(
!
ctx
->
vocabs
_filename
){
strcpy
(
absolute_filename
,
ctx
->
maca_data_path
);
strcat(absolute_filename, DEFAULT_
MULTI_COL_DESC
_FILENAME);
ctx->
mcd
_filename = strdup(absolute_filename);
}
*/
strcat
(
absolute_filename
,
DEFAULT_
VOCABS_PARSER_NN
_FILENAME
);
ctx
->
vocabs
_filename
=
strdup
(
absolute_filename
);
}
if
(
!
ctx
->
features_model_filename
){
strcpy
(
absolute_filename
,
ctx
->
maca_data_path
);
strcat
(
absolute_filename
,
DEFAULT_FEATURES_MODEL_FILENAME
);
strcat
(
absolute_filename
,
DEFAULT_FEATURES_MODEL_
PARSER_NN_
FILENAME
);
ctx
->
features_model_filename
=
strdup
(
absolute_filename
);
}
if
(
ctx
->
verbose
){
fprintf
(
stderr
,
"perc_model_filename = %s
\n
"
,
ctx
->
perc_model_filename
);
fprintf
(
stderr
,
"vocabs_filename = %s
\n
"
,
ctx
->
vocabs_filename
);
fprintf
(
stderr
,
"mcd_filename = %s
\n
"
,
ctx
->
mcd_filename
);
fprintf
(
stderr
,
"perc_features_model_filename = %s
\n
"
,
ctx
->
features_model_filename
);
fprintf
(
stderr
,
"dnn_model = %s
\n
"
,
ctx
->
dnn_model_filename
);
fprintf
(
stderr
,
"json = %s
\n
"
,
ctx
->
json_filename
);
fprintf
(
stderr
,
"vocabs %s
\n
"
,
ctx
->
vocabs_filename
);
fprintf
(
stderr
,
"mcd = %s
\n
"
,
ctx
->
mcd_filename
);
fprintf
(
stderr
,
"features_model = %s
\n
"
,
ctx
->
features_model_filename
);
}
}
...
...
@@ -184,16 +183,15 @@ std::vector<Matrix<float> > config2keras_vec(feat_model *fm, config *c)
void
simple_decoder_parser_arc_eager_nn
(
context
*
ctx
,
Model
&
model
)
{
FILE
*
f
=
(
ctx
->
input_filename
)
?
myfopen
(
ctx
->
input_filename
,
"r"
)
:
stdin
;
feature_table
*
ft
=
feature_table_load
(
ctx
->
perc_model_filename
,
ctx
->
verbose
);
//
feature_table *ft = feature_table_load(ctx->perc_model_filename, ctx->verbose);
int
root_label
;
int
mvt_code
;
int
mvt_type
;
int
mvt_label
;
feat_vec
*
fv
=
feat_vec_new
(
10
);
config
*
c
=
NULL
;
int
result
;
std
::
vector
<
Matrix
<
float
>
>
keras_vec
;
int
sentence_nb
=
0
;
root_label
=
dico_string2int
(
ctx
->
dico_labels
,
ctx
->
root_label
);
if
(
root_label
==
-
1
)
root_label
=
0
;
...
...
@@ -223,11 +221,7 @@ void simple_decoder_parser_arc_eager_nn(context *ctx, Model &model)
Matrix
<
float
>
argmax
=
y
[
0
].
argmax
();
mvt_code
=
argmax
.
at
(
0
,
0
);
// printf("mvt code = %d\n", mvt_code);
/* config2feat_vec_cff(ctx->features_model, c, ctx->d_perceptron_features, fv, LOOKUP_MODE); */
/* mvt_code = feature_table_argmax(fv, ft, &max); */
// fprintf(stderr,"mvt code = %d\n", mvt_code);
mvt_type
=
movement_parser_type
(
mvt_code
);
mvt_label
=
movement_parser_label
(
mvt_code
);
...
...
@@ -247,6 +241,9 @@ void simple_decoder_parser_arc_eager_nn(context *ctx, Model &model)
break
;
case
MVT_PARSER_EOS
:
result
=
movement_parser_eos
(
c
);
sentence_nb
++
;
if
((
sentence_nb
%
2
)
==
0
)
fprintf
(
stderr
,
"
\r
sentence %d"
,
sentence_nb
);
break
;
case
MVT_PARSER_SHIFT
:
result
=
movement_parser_shift
(
c
);
...
...
@@ -262,14 +259,12 @@ void simple_decoder_parser_arc_eager_nn(context *ctx, Model &model)
}
}
}
}
if
(
!
ctx
->
trace_mode
)
}
fprintf
(
stderr
,
"
\n
"
);
print_word_buffer
(
c
,
ctx
->
dico_labels
,
ctx
->
mcd_struct
);
config_free
(
c
);
feat_vec_free
(
fv
);
feature_table_free
(
ft
);
if
(
ctx
->
input_filename
)
fclose
(
f
);
}
...
...
@@ -297,10 +292,9 @@ int main(int argc, char *argv[])
fprintf
(
stderr
,
"cannot find label names
\n
"
);
return
1
;
}
simple_decoder_parser_arc_eager_nn
(
ctx
,
model
);
context_free
(
ctx
);
//
context_free(ctx);
return
0
;
}
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