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

Match weak agreement op with the spec.

Previously it would mandate agreement was met on all categories
in a tag with enough categories, if such tag was found.
Now it checks for agreement only on the number of categories that
actually match, including the case of zero categories matching
(the latter does meet the weak agreement).
parent 730c1d35
No related merge requests found
...@@ -57,13 +57,16 @@ WeakAgreement::BaseRetValPtr WeakAgreement::apply_internal(const FunExecContext& ...@@ -57,13 +57,16 @@ WeakAgreement::BaseRetValPtr WeakAgreement::apply_internal(const FunExecContext&
if (t1->lexemes().size() > t2->lexemes().size()) { if (t1->lexemes().size() > t2->lexemes().size()) {
std::swap(t1, t2); std::swap(t1, t2);
} }
// check strong agreement between range endpoints // Check strong agreement between range endpoints.
// for each possible agreement between them, // For each possible agreement between the endpoints,
// check if remaining tokens meet that agreement too, // check if remaining tokens meet that agreement too,
// but take into account only tokens with a tag that // but instead of looking for strong agreement i.e.
// has enough categories, ignoring the rest (hence "weak" // matching on exact number of categories, look for
// agreement). // weak agreement i.e. matching only on those categories
// return True if an agreement met by all selected tokens is found // that are present.
// Specifically, if there is a lexeme that does not
// match any of the categories, that means the token
// does meet the weak agreement.
foreach (const Corpus2::Lexeme& t1_lex, t1->lexemes()) { foreach (const Corpus2::Lexeme& t1_lex, t1->lexemes()) {
const Corpus2::Tag& t1_tag = t1_lex.tag(); const Corpus2::Tag& t1_tag = t1_lex.tag();
// don't bother checking t2 unless current t1_tag matches enough categories // don't bother checking t2 unless current t1_tag matches enough categories
...@@ -72,21 +75,20 @@ WeakAgreement::BaseRetValPtr WeakAgreement::apply_internal(const FunExecContext& ...@@ -72,21 +75,20 @@ WeakAgreement::BaseRetValPtr WeakAgreement::apply_internal(const FunExecContext&
Corpus2::Tag inter = t1_tag.get_masked(t2_lex.tag()); Corpus2::Tag inter = t1_tag.get_masked(t2_lex.tag());
// if the intersection matches enough categories we have agreement // if the intersection matches enough categories we have agreement
if (attribs->matching_categories(inter) >= min_card) { if (attribs->matching_categories(inter) >= min_card) {
// check if selected agreement is met by all remaining tokens // Check if selected agreement is met by all remaining tokens
// but take into account only tokens with a tag that has
// proper amount of categories.
bool agreement_met = true; bool agreement_met = true;
for(int i = abs_left + 1; agreement_met && (i < abs_right); ++i) { for(int i = abs_left + 1; agreement_met && (i < abs_right); ++i) {
foreach(const Corpus2::Lexeme& i_lex, sc.at(i)->lexemes()) { foreach(const Corpus2::Lexeme& i_lex, sc.at(i)->lexemes()) {
if (attribs->matching_categories(i_lex.tag()) >= min_card) { // Check if agreement is met, but taking into account
// token has a tag matching enough categories, // only categories actually matched in current tag,
// so now it has to meet the selected agreement // without requirement to match all categories in the
agreement_met = false; // agreement.
Corpus2::Tag i_inter = i_lex.tag().get_masked(inter); Corpus2::Tag i_inter = i_lex.tag().get_masked(inter);
if (attribs->matching_categories(i_inter) >= min_card) { agreement_met =
agreement_met = true; (attribs->matching_categories(i_lex.tag())
break; == attribs->matching_categories(i_inter));
} if(agreement_met) {
break;
} }
} }
} }
......
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