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
67862276
Commit
67862276
authored
8 years ago
by
Benoit Favre
Browse files
Options
Downloads
Patches
Plain Diff
add compatibility with macaon configuration commandline options
parent
821ec273
No related branches found
No related tags found
1 merge request
!8
add compatibility with macaon configuration commandline options
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
maca_crf_tagger/src/crf_barebones_decoder.cc
+26
-2
26 additions, 2 deletions
maca_crf_tagger/src/crf_barebones_decoder.cc
with
26 additions
and
2 deletions
maca_crf_tagger/src/crf_barebones_decoder.cc
+
26
−
2
View file @
67862276
#include
<cstdlib>
#include
<vector>
#include
"crf_decoder.hh"
#include
"crf_binlexicon.hh"
...
...
@@ -42,15 +43,20 @@ void tag_sentence(macaon::Decoder& decoder, macaon::BinaryLexicon* lexicon, cons
}
void
usage
(
const
char
*
argv0
)
{
std
::
cerr
<<
"usage: "
<<
argv0
<<
" [--conll07|--column <num>] <model> [lexicon]
\n
"
;
std
::
cerr
<<
"usage: "
<<
argv0
<<
" [--conll07|--column <num>]
[
<model> [lexicon]
|-L <lang> [-D <model-dir>] [--nolexicon]]
\n
"
;
exit
(
1
);
}
int
main
(
int
argc
,
char
**
argv
)
{
bool
isConll07
=
false
;
// warning: no verification of conll07 format
int
word_offset
=
0
;
std
::
string
modelDir
=
""
;
std
::
string
modelLang
=
""
;
char
*
macaon_dir
=
getenv
(
"MACAON_DIR"
);
if
(
macaon_dir
!=
NULL
)
modelDir
=
macaon_dir
;
std
::
string
modelName
=
""
;
std
::
string
lexiconName
=
""
;
bool
noLexicon
=
false
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
std
::
string
arg
=
argv
[
i
];
...
...
@@ -63,6 +69,16 @@ int main(int argc, char** argv) {
arg
=
argv
[
i
+
1
];
word_offset
=
strtol
(
arg
.
c_str
(),
NULL
,
10
)
-
1
;
i
++
;
}
else
if
(
arg
==
"-L"
)
{
arg
=
argv
[
i
+
1
];
modelLang
=
arg
;
i
++
;
}
else
if
(
arg
==
"-D"
)
{
arg
=
argv
[
i
+
1
];
modelDir
=
arg
;
i
++
;
}
else
if
(
arg
==
"--nolexicon"
)
{
noLexicon
=
true
;
}
else
if
(
modelName
==
""
)
{
modelName
=
arg
;
}
else
if
(
lexiconName
==
""
)
{
...
...
@@ -71,11 +87,19 @@ int main(int argc, char** argv) {
usage
(
argv
[
0
]);
}
}
if
(
modelDir
!=
""
&&
modelLang
!=
""
)
{
modelName
=
modelDir
+
"/"
+
modelLang
+
"/bin/crf_tagger_model.bin"
;
if
(
!
noLexicon
)
lexiconName
=
modelDir
+
"/"
+
modelLang
+
"/bin/crf_tagger_wordtag_lexicon.bin"
;
}
if
(
modelName
==
""
||
word_offset
<
0
)
usage
(
argv
[
0
]);
macaon
::
Decoder
decoder
(
modelName
);
if
(
!
decoder
.
IsLoaded
())
return
1
;
macaon
::
BinaryLexicon
*
lexicon
=
NULL
;
if
(
lexiconName
!=
""
)
lexicon
=
new
macaon
::
BinaryLexicon
(
lexiconName
,
decoder
.
getTagset
());
if
(
lexiconName
!=
""
)
{
lexicon
=
new
macaon
::
BinaryLexicon
(
lexiconName
,
decoder
.
getTagset
());
if
(
!
lexicon
->
IsLoaded
())
return
1
;
}
std
::
string
line
;
std
::
vector
<
std
::
vector
<
std
::
string
>
>
lines
;
...
...
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