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
452a26ce
Commit
452a26ce
authored
14 years ago
by
Adam Wardyński
Browse files
Options
Downloads
Patches
Plain Diff
Predicate checking if two values are equal
parent
9fde90ed
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libwccl/ops/equals.h
+62
-0
62 additions, 0 deletions
libwccl/ops/equals.h
with
62 additions
and
0 deletions
libwccl/ops/equals.h
0 → 100644
+
62
−
0
View file @
452a26ce
#ifndef EQUALS_H
#define EQUALS_H
#include
<boost/shared_ptr.hpp>
#include
<boost/mpl/list.hpp>
#include
<boost/mpl/assert.hpp>
#include
<boost/mpl/count.hpp>
#include
<libwccl/ops/predicate.h>
#include
<libwccl/ops/formatters.h>
namespace
Wccl
{
/**
* Predicate that checks for equality of values
*/
template
<
class
T
>
class
Equals
:
public
Predicate
{
public:
typedef
boost
::
shared_ptr
<
Function
<
T
>
>
ArgFunctionPtr
;
Equals
(
const
ArgFunctionPtr
&
arg1_expr
,
const
ArgFunctionPtr
&
arg2_expr
)
:
arg1_expr_
(
arg1_expr
),
arg2_expr_
(
arg2_expr
)
{
BOOST_ASSERT
(
arg1_expr_
);
BOOST_ASSERT
(
arg2_expr_
);
}
virtual
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
tagset
)
const
{
return
BinaryFunctionFormatter
::
to_string
(
tagset
,
*
this
,
*
arg1_expr_
,
*
arg2_expr_
);
}
virtual
std
::
string
to_raw_string
()
const
{
return
BinaryFunctionFormatter
::
to_raw_string
(
*
this
,
*
arg1_expr_
,
*
arg2_expr_
);
}
virtual
const
std
::
string
raw_operator_name
()
const
{
return
"equals"
;
}
protected
:
const
ArgFunctionPtr
arg1_expr_
;
const
ArgFunctionPtr
arg2_expr_
;
typedef
FunctionBase
::
BaseRetValPtr
BaseRetValPtr
;
/**
* Take values of arguments from expressions and return True if they are equal,
* False otherwise.
*/
virtual
BaseRetValPtr
apply_internal
(
const
SentenceContext
&
context
)
const
{
boost
::
shared_ptr
<
T
>
arg1
=
this
->
arg1_expr_
->
apply
(
context
);
boost
::
shared_ptr
<
T
>
arg2
=
this
->
arg2_expr_
->
apply
(
context
);
if
(
arg1
->
equals
(
*
arg2
))
{
return
Predicate
::
True
->
apply
(
context
);
}
return
Predicate
::
False
->
apply
(
context
);
}
};
}
/* end ns Wccl */
#endif // EQUALS_H
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