From 472bb136cda4b707585217c5f288e74f98d6c3f4 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 10:45:39 +0200 Subject: [PATCH] (swig) Added wrapper for Wccl::MatchVector --- swig/Makefile | 13 ++++++++++ swig/libcclmatchvector.i | 56 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 swig/libcclmatchvector.i diff --git a/swig/Makefile b/swig/Makefile index 3c69872..d13b32f 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -24,6 +24,7 @@ CBIN=libcclvalue.o \ libcclmatchdata.o \ libccltokenmatch.o \ libcclannotationmatch.o \ + libcclmatchvector.o \ libcclexpression.o \ libcclparsedexpression.o \ libcclfunctionaloperator.o \ @@ -45,6 +46,7 @@ CBINOUT=_libcclvalue.so \ _libcclmatchdata.so \ _libccltokenmatch.so \ _libcclannotationmatch.so \ + _libcclmatchvector.so \ _libcclsentencecontext.so \ _libccloperator.so \ _libcclparser.so \ @@ -64,6 +66,7 @@ CWRAP=libcclvalue_wrap.cxx \ libcclmatchdata_wrap.cxx \ libccltokenmatch_wrap.cxx \ libcclannotationmatch_wrap.cxx \ + libcclmatchvector_wrap.cxx \ libcclsentencecontext_wrap.cxx \ libcorpussentence_wrap.cxx \ libccloperator_wrap.cxx \ @@ -82,6 +85,7 @@ CWRAPBIN=libcclvalue_wrap.o \ libcclmatchdata_wrap.o \ libccltokenmatch_wrap.o \ libcclannotationmatch_wrap.o \ + libcclmatchvector_wrap.o \ libcclsentencecontext_wrap.o \ libccloperator_wrap.o \ libcclparser_wrap.o \ @@ -101,6 +105,7 @@ PYMODULES=libcclvalue.py \ libcclvariables.py \ libcclsentencecontext.py \ libcclannotationmatch.py \ + libcclmatchvector.py \ libcclfunctionaloperator.py \ libccloperator.py \ boost_shared_ptr.py @@ -118,6 +123,7 @@ PYCBIN=libcclvalue.pyc \ libcclvariables.pyc \ libcclsentencecontext.pyc \ libcclannotationmatch.pyc \ + libcclmatchvector.pyc \ libcclfunctionaloperator.pyc \ libccloperator.pyc \ libcclparser.pyc \ @@ -205,6 +211,13 @@ libcclannotationmatch.o: $(CPP) -shared libcclannotationmatch_wrap.o \ $(CCLBIN) $(ANTLRLIB) -o _libcclannotationmatch.so +# MatchVector +libcclmatchvector.o: + $(SWIG) $(SWIGOPTS_LANG) libcclmatchvector.i + $(CPP) -c libcclmatchvector_wrap.cxx -I$(PYTHONDIR) -I$(WCCLDIR) $(CPPFLAGS) + $(CPP) -shared libcclmatchvector_wrap.o \ + $(CCLBIN) $(ANTLRLIB) -o _libcclmatchvector.so + # Expression libcclexpression.o: $(SWIG) $(SWIGOPTS_LANG) libcclexpression.i diff --git a/swig/libcclmatchvector.i b/swig/libcclmatchvector.i new file mode 100644 index 0000000..f5fa3bb --- /dev/null +++ b/swig/libcclmatchvector.i @@ -0,0 +1,56 @@ +#ifndef SWIG_LIBWCCL_MATCHVECTOR_I +#define SWIG_LIBWCCL_MATCHVECTOR_I + +%module libcclmatchvector +%{ + #include <libwccl/values/matchvector.h> +%} + +%include "libcclmatch.i" +%include "libcclmatchdata.i" +%include "libccltokenmatch.i" +%include "libcclannotationmatch.i" +%include "libcorpus/libcorpusannotatedsentence.i" + +%include "std_string.i" +%include "boost_shared_ptr.i" + +%template(MatchVectorPtr) boost::shared_ptr<Wccl::MatchVector>; + +namespace Wccl { + class MatchVector { + public: + MatchVector(); + ~MatchVector(); + /* --------------------------------------------------------------------- */ + + bool empty() const; + /* --------------------------------------------------------------------- */ + + int first_token(const boost::shared_ptr<Corpus2::AnnotatedSentence>& s) const; + int last_token(const boost::shared_ptr<Corpus2::AnnotatedSentence>& s) const; + /* --------------------------------------------------------------------- */ + + std::string to_raw_string() const; + /* --------------------------------------------------------------------- */ + + void append(const boost::shared_ptr<Match>& m); + void append(const boost::shared_ptr<MatchData>& m); + void append(const boost::shared_ptr<MatchVector>& m); + void append(const boost::shared_ptr<TokenMatch>& m); + void append(const boost::shared_ptr<AnnotationMatch>& m); + /* --------------------------------------------------------------------- */ + + size_t size() const; + void clear(); + /* --------------------------------------------------------------------- */ + + const boost::shared_ptr<Match>& submatch(size_t idx); + // const boost::shared_ptr<const Match> submatch(size_t idx) const; + }; +} + +using namespace std; +using namespace Wccl; + +#endif /* SWIG_LIBWCCL_MATCHVECTOR_I */ -- GitLab