From e74435f90710112def9c9bc7616acccdcb1fceb7 Mon Sep 17 00:00:00 2001
From: Adam Wardynski <award@.(win7-laptop)>
Date: Tue, 15 Feb 2011 19:57:44 +0100
Subject: [PATCH] Fix bug#1264 - leave only underspecified lexemes if agreement
 exists only via them. Underlying issue was temporary table of remaining
 lexemes for a token not being updated (emptied) if only underspecified
 lexemes of the token met an agreement. Effectively the token was left in its
 original state i.e. with all original lexemes present, both those that were
 underspecified and the remaining ones that did not met a weak agreement that
 was otherwise met via the underspecified lexemes.

---
 libwccl/ops/actions/unify.cpp | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/libwccl/ops/actions/unify.cpp b/libwccl/ops/actions/unify.cpp
index 692aa5d..0733efd 100644
--- a/libwccl/ops/actions/unify.cpp
+++ b/libwccl/ops/actions/unify.cpp
@@ -70,37 +70,27 @@ Bool Unify::execute(const ActionExecContext& context) const
 					// there is no agreement possible, abort with no changes
 					changed.set_value(false);
 					return changed;
-				} else {
-					// there were underspecified lexemes, they will be left in the end
-					// so agreement is met anyway, however we need to mark that
-					// changes were made because we removed some lexemes that did not
-					// meet agreement;
-					// "previous" index has to be left alone though, pointing at previous
-					// token that still had some agreedable lexemes
-					changed.set_value(true);
 				}
 			} else {
 				// some non-underspecified lexemes are left, so
 				// next time around, "previous" token is going to be the current one
 				previous = i;
-				// there were changes only if we actually removed something
-				if (curr_rem.size() != remainings[i].size()) {
-					changed.set_value(true);
-					remainings[i] = curr_rem;
-				}
+			}
+			// there were changes only if we actually removed something
+			if (curr_rem.size() != remainings[i].size()) {
+				changed.set_value(true);
+				remainings[i] = curr_rem;
 			}
 		}
 	}
 	// finally assign remaining lexemes to original tokens
 	if (changed.get_value()) {
 		for (size_t i = 0; i < remainings.size(); ++i) {
-			if (remainings[i].size() > 0) {
-				std::vector<Corpus2::Lexeme>& lexemes = sc.at(i + abs_left)->lexemes();
-				lexemes = remainings[i];
-				// underspecced lexemes meet agreement too, so leave them in the end, if any
-				foreach (const Corpus2::Lexeme& lex, underspecifieds[i]) {
-					lexemes.push_back(lex);
-				}
+			std::vector<Corpus2::Lexeme>& lexemes = sc.at(i + abs_left)->lexemes();
+			lexemes = remainings[i];
+			// underspecced lexemes meet agreement too, so leave them in the end, if any
+			foreach (const Corpus2::Lexeme& lex, underspecifieds[i]) {
+				lexemes.push_back(lex);
 			}
 		}
 	}
-- 
GitLab