diff --git a/swig/Makefile b/swig/Makefile index 3f7e76a16924443cee412765987d9990d2755ab6..08582fb312122b6dbf0ed583a8ddf3b7672373bb 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -23,7 +23,8 @@ CBIN=libcorpustag.o \ libcorpustokenwriter.o \ libcorpustokenreader.o \ libcorpusiob.o \ - libcorpusannotationchannel.o + libcorpusannotationchannel.o \ + libcorpusannotatedsentence.o CBINOUT=_boost_shared_ptr.so \ _libcorpustag.so \ @@ -36,7 +37,8 @@ CBINOUT=_boost_shared_ptr.so \ _libcorpustokenwriter.so \ _libcorpustokenreader.so \ _libcorpusiob.so \ - _libcorpusannotationchannel.so + _libcorpusannotationchannel.so \ + _libcorpusannotatedsentence.so CWRAP=boost_shared_ptr_wrap.cxx \ libcorpustag_wrap.cxx \ @@ -49,7 +51,8 @@ CWRAP=boost_shared_ptr_wrap.cxx \ libcorpustokenwriter_wrap.cxx \ libcorpustokenreader_wrap.cxx \ libcorpusiob_wrap.cxx \ - libcorpusannotationchannel_wrap.cxx + libcorpusannotationchannel_wrap.cxx \ + libcorpusannotatedsentence_wrap.cxx CWRAPBIN=boost_shared_ptr_wrap.o \ libcorpustag_wrap.o \ @@ -62,7 +65,8 @@ CWRAPBIN=boost_shared_ptr_wrap.o \ libcorpustokenwriter_wrap.o \ libcorpustokenreader_wrap.o \ libcorpusiob_wrap.o \ - libcorpusannotationchannel_wrap.o + libcorpusannotationchannel_wrap.o \ + libcorpusannotatedsentence_wrap.o PYMODULES=boost_shared_ptr.py \ libcorpustag.py \ @@ -75,7 +79,8 @@ PYMODULES=boost_shared_ptr.py \ libcorpustokenwriter.py \ libcorpustokenreader.py \ libcorpusiob.py \ - libcorpusannotationchannel.py + libcorpusannotationchannel.py \ + libcorpusannotatedsentence.py PYCBIN=boost_shared_ptr.pyc \ libcorpustag.pyc \ @@ -88,7 +93,8 @@ PYCBIN=boost_shared_ptr.pyc \ libcorpustokenwriter.pyc \ libcorpustokenreader.pyc \ libcorpusiob.pyc \ - libcorpusannotationchannel.pyc + libcorpusannotationchannel.pyc \ + libcorpusannotatedsentence.pyc # ----------------------------------------------------------------------------- all:boost_shared_ptr.o $(CBIN) @@ -185,6 +191,13 @@ libcorpusannotationchannel.o: $(CPP) -shared libcorpusannotationchannel_wrap.o \ $(PWRUTILBIN) $(CORPUS2BIN) -o _libcorpusannotationchannel.so +# AnotatedSentence +libcorpusannotatedsentence.o: + $(SWIG) $(SWIGOPTS_LANG) libcorpusannotatedsentence.i + $(CPP) -c libcorpusannotatedsentence_wrap.cxx -I$(PYTHONDIR) $(CPPFLAGS) + $(CPP) -shared libcorpusannotatedsentence_wrap.o \ + $(PWRUTILBIN) $(CORPUS2BIN) -o _libcorpusannotatedsentence.so + # ----------------------------------------------------------------------------- clean: rm -f $(CBIN) $(CBINOUT) $(CWRAP) $(CWRAPBIN) $(PYMODULES) $(PYCBIN) diff --git a/swig/libcorpusannotatedsentence.i b/swig/libcorpusannotatedsentence.i new file mode 100644 index 0000000000000000000000000000000000000000..0f85282b0414c9b45a9cd734ada6d38ffd926e4f --- /dev/null +++ b/swig/libcorpusannotatedsentence.i @@ -0,0 +1,59 @@ +#ifndef SWIG_LIBCORPUS2_ANNOTATEDSENTENCE_I +#define SWIG_LIBCORPUS2_ANNOTATEDSENTENCE_I + +%module libcorpusannotatedsentence +%{ + #include <libcorpus2/ann/annotatedsentence.h> +%} + +%include "libcorpustoken.i" +%include "libcorpussentence.i" +%include "libcorpusannotationchannel.i" + +%include "boost_shared_ptr.i" +%include "std_map.i" +%include "std_string.i" + +%feature("notabstract") Corpus2::AnnotatedSentence; + +%template(chan_map_t) std::map<std::string, Corpus2::AnnotationChannel>; +%template(SentencePtr) boost::shared_ptr<Corpus2::Sentence>; +%template(AnnotatedSentencePtr) boost::shared_ptr<Corpus2::AnnotatedSentence>; + +namespace Corpus2 { + class AnnotatedSentence : public Corpus2::Sentence { + public: + typedef std::map<std::string, AnnotationChannel> chan_map_t; + + /* --------------------------------------------------------------------- */ + AnnotatedSentence(); + ~AnnotatedSentence(); + + /* --------------------------------------------------------------------- */ + Sentence::Ptr clone_shared() const; + + static boost::shared_ptr<AnnotatedSentence> wrap_sentence( + const boost::shared_ptr<Sentence>& s); + static boost::shared_ptr<AnnotatedSentence> wrap_sentence_clone( + const boost::shared_ptr<Sentence>& s); + + /* --------------------------------------------------------------------- */ + void create_channel(const std::string& name); + bool has_channel(const std::string& name) const; + + AnnotationChannel& get_channel(const std::string& name); + const AnnotationChannel& get_channel(const std::string& name) const; + const chan_map_t& all_channels() const; + + /* --------------------------------------------------------------------- */ + void append(Token *t); + + /* --------------------------------------------------------------------- */ + std::string annotation_info() const; + }; +} + +using namespace std; +using namespace Corpus2; + +#endif /* SWIG_LIBCORPUS2_ANNOTATEDSENTENCE_I */