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

to_string and write_to for TagRuleSequence.

parent 454e3945
Branches
No related merge requests found
...@@ -41,4 +41,31 @@ int TagRuleSequence::execute_until_done(const boost::shared_ptr<Corpus2::Sentenc ...@@ -41,4 +41,31 @@ int TagRuleSequence::execute_until_done(const boost::shared_ptr<Corpus2::Sentenc
return iter_no; 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 */ } /* end ns Wccl */
...@@ -11,7 +11,7 @@ namespace Wccl { ...@@ -11,7 +11,7 @@ namespace Wccl {
* for all positions of a Sentence. * for all positions of a Sentence.
* @note The class methods are not thread-safe * @note The class methods are not thread-safe
*/ */
class TagRuleSequence : public std::vector<TagRule> class TagRuleSequence : public std::vector<TagRule>, public Expression
{ {
public: public:
TagRuleSequence(std::vector<TagRule> rules); TagRuleSequence(std::vector<TagRule> rules);
...@@ -65,6 +65,10 @@ public: ...@@ -65,6 +65,10 @@ public:
* @see execute_once() - Executes Rules but only once * @see execute_once() - Executes Rules but only once
*/ */
int execute_until_done(const boost::shared_ptr<Corpus2::Sentence>& sentence, int max_iter = 1000); 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;
}; };
......
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