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

Small tweaks to Delete and Select code.

parent 922a6fb2
No related merge requests found
#include <libwccl/ops/actions/delete.h>
#include <libwccl/ops/functions/constant.h>
#include <libpwrutils/foreach.h>
#include <sstream>
......@@ -8,13 +7,12 @@ namespace Wccl {
Bool Delete::execute(const ActionExecContext& context) const
{
Bool changed(false);
const boost::shared_ptr<const Position> pos = pos_->apply(context);
int abs_pos = context.sentence_context().get_abs_position(*pos);
int abs_pos = context.sentence_context().get_abs_position(*pos_->apply(context));
if (context.sentence_context().is_inside(abs_pos)) {
Corpus2::Token& token = *context.sentence_context().at(abs_pos);
std::vector<Corpus2::Lexeme> original(token.lexemes());
std::vector<Corpus2::Lexeme> remaining;
token.lexemes() = remaining;
token.lexemes().clear();
foreach (const Corpus2::Lexeme& lexeme, original) {
token.add_lexeme(lexeme);
if (!condition_->apply(context)->get_value()) {
......
#include <libwccl/ops/actions/select.h>
#include <libwccl/ops/functions/constant.h>
#include <libpwrutils/foreach.h>
#include <sstream>
namespace Wccl {
......@@ -7,13 +7,12 @@ namespace Wccl {
Bool Select::execute(const ActionExecContext& context) const
{
Bool changed(false);
const boost::shared_ptr<const Position> pos = pos_->apply(context);
int abs_pos = context.sentence_context().get_abs_position(*pos);
int abs_pos = context.sentence_context().get_abs_position(*pos_->apply(context));
if (context.sentence_context().is_inside(abs_pos)) {
Corpus2::Token& token = *context.sentence_context().at(abs_pos);
std::vector<Corpus2::Lexeme> original(token.lexemes());
std::vector<Corpus2::Lexeme> remaining;
token.lexemes() = remaining;
token.lexemes().clear();
foreach (const Corpus2::Lexeme& lexeme, original) {
token.add_lexeme(lexeme);
if (condition_->apply(context)->get_value()) {
......
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