From b221b57c9d6b3eb907a4ac9e1b3577ce5076fd04 Mon Sep 17 00:00:00 2001
From: Adam Wardynski <award@.(win7-laptop)>
Date: Thu, 28 Apr 2011 21:48:52 +0200
Subject: [PATCH] to_string and write_to for TagRuleSequence.

---
 libwccl/ops/tagrulesequence.cpp | 27 +++++++++++++++++++++++++++
 libwccl/ops/tagrulesequence.h   |  6 +++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/libwccl/ops/tagrulesequence.cpp b/libwccl/ops/tagrulesequence.cpp
index ea2c3ab..7391294 100644
--- a/libwccl/ops/tagrulesequence.cpp
+++ b/libwccl/ops/tagrulesequence.cpp
@@ -41,4 +41,31 @@ int TagRuleSequence::execute_until_done(const boost::shared_ptr<Corpus2::Sentenc
 	return iter_no;
 }
 
+std::string TagRuleSequence::to_string(const Corpus2::Tagset& tagset) const
+{
+	std::ostringstream os;
+	os << "rules(";
+	for (size_t i = 0; i < size(); ++i) {
+		if (i != 0) {
+			os << ", \n";
+		}
+		os << at(i).to_string(tagset);
+	}
+	os << ")";
+	return os.str();
+}
+
+std::ostream& TagRuleSequence::write_to(std::ostream &os) const
+{
+	os << "rules(";
+	for (size_t i = 0; i < size(); ++i) {
+		if (i != 0) {
+			os << ", \n";
+		}
+		os << at(i);
+	}
+	os << ")";
+	return os;
+}
+
 } /* end ns Wccl */
diff --git a/libwccl/ops/tagrulesequence.h b/libwccl/ops/tagrulesequence.h
index e415098..4a1ab67 100644
--- a/libwccl/ops/tagrulesequence.h
+++ b/libwccl/ops/tagrulesequence.h
@@ -11,7 +11,7 @@ namespace Wccl {
  * for all positions of a Sentence.
  * @note The class methods are not thread-safe
  */
-class TagRuleSequence : public std::vector<TagRule>
+class TagRuleSequence : public std::vector<TagRule>, public Expression
 {
 public:
 	TagRuleSequence(std::vector<TagRule> rules);
@@ -65,6 +65,10 @@ public:
 	 * @see execute_once() - Executes Rules but only once
 	 */
 	int execute_until_done(const boost::shared_ptr<Corpus2::Sentence>& sentence, int max_iter = 1000);
+
+	std::string to_string(const Corpus2::Tagset& tagset) const;
+protected:
+	std::ostream& write_to(std::ostream& os) const;
 };
 
 
-- 
GitLab