diff --git a/libwccl/ops/tagrulesequence.cpp b/libwccl/ops/tagrulesequence.cpp index ea2c3abf3dacfe345f6e5cdee46e8a1370564945..73912941ba2ddafae855f68a66dbca5cba2d7daa 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 e415098d38adda9992a660f8ba315b607ff69a62..4a1ab672876b3b6224e793246e7da5b4fe02729b 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; };