From 2f02ba57c6b5caad60af9b4a09f07cf11a3ddbef Mon Sep 17 00:00:00 2001
From: Adam Radziszewski <adam.radziszewski@pwr.wroc.pl>
Date: Wed, 20 Jul 2011 14:50:01 +0200
Subject: [PATCH] revert to expand_optional_attrs

---
 libcorpus2/tagging.cpp |  4 ++--
 libcorpus2/tagging.h   |  4 ++--
 libcorpus2/tagset.cpp  |  5 ++---
 libcorpus2/tagset.h    | 14 +++++++-------
 swig/tagging.i         |  2 +-
 swig/tagset.i          |  2 +-
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/libcorpus2/tagging.cpp b/libcorpus2/tagging.cpp
index d009c95..41b0733 100644
--- a/libcorpus2/tagging.cpp
+++ b/libcorpus2/tagging.cpp
@@ -77,10 +77,10 @@ bool select_preferred_disamb(const Tagset& tagset,
 	return true;
 }
 
-void expand_unspec_attrs(const Tagset& tagset, Token* token)
+void expand_optional_attrs(const Tagset& tagset, Token* token)
 {
 	foreach (Lexeme& lex, token->lexemes()) {
-		lex.set_tag(tagset.expand_unspec_attrs(lex.tag()));
+		lex.set_tag(tagset.expand_optional_attrs(lex.tag()));
 	}
 }
 
diff --git a/libcorpus2/tagging.h b/libcorpus2/tagging.h
index 0cbb443..7ae0a39 100644
--- a/libcorpus2/tagging.h
+++ b/libcorpus2/tagging.h
@@ -50,11 +50,11 @@ int mask_card(const Tag& mask);
   */
 bool select_preferred_disamb(const Tagset& tagset, Token* token);
 
-/** Encodes attributes with unspecified values as each value set.
+/** Encodes optional attributes with unspecified values as each value set.
   * This is to facilitate safe masking when the value in question is not to be
   * skipped.
   */
-void expand_unspec_attrs(const Tagset& tagset, Token* token);
+void expand_optional_attrs(const Tagset& tagset, Token* token);
 
 /** Repairs multivalue tags. Optional attributes will be cleared if
   * multi-value. Regular attributes will be set to lowest value given.
diff --git a/libcorpus2/tagset.cpp b/libcorpus2/tagset.cpp
index 8ae89fe..5869159 100644
--- a/libcorpus2/tagset.cpp
+++ b/libcorpus2/tagset.cpp
@@ -604,12 +604,11 @@ Tag Tagset::select_singular(const Tag& tag) const
 	return new_tag;
 }
 
-Tag Tagset::expand_unspec_attrs(const Tag& tag) const
+Tag Tagset::expand_optional_attrs(const Tag& tag) const
 {
 	Tag new_tag(tag);
 	idx_t pos_idx = tag.get_pos_index();
-	const std::vector<idx_t>& attrs = get_pos_attributes(pos_idx);
-	for (idx_t a = 0; a < attribute_count(); ++a) {
+	foreach (idx_t a, get_pos_attributes(pos_idx)) {
 		mask_t attr_mask = get_attribute_mask(a);
 		mask_t value = tag.get_values_for(attr_mask);
 		if (!value.any()) { // no value given
diff --git a/libcorpus2/tagset.h b/libcorpus2/tagset.h
index 504dc22..821ec9a 100644
--- a/libcorpus2/tagset.h
+++ b/libcorpus2/tagset.h
@@ -374,14 +374,14 @@ public:
 	Tag select_singular(const Tag& tag) const;
 
 	/**
-	  * Creates a copy of the given tag where any attribute with no value given
-	  * is encoded as each possible value set. NOTE: this produce an invalid
-	  * tag (multiple values set for one attribute), yet it is convenient for
-	  * some tagging scenarios to be able to retrieve unspecified attr value as
-	  * a non-zero mask. This can always be decoded into a valid tag by using
-	  * select_singular.
+	  * Creates a copy of the given tag where any optional attribute with no
+	  * value given is encoded as each possible value set. NOTE: this may
+	  * an invalid tag (multiple values set for one attribute), yet it is
+	  * convenient for some tagging scenarios to be able to retrieve
+	  * unspecified attr value as a non-zero mask. This can always be decoded
+	  * into a valid tag by using select_singular.
 	  */
-	Tag expand_unspec_attrs(const Tag& tag) const;
+	Tag expand_optional_attrs(const Tag& tag) const;
 
 	/// POS name <-> index dictionary getter
 	const SymbolDictionary<idx_t>& pos_dictionary() const {
diff --git a/swig/tagging.i b/swig/tagging.i
index 96d1bb8..c9fdd9c 100644
--- a/swig/tagging.i
+++ b/swig/tagging.i
@@ -23,7 +23,7 @@ int mask_card(const Tag& mask);
 
 bool select_preferred_disamb(const Tagset& tagset, Token* token);
 
-void expand_unspec_attrs(const Tagset& tagset, Token* token);
+void expand_optional_attrs(const Tagset& tagset, Token* token);
 
 void select_singular_tags(const Tagset& tagset, Token* token);
 
diff --git a/swig/tagset.i b/swig/tagset.i
index 1d62038..3df9d95 100644
--- a/swig/tagset.i
+++ b/swig/tagset.i
@@ -92,7 +92,7 @@ namespace Corpus2 {
     /* --------------------------------------------------------------------- */
     std::vector<Tag> split_tag(const Tag& tag) const;
     Tag select_singular(const Tag& tag) const;
-    Tag expand_unspec_attrs(const Tag& tag) const;
+    Tag expand_optional_attrs(const Tag& tag) const;
     /* --------------------------------------------------------------------- */
     int pos_count() const;
     int attribute_count() const;
-- 
GitLab