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

agr operator, strong agreement on range of tokens.

parent bdda2bbd
Branches
No related merge requests found
#include <libwccl/ops/functions/bool/predicates/strongagreement.h> #include <libwccl/ops/functions/bool/predicates/strongagreement.h>
#include <libpwrutils/foreach.h>
namespace Wccl { namespace Wccl {
...@@ -47,14 +48,38 @@ StrongAgreement::BaseRetValPtr StrongAgreement::apply_internal(const FunExecCont ...@@ -47,14 +48,38 @@ StrongAgreement::BaseRetValPtr StrongAgreement::apply_internal(const FunExecCont
return Predicate::False(context); return Predicate::False(context);
} }
const boost::shared_ptr<const TSet>& attribs_tset = attribs_expr_->apply(context); const boost::shared_ptr<const TSet>& attribs = attribs_expr_->apply(context);
const Corpus2::Tag& attribs = attribs_tset->get_value();
// int min_card = attribs->categories_count(tagset_);
// @todo: implement
//
return Predicate::False(context); for(int i = abs_left; i <= abs_right; ++i) {
bool i_has_matched_tag = false;
foreach (const Corpus2::Lexeme& i_lex, sc.at(i)->lexemes()) {
const Corpus2::Tag& i_tag = i_lex.tag();
if (attribs->matching_categories(i_tag) >= min_card) {
i_has_matched_tag = true;
for(int j = abs_right; j > i; --j) {
bool i_agrees_with_j = false;
foreach(const Corpus2::Lexeme& j_lex, sc.at(j)->lexemes()) {
Corpus2::Tag intersection = i_tag.get_masked(j_lex.tag());
// if the intersection matches enough categories we have agreement
if (attribs->matching_categories(intersection) >= min_card) {
i_agrees_with_j = true;
break;
}
}
if (!i_agrees_with_j) {
return Predicate::False(context);
}
}
}
}
if (!i_has_matched_tag) {
return Predicate::False(context);
}
}
return Predicate::True(context);
} }
} /* end ns Wccl */ } /* end ns Wccl */
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