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

wagr, weak agreement over range of tokens.

parent e32ccea8
No related merge requests found
......@@ -47,14 +47,43 @@ WeakAgreement::BaseRetValPtr WeakAgreement::apply_internal(const FunExecContext&
return Predicate::False(context);
}
const boost::shared_ptr<const TSet>& attribs_tset = attribs_expr_->apply(context);
const Corpus2::Tag& attribs = attribs_tset->get_value();
const boost::shared_ptr<const TSet>& attribs = attribs_expr_->apply(context);
//
// @todo: implement
//
int min_card = attribs->categories_count(tagset_);
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;
bool j_has_matched_tag = false;
foreach(const Corpus2::Lexeme& j_lex, sc.at(j)->lexemes()) {
const Corpus2::Tag& j_tag = j_lex.tag();
if (attribs->matching_categories(i_tag) >= min_card) {
j_has_matched_tag = true;
Corpus2::Tag intersection = i_tag.get_masked(j_tag);
// if the intersection matches enough categories we have agreement
if (attribs->matching_categories(intersection) >= min_card) {
i_agrees_with_j = true;
break;
}
}
}
if (j_has_matched_tag && !i_agrees_with_j) {
return Predicate::False(context);
}
}
}
}
if (!i_has_matched_tag && (i == abs_left || i == abs_right)) {
return Predicate::False(context);
}
}
return Predicate::True(context);
}
} /* 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