Skip to content
Snippets Groups Projects
Commit 7838cf57 authored by Adam Radziszewski's avatar Adam Radziszewski
Browse files

fix match token-level condition: immediately terminate and return empty match...

fix match token-level condition: immediately terminate and return empty match result when curr pos is outside sent
parent ebe8110a
No related merge requests found
......@@ -40,16 +40,18 @@ std::string TokenCondition::to_string(const Corpus2::Tagset& tagset) const
MatchResult TokenCondition::apply(const ActionExecContext& context) const
{
int orig_iter = context.sentence_context().get_position();
if (_predicate->apply(context)->get_value()) {
boost::shared_ptr<TokenMatch> match(new TokenMatch(context.sentence_context().get_position()));
// increase current sentence position by one after successful token match
context.sentence_context().set_position(orig_iter + 1);
return MatchResult(match);
}
else {
context.sentence_context().set_position(orig_iter);
return MatchResult();
if (context.sentence_context().is_current_inside()) {
if (_predicate->apply(context)->get_value()) {
boost::shared_ptr<TokenMatch> match(new TokenMatch(context.sentence_context().get_position()));
// increase current sentence position by one after successful token match
context.sentence_context().set_position(orig_iter + 1);
return MatchResult(match);
}
}
// else
context.sentence_context().set_position(orig_iter);
return MatchResult();
}
std::ostream& TokenCondition::write_to(std::ostream& os) const
......
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