Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
f948adee
Commit
f948adee
authored
13 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
simple tests for ann and annsub
parent
76791cf4
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/CMakeLists.txt
+3
-1
3 additions, 1 deletion
tests/CMakeLists.txt
tests/ann_op.cpp
+126
-0
126 additions, 0 deletions
tests/ann_op.cpp
tests/positionpredicates.cpp
+1
-1
1 addition, 1 deletion
tests/positionpredicates.cpp
with
130 additions
and
2 deletions
tests/CMakeLists.txt
+
3
−
1
View file @
f948adee
...
...
@@ -19,7 +19,10 @@ include_directories( ${CMAKE_SOURCE_DIR} )
add_definitions
(
-DLIBWCCL_TEST_DATA_DIR=
"
${
PROJECT_SOURCE_DIR
}
/"
)
add_executable
(
tests
main.cpp
optest.cpp
ann_op.cpp
conditional.cpp
constant.cpp
context.cpp
...
...
@@ -31,7 +34,6 @@ add_executable(tests
getorth.cpp
isempty.cpp
logicalpredicates.cpp
main.cpp
mark.cpp
match.cpp
position.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/ann_op.cpp
0 → 100644
+
126
−
0
View file @
f948adee
#include
<boost/test/unit_test.hpp>
#include
<boost/bind.hpp>
#include
<libcorpus2/ann/annotatedsentence.h>
#include
<libwccl/ops/functions/constant.h>
#include
<libwccl/ops/functions/bool/predicates/ann.h>
#include
<libwccl/ops/functions/bool/predicates/annsub.h>
#include
<libwccl/values/match.h>
#include
<libwccl/values/tokenmatch.h>
#include
"optest.h"
using
namespace
Wccl
;
BOOST_AUTO_TEST_SUITE
(
ann_ann_sub
)
struct
AnnSubFix
:
public
Wccl
::
PositionFixture
{
AnnSubFix
()
:
Wccl
::
PositionFixture
(
3
),
as
(
boost
::
make_shared
<
Corpus2
::
AnnotatedSentence
>
()),
sc
(
as
),
cx
(
sc
,
boost
::
make_shared
<
Variables
>
())
{
as
->
append
(
new
Corpus2
::
Token
(
UnicodeString
::
fromUTF8
(
"t1"
),
PwrNlp
::
Whitespace
::
Newline
));
as
->
append
(
new
Corpus2
::
Token
(
UnicodeString
::
fromUTF8
(
"t2"
),
PwrNlp
::
Whitespace
::
Newline
));
as
->
append
(
new
Corpus2
::
Token
(
UnicodeString
::
fromUTF8
(
"t3"
),
PwrNlp
::
Whitespace
::
Newline
));
as
->
append
(
new
Corpus2
::
Token
(
UnicodeString
::
fromUTF8
(
"t4"
),
PwrNlp
::
Whitespace
::
Newline
));
as
->
append
(
new
Corpus2
::
Token
(
UnicodeString
::
fromUTF8
(
"t5"
),
PwrNlp
::
Whitespace
::
Newline
));
as
->
create_channel
(
"ch1"
);
as
->
get_channel
(
"ch1"
).
set_segment_at
(
2
,
1
);
as
->
get_channel
(
"ch1"
).
set_segment_at
(
3
,
1
);
as
->
get_channel
(
"ch1"
).
set_head_at
(
3
,
true
);
}
boost
::
shared_ptr
<
Corpus2
::
AnnotatedSentence
>
as
;
SentenceContext
sc
;
Corpus2
::
Tagset
tagset
;
FunExecContext
cx
;
};
BOOST_FIXTURE_TEST_CASE
(
ann_not
,
AnnSubFix
)
{
boost
::
shared_ptr
<
Constant
<
Match
>
>
m0
,
m1
;
m0
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
0
)))));
m1
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
1
)))));
Ann
a
(
m0
,
m1
,
"ch1"
);
boost
::
shared_ptr
<
const
Bool
>
rv
=
a
.
apply
(
cx
);
BOOST_REQUIRE
(
rv
);
BOOST_CHECK
(
!*
rv
);
AnnSub
as
(
m0
,
m1
,
"ch1"
);
rv
=
a
.
apply
(
cx
);
BOOST_REQUIRE
(
rv
);
BOOST_CHECK
(
!*
rv
);
}
BOOST_FIXTURE_TEST_CASE
(
ann_yes
,
AnnSubFix
)
{
boost
::
shared_ptr
<
Constant
<
Match
>
>
m0
,
m1
;
m0
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
2
)))));
m1
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
3
)))));
Ann
a
(
m0
,
m1
,
"ch1"
);
boost
::
shared_ptr
<
const
Bool
>
rv
=
a
.
apply
(
cx
);
BOOST_REQUIRE
(
rv
);
BOOST_CHECK
(
*
rv
);
AnnSub
as
(
m0
,
m1
,
"ch1"
);
rv
=
as
.
apply
(
cx
);
BOOST_REQUIRE
(
rv
);
BOOST_CHECK
(
*
rv
);
}
BOOST_FIXTURE_TEST_CASE
(
ann_sub
,
AnnSubFix
)
{
boost
::
shared_ptr
<
Constant
<
Match
>
>
m0
,
m1
;
m0
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
2
)))));
m1
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
2
)))));
Ann
a
(
m0
,
m1
,
"ch1"
);
boost
::
shared_ptr
<
const
Bool
>
rv
=
a
.
apply
(
cx
);
BOOST_REQUIRE
(
rv
);
BOOST_CHECK
(
!*
rv
);
AnnSub
as
(
m0
,
m1
,
"ch1"
);
rv
=
as
.
apply
(
cx
);
BOOST_REQUIRE
(
rv
);
BOOST_CHECK
(
*
rv
);
}
//------ to_string test cases -------
BOOST_FIXTURE_TEST_CASE
(
ann_to_string
,
AnnSubFix
)
{
boost
::
shared_ptr
<
Constant
<
Match
>
>
m0
,
m1
;
m0
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
0
)))));
m1
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
1
)))));
Ann
ann
(
m0
,
m1
,
"ch"
);
BOOST_CHECK_EQUAL
(
"ann(TOK[0], TOK[1],
\"
ch
\"
)"
,
ann
.
to_string
(
tagset
));
}
BOOST_FIXTURE_TEST_CASE
(
ann_to_string_one
,
AnnSubFix
)
{
boost
::
shared_ptr
<
Constant
<
Match
>
>
m0
,
m1
;
m0
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
0
)))));
m1
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
1
)))));
Ann
ann
(
m0
,
"ch"
);
BOOST_CHECK_EQUAL
(
"ann(TOK[0],
\"
ch
\"
)"
,
ann
.
to_string
(
tagset
));
}
BOOST_FIXTURE_TEST_CASE
(
annsub_to_string
,
AnnSubFix
)
{
boost
::
shared_ptr
<
Constant
<
Match
>
>
m0
,
m1
;
m0
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
0
)))));
m1
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
1
)))));
AnnSub
ann
(
m0
,
m1
,
"ch"
);
BOOST_CHECK_EQUAL
(
"annsub(TOK[0], TOK[1],
\"
ch
\"
)"
,
ann
.
to_string
(
tagset
));
}
BOOST_FIXTURE_TEST_CASE
(
annsub_to_string_one
,
AnnSubFix
)
{
boost
::
shared_ptr
<
Constant
<
Match
>
>
m0
,
m1
;
m0
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
0
)))));
m1
.
reset
(
new
Constant
<
Match
>
(
Match
(
TokenMatch
(
pos_value
(
1
)))));
AnnSub
ann
(
m0
,
"ch"
);
BOOST_CHECK_EQUAL
(
"annsub(TOK[0],
\"
ch
\"
)"
,
ann
.
to_string
(
tagset
));
}
BOOST_AUTO_TEST_SUITE_END
()
This diff is collapsed.
Click to expand it.
tests/positionpredicates.cpp
+
1
−
1
View file @
f948adee
...
...
@@ -13,7 +13,7 @@ using namespace Wccl;
BOOST_AUTO_TEST_SUITE
(
position_predicates
)
struct
PosPredFix
:
public
Wccl
::
PositionFixture
struct
PosPredFix
:
public
Wccl
::
PositionFixture
{
PosPredFix
()
:
Wccl
::
PositionFixture
(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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