diff --git a/swig/Makefile b/swig/Makefile index a089f80d4289a3fea7a92f1dc8e843ad57f1a799..d2e51bdbb937c7027f0268968089ee45aaa95024 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -13,22 +13,28 @@ ANTLRLIB=/usr/lib/libantlr-pic.a CPPFLAGS=-fPIC -O2 -CBIN=libcorpustag.o +CBIN=libcorpustag.o \ + libcorpustagset.o CBINOUT=_boost_shared_ptr.so \ - _libcorpustag.so + _libcorpustag.so \ + _libcorpustagset.so CWRAP=boost_shared_ptr_wrap.cxx \ - libcorpustag_wrap.cxx + libcorpustag_wrap.cxx \ + libcorpustagset_wrap.cxx CWRAPBIN=boost_shared_ptr_wrap.o \ - libcorpustag_wrap.o + libcorpustag_wrap.o \ + libcorpustagset_wrap.o PYMODULES=boost_shared_ptr.py \ - libcorpustag.py + libcorpustag.py \ + libcorpustagset.py PYCBIN=boost_shared_ptr.pyc \ - libcorpustag.pyc + libcorpustag.pyc \ + libcorpustagset.pyc # ----------------------------------------------------------------------------- all:boost_shared_ptr.o $(CBIN) @@ -55,6 +61,13 @@ libcorpustag.o: $(CPP) -shared libcorpustag_wrap.o \ $(PWRUTILBIN) $(CORPUS2BIN) -o _libcorpustag.so +# Tagset +libcorpustagset.o: + $(SWIG) $(SWIGOPTS_LANG) libcorpustagset.i + $(CPP) -c libcorpustagset_wrap.cxx -I$(PYTHONDIR) $(CPPFLAGS) + $(CPP) -shared libcorpustagset_wrap.o \ + $(PWRUTILBIN) $(CORPUS2BIN) -o _libcorpustagset.so + # ----------------------------------------------------------------------------- clean: rm -f $(CBIN) $(CBINOUT) $(CWRAP) $(CWRAPBIN) $(PYMODULES) $(PYCBIN) diff --git a/swig/libcorpustagset.i b/swig/libcorpustagset.i new file mode 100644 index 0000000000000000000000000000000000000000..4744f80e23f106c0353b835d37c76cd1943917f4 --- /dev/null +++ b/swig/libcorpustagset.i @@ -0,0 +1,82 @@ +#ifndef SWIG_LIBCORPUS2_TAGSET_I +#define SWIG_LIBCORPUS2_TAGSET_I + +%module libcorpustagset +%{ + #include <libcorpus2/tagset.h> +%} + +%include "libcorpustag.i" + +%include "std_string.i" +%include "std_vector.i" + +%feature("notabstract") Corpus2::Tagset; + +namespace Corpus2 { + class Tagset { + public: + + enum ParseMode { + ParseCheckRequired = 1, + ParseAllowExtra = 2, + ParseCheckSingular = 4, + + ParseDefault = ParseCheckRequired, + ParseRequiredWithExtra = ParseCheckRequired | ParseAllowExtra, + ParseStrict = ParseCheckRequired | ParseCheckSingular, + ParseLoose = ParseAllowExtra + }; + + Tagset(); + static Tagset from_data(const char*); + + /* --------------------------------------------------------------------- */ + Tag parse_symbol(const std::string& s) const; + Tag parse_symbol_string(const std::string& s) const; + + /* --------------------------------------------------------------------- */ + std::vector<Tag> parse_tag(const char* c, ParseMode m = ParseDefault) const; + Tag parse_simple_tag(const char* c, ParseMode mode = ParseDefault) const; + Tag make_ign_tag() const; + + /* --------------------------------------------------------------------- */ + std::string tag_to_string(const Tag& tag) const; + std::string tag_to_no_opt_string(const Tag &tag) const; + + /* --------------------------------------------------------------------- */ + std::vector<std::string> tag_to_symbol_string_vector(const Tag& tag, bool + compress_attribites = true) const; + + std::string tag_to_symbol_string(const Tag& tag, + bool compress_attribites = true) const; + + /* --------------------------------------------------------------------- */ + size_t tag_size(const Tag& tag) const; + bool tag_is_singular(const Tag& tag) const; + + /* --------------------------------------------------------------------- */ + std::vector<Tag> split_tag(const Tag& tag) const; + + /* --------------------------------------------------------------------- */ + int pos_count() const; + int attribute_count() const; + int value_count() const; + size_t size() const; + + double size_extra() const; + + /* --------------------------------------------------------------------- */ + std::string name() const; + void set_name(const std::string& name); + + + std::string id_string() const; + std::string id_string(const Tag& tag) const; + }; +} + +using namespace std; +using namespace Corpus2; + +#endif /* SWIG_LIBCORPUS2_TAGSET_I */