Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Analysers
WCCL
Commits
15b4f0d6
Commit
15b4f0d6
authored
Dec 2, 2010
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
GetSymbols tests
parent
6377c41d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/getsymbols.cpp
+117
-0
117 additions, 0 deletions
tests/getsymbols.cpp
with
118 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
15b4f0d6
...
...
@@ -9,6 +9,7 @@ add_executable(tests
constant.cpp
context.cpp
getlemmas.cpp
getsymbols.cpp
getorth.cpp
logicalpredicates.cpp
main.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/getsymbols.cpp
0 → 100644
+
117
−
0
View file @
15b4f0d6
#include
<boost/test/unit_test.hpp>
#include
<boost/bind.hpp>
#include
<boost/shared_ptr.hpp>
#include
<libcorpus2/sentence.h>
#include
<libcorpus2/tagsetmanager.h>
#include
<libwccl/ops/functions/constant.h>
#include
<libwccl/ops/functions/tset/getsymbols.h>
using
namespace
Wccl
;
BOOST_AUTO_TEST_SUITE
(
get_symbols_op
)
struct
SymbolsFix
{
SymbolsFix
()
:
s
(
boost
::
make_shared
<
Corpus2
::
Sentence
>
()),
sc
(
s
),
tagset
(
Corpus2
::
get_named_tagset
(
"kipi"
)),
cx
(
sc
,
boost
::
make_shared
<
Variables
>
()),
pos_zero
(
0
),
nowhere
(
Position
::
Nowhere
),
pos_zero_constant
(
new
Constant
<
Position
>
(
pos_zero
)),
nowhere_constant
(
new
Constant
<
Position
>
(
nowhere
))
{
Corpus2
::
Token
*
the_token
=
new
Corpus2
::
Token
(
"One"
,
PwrNlp
::
Whitespace
::
ManySpaces
);
Corpus2
::
Lexeme
l1
(
"aaa"
,
tagset
.
parse_simple_tag
(
"subst:sg:nom:m1"
,
false
));
Corpus2
::
Lexeme
l2
(
"aaa"
,
tagset
.
parse_simple_tag
(
"subst:sg:nom:m2"
,
false
));
the_token
->
add_lexeme
(
l1
);
the_token
->
add_lexeme
(
l2
);
s
->
append
(
the_token
);
Corpus2
::
Token
*
another_token
=
new
Corpus2
::
Token
(
"Two"
,
PwrNlp
::
Whitespace
::
ManySpaces
);
Corpus2
::
Lexeme
l3
(
"aaa"
,
tagset
.
parse_simple_tag
(
"subst:pl:dat:f"
,
false
));
Corpus2
::
Lexeme
l4
(
"aaa"
,
tagset
.
parse_simple_tag
(
"prep:nom:wok"
,
false
));
Corpus2
::
Lexeme
l5
(
"aaa"
,
tagset
.
parse_simple_tag
(
"adja"
,
false
));
another_token
->
add_lexeme
(
l3
);
another_token
->
add_lexeme
(
l4
);
another_token
->
add_lexeme
(
l5
);
s
->
append
(
another_token
);
gnd
=
tagset
.
parse_symbol
(
"gnd"
);
nmb
=
tagset
.
parse_symbol
(
"nmb"
);
vcl
=
tagset
.
parse_symbol
(
"vcl"
);
pos
.
set_pos
(
Corpus2
::
make_full_mask
());
}
boost
::
shared_ptr
<
Corpus2
::
Sentence
>
s
;
SentenceContext
sc
;
const
Corpus2
::
Tagset
&
tagset
;
FunExecContext
cx
;
Position
pos_zero
;
Position
nowhere
;
boost
::
shared_ptr
<
Function
<
Position
>
>
pos_zero_constant
;
boost
::
shared_ptr
<
Function
<
Position
>
>
nowhere_constant
;
TSet
empty
;
Corpus2
::
Tag
gnd
;
Corpus2
::
Tag
nmb
;
Corpus2
::
Tag
vcl
;
Corpus2
::
Tag
pos
;
};
BOOST_FIXTURE_TEST_CASE
(
symbols_nowhere
,
SymbolsFix
)
{
GetSymbols
symbols
(
nowhere_constant
,
gnd
);
BOOST_CHECK
(
symbols
.
apply
(
cx
)
->
equals
(
empty
));
GetSymbols
s2
(
nowhere_constant
,
nmb
);
BOOST_CHECK
(
s2
.
apply
(
cx
)
->
equals
(
empty
));
GetSymbols
s3
(
nowhere_constant
,
pos
);
BOOST_CHECK
(
s3
.
apply
(
cx
)
->
equals
(
empty
));
}
BOOST_FIXTURE_TEST_CASE
(
get_gnd
,
SymbolsFix
)
{
GetSymbols
symbols
(
pos_zero_constant
,
gnd
);
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{m1,m2}"
);
sc
.
advance
();
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{f}"
);
sc
.
advance
();
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{}"
);
}
BOOST_FIXTURE_TEST_CASE
(
get_nmb
,
SymbolsFix
)
{
GetSymbols
symbols
(
pos_zero_constant
,
nmb
);
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{sg}"
);
sc
.
advance
();
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{pl}"
);
sc
.
advance
();
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{}"
);
}
BOOST_FIXTURE_TEST_CASE
(
get_vcl
,
SymbolsFix
)
{
GetSymbols
symbols
(
pos_zero_constant
,
vcl
);
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{}"
);
sc
.
advance
();
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{wok}"
);
sc
.
advance
();
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{}"
);
}
BOOST_FIXTURE_TEST_CASE
(
get_pos
,
SymbolsFix
)
{
GetSymbols
symbols
(
pos_zero_constant
,
pos
);
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{subst}"
);
sc
.
advance
();
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{adja,prep,subst}"
);
sc
.
advance
();
BOOST_CHECK_EQUAL
(
symbols
.
apply
(
cx
)
->
to_string
(
tagset
),
"{}"
);
}
BOOST_AUTO_TEST_SUITE_END
()
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