From 98c793591b6d9030e31c5078002bc01337ef17e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <Pawel.Kedzia@pwr.wroc.pl> Date: Tue, 10 May 2011 12:25:20 +0200 Subject: [PATCH] (swig) Added wrapper for Wccl::TagRuleSequence --- swig/Makefile | 15 +++++++++++- swig/libccltagrulesequence.i | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 swig/libccltagrulesequence.i diff --git a/swig/Makefile b/swig/Makefile index a0a2e77..241f1f4 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -34,7 +34,8 @@ CBIN=libcclvalue.o \ libcclparser.o \ libcclactionexeccontext.o \ libccltagaction.o \ - libccltagrule.o + libccltagrule.o \ + libccltagrulesequence.o CBINOUT=_libcclvalue.so \ _libcclstrset.so \ @@ -56,6 +57,7 @@ CBINOUT=_libcclvalue.so \ _libcclactionexeccontext.so \ _libccltagaction.so \ _libccltagrule.so \ + _libccltagrulesequence.so \ _boost_shared_ptr.so CWRAP=libcclvalue_wrap.cxx \ @@ -79,6 +81,7 @@ CWRAP=libcclvalue_wrap.cxx \ libcclactionexeccontext_wrap.cxx \ libccltagaction_wrap.cxx \ libccltagrule_wrap.cxx \ + libccltagrulesequence_wrap.cxx \ boost_shared_ptr_wrap.cxx CWRAPBIN=libcclvalue_wrap.o \ @@ -101,6 +104,7 @@ CWRAPBIN=libcclvalue_wrap.o \ libcclactionexeccontext_wrap.o \ libccltagaction_wrap.o \ libccltagrule_wrap.o \ + libccltagrulesequence_wrap.o \ boost_shared_ptr_wrap.o PYMODULES=libcclvalue.py \ @@ -123,6 +127,7 @@ PYMODULES=libcclvalue.py \ libcclactionexeccontext.py \ libccltagaction.py \ libccltagrule.py \ + libccltagrulesequence.py \ boost_shared_ptr.py PYCBIN=libcclvalue.pyc \ @@ -145,6 +150,7 @@ PYCBIN=libcclvalue.pyc \ libcclactionexeccontext.pyc \ libccltagaction.pyc \ libccltagrule.pyc \ + libccltagrulesequence.pyc \ boost_shared_ptr.pyc all:boost_shared_ptr.o $(CBIN) @@ -310,6 +316,13 @@ libccltagrule.o: $(CPP) -shared libccltagrule_wrap.o \ $(CCLBIN) $(ANTLRLIB) -o _libccltagrule.so +# TagRuleSequence +libccltagrulesequence.o: + $(SWIG) $(SWIGOPTS_LANG) libccltagrulesequence.i + $(CPP) -c libccltagrulesequence_wrap.cxx -I$(PYTHONDIR) -I$(WCCLDIR) $(CPPFLAGS) + $(CPP) -shared libccltagrulesequence_wrap.o \ + $(CCLBIN) $(ANTLRLIB) -o _libccltagrulesequence.so + # ----------------------------------------------------------------------------- clean: rm -f $(CBIN) $(CBINOUT) $(CWRAP) $(CWRAPBIN) $(PYMODULES) $(PYCBIN) diff --git a/swig/libccltagrulesequence.i b/swig/libccltagrulesequence.i new file mode 100644 index 0000000..2c5bde4 --- /dev/null +++ b/swig/libccltagrulesequence.i @@ -0,0 +1,47 @@ +#ifndef SWIG_LIBWCCL_TAGRULESEQUENCE_I +#define SWIG_LIBWCCL_TAGRULESEQUENCE_I + +%module libccltagrulesequence +%{ + #include <libwccl/ops/tagrulesequence.h> +%} + +%include "libcclbool.i" +%include "libccltagrule.i" +%include "libcclexpression.i" +%include "libcorpus/libcorpussentence.i" + +%include "std_string.i" +%include "std_vector.i" +%include "boost_shared_ptr.i" + +%template(StdVectorTagRule) std::vector<TagRule>; +%template(TagRuleSequencPtr) boost::shared_ptr<Wccl::TagRuleSequence>; + +namespace Wccl { + class TagRuleSequence : public std::vector<TagRule>, public Expression { + public: + TagRuleSequence(const std::vector<TagRule>& rules); + TagRuleSequence(); + + /* --------------------------------------------------------------------- */ + + %rename(OpFunTagRuleSequence) operator()( + const boost::shared_ptr<Corpus2::Sentence>& sentence + ); + Bool operator()(const boost::shared_ptr<Corpus2::Sentence>& sentence); + + /* --------------------------------------------------------------------- */ + + Bool execute_once(const boost::shared_ptr<Corpus2::Sentence>& sentence); + int execute_until_done(const boost::shared_ptr<Corpus2::Sentence>& sentence, int max_iter = 1000); + + std::string to_string(const Corpus2::Tagset& tagset) const; + }; +} + +using namespace boost; +using namespace Wccl; +using namespace std; + +#endif /* SWIG_LIBWCCL_TAGRULESEQUENCE_I */ -- GitLab