Commit 375f641c authored by Radosław Warzocha's avatar Radosław Warzocha

Fixes - all classes use shared_ptrs instead of references

parent e58cc40f
......@@ -22,7 +22,7 @@ namespace Wccl {
FunctionBase::BaseRetValPtr IsSingular::apply_internal(const FunExecContext& context) const {
const boost::shared_ptr<const TSet>& tag = arg_expr_->apply(context);
return Predicate::evaluate(tagset_.tag_is_singular(tag->get_value()), context);
return Predicate::evaluate(tagset_->tag_is_singular(tag->get_value()), context);
}
std::string IsSingular::to_string(const Corpus2::Tagset &tagset) const {
......
......@@ -32,7 +32,7 @@ class IsSingular : public Predicate
public:
typedef boost::shared_ptr<Function<TSet> > ArgFunctionPtr;
IsSingular(const ArgFunctionPtr& arg_expr, const Corpus2::Tagset& tagset)
IsSingular(const ArgFunctionPtr& arg_expr, const boost::shared_ptr<const Corpus2::Tagset> tagset)
: arg_expr_(arg_expr), tagset_(tagset)
{
BOOST_ASSERT(arg_expr_);
......@@ -52,7 +52,7 @@ public:
protected:
const ArgFunctionPtr arg_expr_;
const Corpus2::Tagset& tagset_;
const boost::shared_ptr<const Corpus2::Tagset> tagset_;
/**
* Take value of argument and return True if it is empty, False otherwise.
......
......@@ -53,7 +53,7 @@ PointAgreement::BaseRetValPtr PointAgreement::apply_internal(const FunExecContex
const boost::shared_ptr<const TSet>& attribs = attribs_expr_->apply(context);
int min_card = attribs->categories_count(tagset_);
int min_card = attribs->categories_count(*tagset_);
const Corpus2::Token* t1 = sc.at(*pos1);
const Corpus2::Token* t2 = sc.at(*pos2);
......
......@@ -38,7 +38,7 @@ public:
const PosFunctionPtr& pos1_expr,
const PosFunctionPtr& pos2_expr,
const TSetFunctionPtr& attribs_expr,
const Corpus2::Tagset& tagset)
const boost::shared_ptr<const Corpus2::Tagset> tagset)
: pos1_expr_(pos1_expr),
pos2_expr_(pos2_expr),
attribs_expr_(attribs_expr),
......@@ -65,7 +65,7 @@ protected:
const PosFunctionPtr pos1_expr_;
const PosFunctionPtr pos2_expr_;
const TSetFunctionPtr attribs_expr_;
const Corpus2::Tagset& tagset_;
const boost::shared_ptr<const Corpus2::Tagset> tagset_;
/**
* Gets two positions from arguments. If either of them
......
......@@ -56,7 +56,7 @@ StrongAgreement::BaseRetValPtr StrongAgreement::apply_internal(const FunExecCont
}
const boost::shared_ptr<const TSet>& attribs = attribs_expr_->apply(context);
int min_card = attribs->categories_count(tagset_);
int min_card = attribs->categories_count(*tagset_);
const Corpus2::Token* t1 = sc.at(abs_left);
const Corpus2::Token* t2 = sc.at(abs_right);
......
......@@ -37,7 +37,7 @@ public:
const PosFunctionPtr& left_pos_expr,
const PosFunctionPtr& right_pos_expr,
const TSetFunctionPtr& attribs_expr,
const Corpus2::Tagset& tagset)
const boost::shared_ptr<const Corpus2::Tagset> tagset)
: left_pos_expr_(left_pos_expr),
right_pos_expr_(right_pos_expr),
attribs_expr_(attribs_expr),
......@@ -65,7 +65,7 @@ protected:
const PosFunctionPtr left_pos_expr_;
const PosFunctionPtr right_pos_expr_;
const TSetFunctionPtr attribs_expr_;
const Corpus2::Tagset& tagset_;
const boost::shared_ptr<const Corpus2::Tagset> tagset_;
/**
* Gets start and end positions for range from arguments.
......
......@@ -56,7 +56,7 @@ WeakAgreement::BaseRetValPtr WeakAgreement::apply_internal(const FunExecContext&
}
const boost::shared_ptr<const TSet>& attribs = attribs_expr_->apply(context);
int min_card = attribs->categories_count(tagset_);
int min_card = attribs->categories_count(*tagset_);
const Corpus2::Token* t1 = sc.at(abs_left);
const Corpus2::Token* t2 = sc.at(abs_right);
// to optimize a bit, make sure t1 is the one with less lexemes
......
......@@ -37,7 +37,7 @@ public:
const PosFunctionPtr& left_pos_expr,
const PosFunctionPtr& right_pos_expr,
const TSetFunctionPtr& attribs_expr,
const Corpus2::Tagset& tagset)
const boost::shared_ptr<const Corpus2::Tagset> tagset)
: left_pos_expr_(left_pos_expr),
right_pos_expr_(right_pos_expr),
attribs_expr_(attribs_expr),
......@@ -65,7 +65,7 @@ protected:
const PosFunctionPtr left_pos_expr_;
const PosFunctionPtr right_pos_expr_;
const TSetFunctionPtr attribs_expr_;
const Corpus2::Tagset& tagset_;
const boost::shared_ptr<const Corpus2::Tagset> tagset_;
/**
* Gets start and end positions for range from arguments.
......
......@@ -59,7 +59,7 @@ AgrFilter::BaseRetValPtr AgrFilter::apply_internal(const FunExecContext& context
const boost::shared_ptr<const TSet>& attribs = attribs_expr_->apply(context);
const boost::shared_ptr<const TSet>& mask = mask_expr_->apply(context);
int min_card = attribs->categories_count(tagset_);
int min_card = attribs->categories_count(*tagset_);
const Corpus2::Token* t1 = sc.at(abs_left);
const Corpus2::Token* t2 = sc.at(abs_right);
// to optimize a bit, make sure t1 is the one with less lexemes
......
......@@ -40,7 +40,7 @@ public:
const PosFunctionPtr& right_pos_expr,
const TSetFunctionPtr& attribs_expr,
const TSetFunctionPtr& mask_expr,
const Corpus2::Tagset& tagset)
const boost::shared_ptr<const Corpus2::Tagset> tagset)
: left_pos_expr_(left_pos_expr),
right_pos_expr_(right_pos_expr),
attribs_expr_(attribs_expr),
......@@ -73,7 +73,7 @@ protected:
const TSetFunctionPtr attribs_expr_;
const TSetFunctionPtr mask_expr_;
const Corpus2::Tagset& tagset_;
const boost::shared_ptr<const Corpus2::Tagset> tagset_;
/**
* Gets range specified via Position expressions. Trims the range
......
......@@ -34,7 +34,7 @@ Parser::Parser(const Corpus2::Tagset& t) : tagset_(new Corpus2::Tagset(t))
{
}
Parser::Parser(const boost::shared_ptr<const Corpus2::Tagset>) : tagset_(tagset)
Parser::Parser(const boost::shared_ptr<const Corpus2::Tagset> tagset) : tagset_(tagset)
{
}
......
......@@ -129,7 +129,7 @@ public:
const std::string& search_path = ".") const;
// ---------------------------------------------------------------------------
const boost::shared_ptr<Corpus2::Tagset> tagset() const {
const boost::shared_ptr<const Corpus2::Tagset> tagset() const {
return tagset_;
}
......
......@@ -362,7 +362,7 @@ symset_elem
[const boost::shared_ptr<const Corpus2::Tagset> tagset, boost::shared_ptr<TSet>& t_set]
: s1: SYMBOL {
try {
t_set->insert_symbol(tagset, str_token_rem_grav(s1));
t_set->insert_symbol(*tagset, str_token_rem_grav(s1));
}
catch(Corpus2::TagParseError &e) {
throw(ParserException(e.info()));
......@@ -827,7 +827,7 @@ symset_getsymbol
}
: t: SYMBOL LBRACKET position = position_operator [scope] RBRACKET {
try {
tag = scope.tagset().parse_symbol(str_token_rem_grav(t));
tag = scope.tagset()->parse_symbol(str_token_rem_grav(t));
}
catch(Corpus2::TagParseError &e) {
throw(ParserException(e.info()));
......
......@@ -48,7 +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);
WcclFile(const boost::shared_ptr<const Corpus2::Tagset> tagset, const std::string& search_path);
/////////////////////
// Untyped and typed operator sections: @X:"sectioname" ( op1; op2 )
......@@ -321,7 +321,7 @@ public:
friend std::ostream& operator<<(std::ostream& ostream, const WcclFile& wccl_file);
std::string to_string() const;
const Corpus2::Tagset& tagset() const;
const boost::shared_ptr<const Corpus2::Tagset> tagset() const;
const PwrNlp::PathSearcher<Wccl::FileNotFound> path() const { return path_; }
PwrNlp::PathSearcher<Wccl::FileNotFound> path() { return path_; }
......@@ -369,6 +369,8 @@ WcclFile::WcclFile(const Corpus2::Tagset& tagset, const std::string& search_path
path_.set_search_path(search_path);
path_.set_verbose(false);
}
inline
WcclFile::WcclFile(const boost::shared_ptr<const Corpus2::Tagset> tagset, const std::string& search_path)
: lexicons_(boost::make_shared<Lexicons>()), tagset_(tagset),
path_(":")
......@@ -672,7 +674,7 @@ std::ostream& operator <<(std::ostream& ostream, const WcclFile& wccl_file) {
}
inline
const boost::shared_ptr<Corpus2::Tagset> WcclFile::tagset() const {
const boost::shared_ptr<const 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