diff --git a/swig/annotatedsentence.i b/swig/annotatedsentence.i index 87cb5a34cc71ce228d850fee00178ea95883f07a..e04c0a05f02f627f621fb848496a911c70b271e8 100644 --- a/swig/annotatedsentence.i +++ b/swig/annotatedsentence.i @@ -17,9 +17,8 @@ %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>; +%template(ConstAnnotatedSentencePtr) boost::shared_ptr<const Corpus2::AnnotatedSentence>; namespace Corpus2 { class MissingAnnotationChannel : public Corpus2Error { diff --git a/swig/annotationchannel.i b/swig/annotationchannel.i index 8ffeb1db171648af87c95b367710cde1be92c870..405c0ca8b6016940bf166aecc55dd666aa8b4bb8 100644 --- a/swig/annotationchannel.i +++ b/swig/annotationchannel.i @@ -8,14 +8,21 @@ %include "std_string.i" %include "std_vector.i" +%include "boost_shared_ptr.i" %include "iob.i" %include "std_defs.i" -// %template(IntVector) std::vector<int>; -%template(IOBVector) std::vector<Corpus2::IOB::Enum>; +%template(chan_map_t) std::map<std::string, Corpus2::AnnotationChannel>; + +%template(AnnotationoPtr) boost::shared_ptr<Corpus2::Annotation>; +%template(ConstAnnotationoPtr) boost::shared_ptr<const Corpus2::Annotation>; + %template(AnnotationVector) std::vector<Corpus2::Annotation>; +%template(AnnotationChannelPtr) boost::shared_ptr<Corpus2::AnnotationChannel>; +%template(ConstAnnotationChannelPtr) boost::shared_ptr<const Corpus2::AnnotationChannel>; + namespace Corpus2 { struct Annotation { Annotation() : indices(), head_index(-1), seg_number(0) {} diff --git a/swig/annotationview.i b/swig/annotationview.i index 10fbb1c0dde1dfe9fde3675e6334fa9a28c9735c..977c1d37bfdfe0f9bf27585aa80b836c66f09b62 100644 --- a/swig/annotationview.i +++ b/swig/annotationview.i @@ -14,6 +14,7 @@ %include "boost_shared_ptr.i" %template(AnnotationViewPtr) boost::shared_ptr<Corpus2::AnnotationView>; +%template(ConstAnnotationViewPtr) boost::shared_ptr<const Corpus2::AnnotationView>; %nodefaultctor Corpus2::TokenWriter; @@ -24,7 +25,7 @@ namespace Corpus2 { ~AnnotationView(); /* --------------------------------------------------------------------- */ - Ptr clone_shared() const; + boost::shared_ptr<Sentence> clone_shared() const; /* --------------------------------------------------------------------- */ void commit(); diff --git a/swig/chunk.i b/swig/chunk.i index b0af757de2729b7f3300ff5d13e043af76f25028..44ba6b98807b2e17d50fd9b22222e6cbfd077e7c 100644 --- a/swig/chunk.i +++ b/swig/chunk.i @@ -8,7 +8,6 @@ %include "std_defs.i" - %include "std_set.i" %include "std_map.i" %include "std_pair.i" @@ -22,9 +21,6 @@ %template(ConstChunkPtr) boost::shared_ptr<const Corpus2::Chunk>; %template(ChunkPtrVector) std::vector< boost::shared_ptr<Corpus2::Chunk> >; -%template(SentencePtrVector) std::vector<boost::shared_ptr<Sentence> >; -// %template(attr_map_t) std::map<std::string, std::string>; - namespace Corpus2 { class Chunk { public: diff --git a/swig/iob.i b/swig/iob.i index 0f4be84c4cd84e57fd20d61fdab8cd7fd2f15c43..361e6c5bcbc7d22984b1940e1e11d220defd6c2d 100644 --- a/swig/iob.i +++ b/swig/iob.i @@ -6,7 +6,7 @@ #include <libcorpus2/ann/iob.h> %} -// %include "...i" +%template(IOBVector) std::vector<Corpus2::IOB::Enum>; namespace Corpus2 { namespace IOB { diff --git a/swig/lexeme.i b/swig/lexeme.i index c78ade4a916995be95f6beb240ad5c9fee7ed8e7..00646e28ac8566245a9d8ae8e130bcf37b7a27e7 100644 --- a/swig/lexeme.i +++ b/swig/lexeme.i @@ -18,7 +18,7 @@ %rename(__op_eq__) Corpus2::Lexeme::operator==(const Lexeme& other) const; %rename(__op_lw__) Corpus2::Lexeme::operator<(const Lexeme& other) const; -/* %template(TagPtr) boost::shared_ptr<Corpus2::Tag>; */ +%template(LexemeVector) std::vector<Corpus2::Lexeme>; namespace Corpus2 { class Lexeme { diff --git a/swig/relation.i b/swig/relation.i index 64084f2cbb28afeddd2fdeb93d3d5373a681de33..89bc46d6495c5aa447583ddd6564114f8cfc2863 100644 --- a/swig/relation.i +++ b/swig/relation.i @@ -10,7 +10,6 @@ %include "std_string.i" %include "boost_shared_ptr.i" -// %feature("notabstract") Corpus2::TokenMetaData; %template(DirectionPointPtr) boost::shared_ptr<Corpus2::DirectionPoint>; %template(ConstDirectionPointPtr) boost::shared_ptr<const Corpus2::DirectionPoint>; diff --git a/swig/sentence.i b/swig/sentence.i index f639b2f62f476a866ce8f159cf7c109dff394aa8..edf2c47349bc509bbfa53ddf09326413cf2bb98a 100644 --- a/swig/sentence.i +++ b/swig/sentence.i @@ -10,9 +10,11 @@ %include "token.i" %include "boost_shared_ptr.i" -%template(Ptr) boost::shared_ptr<Corpus2::Sentence>; -%template(ConstPtr) boost::shared_ptr<const Corpus2::Sentence>; -%template(TokenPtrVector) std::vector<Corpus2::Token*>; +%template(SentencePtr) boost::shared_ptr<Corpus2::Sentence>; +%template(ConstSentencePtr) boost::shared_ptr<const Corpus2::Sentence>; + +%template(SentencePtrVector) std::vector<boost::shared_ptr<Corpus2::Sentence> >; +%template(ConstSentencePtrVector) std::vector<boost::shared_ptr<const Corpus2::Sentence> >; namespace Corpus2 { class Sentence { diff --git a/swig/tag.i b/swig/tag.i index 0197662fe0b59e1d699581e0709d180f746fbd31..146175ebf8450e0d46d668014702e1342493ee3d 100644 --- a/swig/tag.i +++ b/swig/tag.i @@ -20,6 +20,8 @@ %rename(__op_eq__) Corpus2::Tag::operator==(const Tag& other) const; %rename(__op_lw__) Corpus2::Tag::operator<(const Tag& other) const; +%template(TagVector) std::vector<Corpus2::Tag>; + namespace Corpus2 { class Tag { public: diff --git a/swig/tagset.i b/swig/tagset.i index f4305db95e85f9f74d17f4c2cb64fa2b8a96609c..8fe526eac23a65477117b0ecec007a3a806e5f4a 100644 --- a/swig/tagset.i +++ b/swig/tagset.i @@ -15,8 +15,8 @@ %feature("notabstract") Corpus2::Tagset; -%template(TagVector) std::vector<Corpus2::Tag>; -// %template(StdStringVector) std::vector<std::string>; +%template(TagsetPtr) boost::shared_ptr<Corpus2::Tagset>; +%template(ConstTagsetPtr) boost::shared_ptr<const Corpus2::Tagset>; namespace Corpus2 { class Tagset; diff --git a/swig/tagsetmanager.i b/swig/tagsetmanager.i index a4aa9f4df135ef5273ec4affa998007d5a993801..113ed7e1c65505d7c5722a1541af844683e768ed 100644 --- a/swig/tagsetmanager.i +++ b/swig/tagsetmanager.i @@ -14,7 +14,6 @@ %include "boost_shared_ptr.i" %feature("notabstract") Corpus2::TagsetManager; -%template(TagsetPtr) boost::shared_ptr<Tagset>; namespace Corpus2 { class TagsetNotFound : public Corpus2Error { diff --git a/swig/token.i b/swig/token.i index 19a0c56b1cc0c05b9ce6381e2c17169618df4e52..e90abc86b9462728d206750733f23a9259085ad8 100644 --- a/swig/token.i +++ b/swig/token.i @@ -20,7 +20,11 @@ %rename(__op_eq__) Corpus2::Token::operator==(const Corpus2::Token& other) const; -%template(LexemeVector) std::vector<Corpus2::Lexeme>; +%template(TokenPtr) boost::shared_ptr<Corpus2::Token>; +%template(ConstTokenPtr) boost::shared_ptr<const Corpus2::Token>; + +%template(TokenPtrVector) std::vector<Corpus2::Token*>; +%template(ConstTokenPtrVector) std::vector<const Corpus2::Token*>; namespace Corpus2 { class Token { diff --git a/swig/tokenmetadata.i b/swig/tokenmetadata.i index 422442be9f16b389913f424ed771ed14f829b010..8a80fd7add595b74e1bc9e2faa70045c2d864857 100644 --- a/swig/tokenmetadata.i +++ b/swig/tokenmetadata.i @@ -15,6 +15,7 @@ %feature("notabstract") Corpus2::TokenMetaData; %template(TokenMetaDataPtr) boost::shared_ptr<Corpus2::TokenMetaData>; +%template(ConstTokenMetaDataPtr) boost::shared_ptr<const Corpus2::TokenMetaData>; namespace Corpus2 { class TokenMetaData { diff --git a/swig/tokenreader.i b/swig/tokenreader.i index 505d6643122147e9641104151f85d4a36281b09b..1770331649bb1fce551a1a609fd154c2d5262cf9 100644 --- a/swig/tokenreader.i +++ b/swig/tokenreader.i @@ -17,11 +17,12 @@ %include "boost_shared_ptr.i" %nodefaultctor Corpus2::TokenReader; + %template(TokenReaderPtr) boost::shared_ptr<Corpus2::TokenReader>; -%template(TokenPtr) boost::shared_ptr<Corpus2::Token>; -// %template(StdStringVector) std::vector<std::string>; -// %template(ChunkPtr) boost::shared_ptr<Corpus2::Chunk>; -typedef boost::shared_ptr<Corpus2::Token> TokenPtr; +%template(ConstTokenReaderPtr) boost::shared_ptr<const Corpus2::TokenReader>; + +// typedef boost::shared_ptr<Corpus2::Token> TokenPtr; + namespace Corpus2 { class TokenReader { public: diff --git a/swig/tokenwriter.i b/swig/tokenwriter.i index bb55c1adfd372f89b4b995e1060387afe2040988..495e4b03b2196c1ddc9942d228973a2600a7e01d 100644 --- a/swig/tokenwriter.i +++ b/swig/tokenwriter.i @@ -15,7 +15,9 @@ %include "boost_shared_ptr.i" %nodefaultctor Corpus2::TokenWriter; + %template(TokenWriterPtr) boost::shared_ptr<Corpus2::TokenWriter>; +%template(ConstTokenWriterPtr) boost::shared_ptr<const Corpus2::TokenWriter>; namespace Corpus2 { class TokenWriter { diff --git a/swig/unicodestring.i b/swig/unicodestring.i index 30997d7d1a91929648fea39967dc7a85107e2984..ee6f0963a76aafb649815fd38325798e0ee5174e 100644 --- a/swig/unicodestring.i +++ b/swig/unicodestring.i @@ -17,11 +17,11 @@ class UnicodeString { UChar* getTerminatedBuffer(); %pythoncode %{ - def __unicode__(self): - return self.as_utf16().decode('utf16') + def __unicode__(self): + return self.as_utf16().decode('utf16') - def __str__(self): - return self.as_utf8() + def __str__(self): + return self.as_utf8() %} }; @@ -31,11 +31,11 @@ class UnicodeString { return std::string((char*)self->getTerminatedBuffer(), self->length()*2); } - std::string as_utf8() { - std::string r; - self->toUTF8String(r); - return r; - } + std::string as_utf8() { + std::string r; + self->toUTF8String(r); + return r; + } }