#ifndef LIBMWEREADER_MWE_H #define LIBMWEREADER_MWE_H #include <boost/unordered_map.hpp> #include <libcorpus2/io/reader.h> #include <libwccl/ops/operator.h> namespace Corpus2 { class LexicalUnit { public: 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 ); /** * \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, 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_;} protected: boost::shared_ptr<Wccl::Operator<Wccl::Bool> > condition_; boost::shared_ptr<Wccl::Operator<Wccl::Bool> > head_cond_; strmap variables_; std::string base_; strset potential_bases_; const Wccl::Position nowhere_; }; typedef boost::shared_ptr<LexicalUnit> LexicalUnitPtr; // TODO: czy bedzie potrzebny podzial na fix/flex w kodzie? class FixedLU : public LexicalUnit { 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 { 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> { 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