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

Select Action, leaving lexemes that meet a condition.

parent 86508c9d
Branches
No related merge requests found
......@@ -7,7 +7,23 @@ namespace Wccl {
Bool Select::execute(const ActionExecContext& context) const
{
Bool changed(false);
//@todo: implement
const boost::shared_ptr<const Position> pos = pos_->apply(context);
int abs_pos = context.sentence_context().get_abs_position(*pos);
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;
foreach (const Corpus2::Lexeme& lexeme, original) {
token.add_lexeme(lexeme);
if (condition_->apply(context)->get_value()) {
remaining.push_back(lexeme);
}
token.lexemes().pop_back();
}
changed.set_value((remaining.size() > 0) && (remaining.size() < original.size()));
token.lexemes() = changed.get_value() ? remaining : original;
}
return changed;
}
......
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