diff --git a/swig/Makefile b/swig/Makefile index 4ee6bfd9d6f789f2e643df75bdd2a1bd20d6820d..63c97ce43f8a04197c9f3b0d91c80e2a6cbb1d4c 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -39,6 +39,7 @@ CBIN=libcclvalue.o \ libcclmatchrule.o \ libcclmatchrulesequence.o \ libcclfunctionalopsequence.o \ + libccllexicon.o \ libcclwcclfileopsections.o \ libcclwcclfile.o \ wccl.o @@ -67,6 +68,7 @@ CBINOUT=_libcclvalue.so \ _libcclmatchrule.so \ _libcclmatchrulesequence.so \ _libcclfunctionalopsequence.so \ + _libccllexicon.so \ _libcclwcclfileopsections.so \ _wccl.so \ _boost_shared_ptr.so @@ -95,6 +97,7 @@ CWRAP=libcclvalue_wrap.cxx \ libcclmatchrule_wrap.cxx \ libcclmatchrulesequence_wrap.cxx \ libcclfunctionalopsequence_wrap.cxx \ + libccllexicon_wrap.cxx \ libcclwcclfileopsections_wrap.cxx \ wccl_wrap.cxx \ boost_shared_ptr_wrap.cxx @@ -123,6 +126,7 @@ CWRAPBIN=libcclvalue_wrap.o \ libcclmatchrule_wrap.o \ libcclmatchrulesequence_wrap.o \ libcclfunctionalopsequence_wrap.o \ + libccllexicon_wrap.o \ libcclwcclfileopsections_wrap.o \ wccl_wrap.o \ boost_shared_ptr_wrap.o @@ -151,6 +155,7 @@ PYMODULES=libcclvalue.py \ libcclmatchrule.py \ libcclmatchrulesequence.py \ libcclfunctionalopsequence.py \ + libccllexicon.py \ libcclwcclfileopsections.py \ wccl.py \ boost_shared_ptr.py @@ -179,6 +184,7 @@ PYCBIN=libcclvalue.pyc \ libcclmatchrule.pyc \ libcclmatchrulesequence.pyc \ libcclfunctionalopsequence.pyc \ + libccllexicon.pyc \ libcclwcclfileopsections.pyc \ wccl.pyc \ boost_shared_ptr.pyc @@ -374,6 +380,13 @@ libcclfunctionalopsequence.o: $(CPP) -shared libcclfunctionalopsequence_wrap.o \ $(CCLBIN) $(ANTLRLIB) -o _libcclfunctionalopsequence.so +# Lexicon +libccllexicon.o: + $(SWIG) $(SWIGOPTS_LANG) libccllexicon.i + $(CPP) -c libccllexicon_wrap.cxx -I$(PYTHONDIR) -I$(WCCLDIR) $(CPPFLAGS) + $(CPP) -shared libccllexicon_wrap.o \ + $(CCLBIN) $(ANTLRLIB) -o _libccllexicon.so + # WcclFileOpSections libcclwcclfileopsections.o: $(SWIG) $(SWIGOPTS_LANG) libcclwcclfileopsections.i diff --git a/swig/libccllexicon.i b/swig/libccllexicon.i new file mode 100644 index 0000000000000000000000000000000000000000..69cc3240af27e9aacfb7303fa37c8b0e7d1611fa --- /dev/null +++ b/swig/libccllexicon.i @@ -0,0 +1,69 @@ +#ifndef SWIG_LIBWCCL_LEXICON_I +#define SWIG_LIBWCCL_LEXICON_I + +%module libccllexicon +%{ + #include <libwccl/lexicon/lexicon.h> + + #include <libcorpus2/lexeme.h> + #include <boost/unordered_map.hpp> +%} + +%include "libcclstrset.i" + +%include "std_string.i" +%include "boost_shared_ptr.i" + +%rename(map_t) boost::unordered_map<UnicodeString, UnicodeString>; + +%nodefaultctor Wccl::Lexicon; + +namespace Wccl { + class Lexicon { + public: + typedef boost::unordered_map<UnicodeString, UnicodeString> map_t; + + /* --------------------------------------------------------------------- */ + + Lexicon(const std::string& name, const std::string& file_name); + + /* --------------------------------------------------------------------- */ + + const UnicodeString& translate(const UnicodeString& key) const; + // boost::shared_ptr<StrSet> translate(const StrSet& set) const; + + // TODO + // std::string translate_utf8(const std::string&); + + /* --------------------------------------------------------------------- */ + + std::string name() const; + std::string file_name() const; + + /* --------------------------------------------------------------------- */ + + bool has_key(const UnicodeString& key) const; + + // TODO + // bool has_key_utf8(const std::string& key) const + + /* --------------------------------------------------------------------- */ + + void insert(const UnicodeString& key, const UnicodeString& value); + void insert(const UnicodeString& key); + + // TODO + // void insert_utf8(const std::string& key, const std::string& value); + // void insert_utf8(const std::string& key); + + /* --------------------------------------------------------------------- */ + + const map_t& map() const; + }; +} + +using namespace boost; +using namespace Wccl; +using namespace std; + +#endif /* SWIG_LIBWCCL_LEXICON_I */