diff --git a/swig/Makefile b/swig/Makefile index da14c48fcb15f91b5448be3322e94283666f06a8..a0a2e7736b4707d862a282fd671d9c498dab2162 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -33,7 +33,8 @@ CBIN=libcclvalue.o \ libcclsentencecontext.o \ libcclparser.o \ libcclactionexeccontext.o \ - libccltagaction.o + libccltagaction.o \ + libccltagrule.o CBINOUT=_libcclvalue.so \ _libcclstrset.so \ @@ -54,6 +55,7 @@ CBINOUT=_libcclvalue.so \ _libcclparser.so \ _libcclactionexeccontext.so \ _libccltagaction.so \ + _libccltagrule.so \ _boost_shared_ptr.so CWRAP=libcclvalue_wrap.cxx \ @@ -76,6 +78,7 @@ CWRAP=libcclvalue_wrap.cxx \ libcclparser_wrap.cxx \ libcclactionexeccontext_wrap.cxx \ libccltagaction_wrap.cxx \ + libccltagrule_wrap.cxx \ boost_shared_ptr_wrap.cxx CWRAPBIN=libcclvalue_wrap.o \ @@ -97,6 +100,7 @@ CWRAPBIN=libcclvalue_wrap.o \ libcclparser_wrap.o \ libcclactionexeccontext_wrap.o \ libccltagaction_wrap.o \ + libccltagrule_wrap.o \ boost_shared_ptr_wrap.o PYMODULES=libcclvalue.py \ @@ -118,6 +122,7 @@ PYMODULES=libcclvalue.py \ libcclparser.py \ libcclactionexeccontext.py \ libccltagaction.py \ + libccltagrule.py \ boost_shared_ptr.py PYCBIN=libcclvalue.pyc \ @@ -139,6 +144,7 @@ PYCBIN=libcclvalue.pyc \ libcclparser.pyc \ libcclactionexeccontext.pyc \ libccltagaction.pyc \ + libccltagrule.pyc \ boost_shared_ptr.pyc all:boost_shared_ptr.o $(CBIN) @@ -297,6 +303,13 @@ libccltagaction.o: $(CPP) -shared libccltagaction_wrap.o \ $(CCLBIN) $(ANTLRLIB) -o _libccltagaction.so +# TagRule +libccltagrule.o: + $(SWIG) $(SWIGOPTS_LANG) libccltagrule.i + $(CPP) -c libccltagrule_wrap.cxx -I$(PYTHONDIR) -I$(WCCLDIR) $(CPPFLAGS) + $(CPP) -shared libccltagrule_wrap.o \ + $(CCLBIN) $(ANTLRLIB) -o _libccltagrule.so + # ----------------------------------------------------------------------------- clean: rm -f $(CBIN) $(CBINOUT) $(CWRAP) $(CWRAPBIN) $(PYMODULES) $(PYCBIN) diff --git a/swig/libccltagrule.i b/swig/libccltagrule.i new file mode 100644 index 0000000000000000000000000000000000000000..d9db4091fcebcdb37b4f1b031caf1685b8aa7c42 --- /dev/null +++ b/swig/libccltagrule.i @@ -0,0 +1,74 @@ +#ifndef SWIG_LIBWCCL_TAGRULE_I +#define SWIG_LIBWCCL_TAGRULE_I + +%module libccltagrule +%{ + #include <libwccl/ops/tagrule.h> +%} + +%include "libcclbool.i" +%include "libccltagaction.i" +%include "libcclvariables.i" +%include "libcclsentencecontext.i" +%include "libcclparsedexpression.i" + +%include "libcorpus/libcorpustagset.i" + +%include "std_string.i" +%include "boost_shared_ptr.i" + +%template(TagRulePtr) boost::shared_ptr<Wccl::TagRule>; + +namespace Wccl { + class TagRule : public ParsedExpression { + public: + /* + TagRule( + const std::string& name, + const Variables& variables, + const boost::shared_ptr<const std::vector<boost::shared_ptr<TagAction> > >& actions, + const boost::shared_ptr<const Function<Bool> >& condition = TrueCondition() + ); + */ + + TagRule(); + TagRule(const TagRule& other, bool clean = false); + + /* --------------------------------------------------------------------- */ + + %rename(OpFunTagRule) operator()(const SentenceContext& sentence_context); + Bool operator()(SentenceContext& sentence_context); + /* --------------------------------------------------------------------- */ + + Bool execute(SentenceContext& sentence_context); + + std::string name() const; + /* --------------------------------------------------------------------- */ + + TagRule clone() const; + TagRule clone_clean() const; + /* --------------------------------------------------------------------- */ + + boost::shared_ptr<TagRule> clone_ptr() const; + boost::shared_ptr<TagRule> clone_clean_ptr() const; + /* --------------------------------------------------------------------- */ + + %rename(OperatorEqTagRule) *::operator=(const TagRule& other); + /* --------------------------------------------------------------------- */ + + std::string to_string(const Corpus2::Tagset& tagset) const; + /* --------------------------------------------------------------------- */ + + protected: + TagRule* clone_internal() const; + + private: + // static const boost::shared_ptr<const Function<Bool> > TrueCondition(); + }; +} + +using namespace boost; +using namespace Wccl; +using namespace std; + +#endif /* SWIG_LIBWCCL_TAGRULE_I */