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
f1efa81a
Commit
f1efa81a
authored
8 years ago
by
Benoit Favre
Browse files
Options
Downloads
Patches
Plain Diff
make simple parser test more generic
parent
64eb310f
Branches
maca_graph_parser
Branches containing commit
No related tags found
1 merge request
!2
add first version of exernal-dependency-free graph parser
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
maca_graph_parser/simple_parser.cc
+1
-0
1 addition, 0 deletions
maca_graph_parser/simple_parser.cc
maca_graph_parser/test_simple_parser.cc
+32
-37
32 additions, 37 deletions
maca_graph_parser/test_simple_parser.cc
with
33 additions
and
37 deletions
maca_graph_parser/simple_parser.cc
+
1
−
0
View file @
f1efa81a
...
...
@@ -95,6 +95,7 @@ macaon::Parser::Parser(
int
argc
=
sizeof
(
argv
)
/
sizeof
(
char
*
);
ctx
=
maca_graph_parser_LoadCTX
(
argc
,
(
char
**
)
argv
);
ctx
->
verbose_flag
=
verbose_flag
;
int
i
;
int
sent_num
;
...
...
This diff is collapsed.
Click to expand it.
maca_graph_parser/test_simple_parser.cc
+
32
−
37
View file @
f1efa81a
#include
<iostream>
#include
<string>
#include
<vector>
#include
<sstream>
#include
"simple_parser.h"
using
namespace
macaon
;
int
main
(
int
argc
,
char
**
argv
)
{
// Parser mp("en", 3, "/home/alexis/test_maca_graph_parser/en/ptb.mod", "/home/alexis/test_maca_graph_parser/en/ptb.alpha", 1);
if
(
argc
<
4
)
{
std
::
cerr
<<
"usage: "
<<
argv
[
0
]
<<
" <model.bin> <model.alpha> <model.dep_count>
\n
"
;
std
::
cerr
<<
"usage: "
<<
argv
[
0
]
<<
" <cfg> <model.bin> <model.alpha> <model.dep_count>
\n
"
;
std
::
cerr
<<
"expects: one word, one lemma, one tag, per line, empty line between sentences
\n
"
;
return
1
;
}
Parser
mp
(
"en"
,
3
,
argv
[
1
],
argv
[
2
],
argv
[
3
],
1
);
Parser
mp
(
argv
[
1
]
,
0
,
argv
[
2
],
argv
[
3
],
argv
[
4
],
1
);
for
(
int
iteration
=
0
;
iteration
<
10
;
iteration
++
)
{
std
::
vector
<
std
::
string
>
words
;
std
::
vector
<
std
::
string
>
lemmas
;
std
::
vector
<
std
::
string
>
tags
;
words
.
push_back
(
"the"
);
words
.
push_back
(
"boy"
);
words
.
push_back
(
"hits"
);
words
.
push_back
(
"the"
);
words
.
push_back
(
"ball"
);
words
.
push_back
(
"."
);
lemmas
.
push_back
(
"the"
);
lemmas
.
push_back
(
"boy"
);
lemmas
.
push_back
(
"hit"
);
lemmas
.
push_back
(
"the"
);
lemmas
.
push_back
(
"ball"
);
lemmas
.
push_back
(
"."
);
tags
.
push_back
(
"DT"
);
tags
.
push_back
(
"NN"
);
tags
.
push_back
(
"VBZ"
);
tags
.
push_back
(
"DT"
);
tags
.
push_back
(
"NN"
);
tags
.
push_back
(
"."
);
std
::
string
line
;
while
(
std
::
getline
(
std
::
cin
,
line
))
{
std
::
cout
<<
"|"
<<
line
<<
"|
\n
"
;
if
(
line
==
""
)
{
std
::
vector
<
ParsedWord
>
output
;
mp
.
ProcessSentence
(
words
,
tags
,
lemmas
,
output
);
//mp.ProcessSentence(words, tags, output)
;
std
::
cout
<<
"size: "
<<
output
.
size
()
<<
"
\n
"
;
for
(
size_t
i
=
0
;
i
<
output
.
size
();
i
++
){
// std::cout << i << " " << output[i].word << " " << output[i].lemma << " " << output[i].posTag << " " << output[i].dependencyParent << " " << output[i].dependencyLabel << "\n";
std
::
cout
<<
i
<<
" "
<<
output
[
i
].
word
<<
" "
<<
output
[
i
].
posTag
<<
" "
<<
output
[
i
].
dependencyParent
<<
" "
<<
output
[
i
].
dependencyLabel
<<
"
\n
"
;
}
std
::
cout
<<
"
\n
"
;
words
.
clear
();
tags
.
clear
();
lemmas
.
clear
();
}
std
::
stringstream
reader
(
line
);
std
::
string
word
,
lemma
,
tag
;
reader
>>
word
>>
lemma
>>
tag
;
words
.
push_back
(
word
);
lemmas
.
push_back
(
lemma
);
tags
.
push_back
(
tag
);
}
}
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