Newer
Older
#ifndef LIBMWEREADER_MWE_H
#define LIBMWEREADER_MWE_H
Bartosz Broda
committed
#include <boost/unordered_map.hpp>
Bartosz Broda
committed
typedef std::map<std::string, std::string> strmap;
typedef std::set<std::string> strset;
typedef boost::shared_ptr<Wccl::Operator<Wccl::Bool> > BoolOpPtr;
LexicalUnit(const std::string &base, BoolOpPtr condition,
BoolOpPtr head_cond, strmap variables
Bartosz Broda
committed
/**
* \param sc SentenceContext with position set to value which
* will be checked
* \param out_positions will contain absolute position in
* SentenceContext (called with sc->get_abs_position) only if
* the main condition of this LexicalUnit will return true in current
* sentence context
* \returns true if this lexical unit was found here
*/
virtual bool IsHere(const Wccl::SentenceContext& sc,
Bartosz Broda
committed
std::set<size_t> &out_positions) ;
const std::string & get_base() const{ return base_;}
const strmap & get_variables() const{ return variables_;}
const strset& get_potential_bases() const{ return potential_bases_;}
Bartosz Broda
committed
boost::shared_ptr<Wccl::Operator<Wccl::Bool> > condition_;
boost::shared_ptr<Wccl::Operator<Wccl::Bool> > head_cond_;
Bartosz Broda
committed
strmap variables_;
Bartosz Broda
committed
strset potential_bases_;
const Wccl::Position nowhere_;
Bartosz Broda
committed
typedef boost::shared_ptr<LexicalUnit> LexicalUnitPtr;
// TODO: czy bedzie potrzebny podzial na fix/flex w kodzie?
public:
FixedLU(const std::string &base,
boost::shared_ptr<Wccl::Operator<Wccl::Bool> > condition,
boost::shared_ptr<Wccl::Operator<Wccl::Bool> > head_cond,
std::map<std::string, std::string> variables
);
};
class FlexLU : public LexicalUnit
{
Bartosz Broda
committed
public:
FlexLU(const std::string &base,
boost::shared_ptr<Wccl::Operator<Wccl::Bool> > condition,
boost::shared_ptr<Wccl::Operator<Wccl::Bool> > head_cond,
std::map<std::string, std::string> variables
);
};
class MWEIndex // lub base -> vector<LexicalUnit>
{
Bartosz Broda
committed
public:
MWEIndex();
void add_lexicalunit(LexicalUnitPtr lu);
protected:
typedef std::vector<LexicalUnitPtr> luvec;
typedef boost::unordered_map<std::string,luvec> value_type;
value_type index_;
};
}// ns Corpus2
#endif //LIBMWEREADER_MWE_H