Skip to content
Snippets Groups Projects
Commit f88f97eb authored by Adam Wardynski's avatar Adam Wardynski
Browse files

MatchOperator to act more like a function (FunExecContext).

parent f886a617
Branches
No related merge requests found
......@@ -4,11 +4,9 @@
namespace Wccl {
const char* MatchOperator::IterationPosVarName = "$_";
boost::shared_ptr<MatchVector> MatchOperator::execute(
boost::shared_ptr<Match> MatchOperator::apply(
boost::shared_ptr<Position> iter_pos,
const ActionExecContext &context) const
const FunExecContext& context) const
{
boost::shared_ptr<MatchVector> matches(new MatchVector());
int orig_iter_pos = iter_pos->get_value();
......
......@@ -12,8 +12,6 @@ namespace Wccl {
class MatchOperator : public Expression
{
public:
static const char* IterationPosVarName;
MatchOperator(const std::vector< boost::shared_ptr<const MatchCondition> >& conditions)
: _conditions(conditions) {
}
......@@ -30,6 +28,20 @@ public:
*/
std::string to_string(const Corpus2::Tagset& tagset) const;
/**
* Applies the operator to the given context.
* @returns Vector of matches corresponding to match conditions,
* if all conditions were met. In such case position $_ points one position
* ahead of matched tokens.
* Empty MatchVector is returned if any of the conditions was not met.
* In such case Position $_ is advanced by 1.
* @param iter_pos Pointer to the variable $_ from context's Variables
* @param context Execution context - current sentence and Variables to operate on
*/
boost::shared_ptr<Match> apply(
boost::shared_ptr<Position> iter_pos,
const FunExecContext& context) const;
protected:
/**
* Writes string representation of the operator to
......@@ -39,19 +51,6 @@ protected:
*/
std::ostream& write_to(std::ostream& ostream) const;
/**
* Executes the operator on given context.
* @returns Vector of matches corresponding to match conditions,
* if all conditions were met. In such case position $_ is advanced past matched tokens.
* Empty MatchVector is returned if any of conditions was not met.
* In such case Position $_ is advanced by 1.
* @param iter_pos Pointer to the variable $_ from context's Variables
* @param context Execution context - current sentence and Variables to operate on
*/
boost::shared_ptr<MatchVector> execute(
boost::shared_ptr<Position> iter_pos,
const ActionExecContext &context) const;
private:
const std::vector<boost::shared_ptr<const MatchCondition> > _conditions;
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment