Commit bcef63ac authored by Radosław Warzocha's avatar Radosław Warzocha

Parser and WcclFile have now their own copy of tagset

parent a6fd8c0c
......@@ -30,11 +30,16 @@ namespace Wccl {
/**
* @desc Parser constructor. Default tagset is NULL
*/
Parser::Parser(const Corpus2::Tagset& t) : tagset_(t)
Parser::Parser(const Corpus2::Tagset& t) : tagset_(new Corpus2::Tagset(t))
{
}
Parser::Parser(const std::string& tagset_name) : tagset_(Corpus2::get_named_tagset(tagset_name))
Parser::Parser(const boost::shared_ptr<const Corpus2::Tagset>) : tagset_(tagset)
{
}
Parser::Parser(const std::string& tagset_name)
: tagset_(new Corpus2::Tagset(Corpus2::get_named_tagset(tagset_name)))
{
}
......
......@@ -50,6 +50,7 @@ namespace Wccl{
class Parser {
public:
explicit Parser(const Corpus2::Tagset&);
explicit Parser(const boost::shared_ptr<const Corpus2::Tagset>);
explicit Parser(const std::string& tagset_name);
~Parser();
......@@ -128,12 +129,12 @@ public:
const std::string& search_path = ".") const;
// ---------------------------------------------------------------------------
const Corpus2::Tagset& tagset() const {
const boost::shared_ptr<Corpus2::Tagset> tagset() const {
return tagset_;
}
private:
const Corpus2::Tagset &tagset_;
const boost::shared_ptr<const Corpus2::Tagset> tagset_;
};
} // end Wccl ns
......
......@@ -78,13 +78,13 @@ std::ostream& WcclFile::write_to(std::ostream& os) const
}
}
BOOST_FOREACH (const boost::shared_ptr<FunctionalOpSequence>& s, all_sections_) {
os << s->to_string(tagset_) << '\n';
os << s->to_string(*tagset_) << '\n';
}
if (has_tag_rules()) {
os << tag_rules_->to_string(tagset_) << '\n';
os << tag_rules_->to_string(*tagset_) << '\n';
}
if (has_match_rules()) {
os << match_rules_->to_string(tagset_) << '\n';
os << match_rules_->to_string(*tagset_) << '\n';
}
return os;
}
......
......@@ -48,6 +48,7 @@ class WcclFile
{
public:
WcclFile(const Corpus2::Tagset& tagset, const std::string& search_path);
WcclFile(const boost::shared_ptr<const Corpus2::Tagset> tagset, const std::string& search path);
/////////////////////
// Untyped and typed operator sections: @X:"sectioname" ( op1; op2 )
......@@ -340,7 +341,7 @@ public:
void import_lexicon(const boost::shared_ptr<Lexicon>& lexicon);
void set_tag_rules(const boost::shared_ptr<TagRuleSequence>& tag_rules);
void set_match_rules(const boost::shared_ptr<Matching::MatchRuleSequence>& match_rules);
private:
......@@ -349,7 +350,7 @@ private:
boost::shared_ptr<TagRuleSequence> tag_rules_;
boost::shared_ptr<Matching::MatchRuleSequence> match_rules_;
boost::shared_ptr<Lexicons> lexicons_;
const Corpus2::Tagset& tagset_;
const boost::shared_ptr<const Corpus2::Tagset> tagset_;
PwrNlp::PathSearcher<Wccl::FileNotFound> path_;
};
......@@ -362,6 +363,13 @@ namespace Wccl {
inline
WcclFile::WcclFile(const Corpus2::Tagset& tagset, const std::string& search_path)
: lexicons_(boost::make_shared<Lexicons>()), tagset_(new Corpus2::Tagset(tagset)),
path_(":")
{
path_.set_search_path(search_path);
path_.set_verbose(false);
}
WcclFile::WcclFile(const boost::shared_ptr<const Corpus2::Tagset> tagset, const std::string& search_path)
: lexicons_(boost::make_shared<Lexicons>()), tagset_(tagset),
path_(":")
{
......@@ -664,7 +672,7 @@ std::ostream& operator <<(std::ostream& ostream, const WcclFile& wccl_file) {
}
inline
const Corpus2::Tagset& WcclFile::tagset() const {
const boost::shared_ptr<Corpus2::Tagset> WcclFile::tagset() const {
return tagset_;
}
......
Markdown is supported
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